1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
55
56 /* Lynch1.sas */
57 title 'Hovland and Sears Lynching data';
58
59 data lynch;
60 infile '/folders/myfolders/Lynch.data.txt' firstobs=7;
61 /* Skipping the header */
62 input Year Ayres Cotton1 Cotton2 Blynch Totlynch;
63 label ayres = 'Ayres'' composite economic index'
64 cotton1 = 'Per-acre value of cotton'
65 cotton2 = 'Farm value of cotton'
66 blynch = 'Negro lynchings'
67 totlynch = 'Total lynchings';
68 olynch = totlynch-blynch;
69 label olynch = 'Non-Black lynchings';
70 one=1; /* Used below -- one "subject." */
71
NOTE: The infile '/folders/myfolders/Lynch.data.txt' is:
Filename=/folders/myfolders/Lynch.data.txt,
Owner Name=root,Group Name=vboxsf,
Access Permission=-rwxrwx---,
Last Modified=22Mar2016:13:25:43,
File Size (bytes)=3083
NOTE: 48 records were read from the infile '/folders/myfolders/Lynch.data.txt'.
The minimum record length was 54.
The maximum record length was 55.
NOTE: The data set WORK.LYNCH has 48 observations and 8 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
72 proc sgplot;
73 title2 'Lynchings and Cotton Prices over Time';
74 series x=year y=cotton2;
75 series x=year y=totlynch / y2axis;
76
77 proc means;
NOTE: PROCEDURE SGPLOT used (Total process time):
real time 0.49 seconds
cpu time 0.12 seconds
NOTE: There were 48 observations read from the data set WORK.LYNCH.
78 var ayres -- olynch;
NOTE: There were 48 observations read from the data set WORK.LYNCH.
NOTE: PROCEDURE MEANS used (Total process time):
real time 0.06 seconds
cpu time 0.06 seconds
79 proc corr;
80 var year -- olynch;
81
82
NOTE: PROCEDURE CORR used (Total process time):
real time 0.09 seconds
cpu time 0.09 seconds
83 proc reg plots=none;
84 title2 'Naive regression, but request Durbin-Watson statistic';
85 title3 'Lower Durbin-Watson critical value = 1.5';
86 model totlynch = year cotton2 / dw;
87 output out = Dixie residual = epsilonhat; /* Save residuals */
88
NOTE: The data set WORK.DIXIE has 48 observations and 9 variables.
NOTE: PROCEDURE REG used (Total process time):
real time 0.06 seconds
cpu time 0.06 seconds
89 proc arima;
90 title2 'Autocorrelations and partial autocorrelations';
91 identify var = epsilonhat;
92
93 /* That looks like an AR(1) */
94
95 /* Apparently SAS university Edition does not include proc autoreg,
96 so this does not work.
97
98 *********************************************************
99 proc autoreg;
100 title2 'Fit AR(1) with proc autoreg';
101 model totlynch = year cotton2 / nlag=1 method=ml;
102 *********************************************************/
103
NOTE: PROCEDURE ARIMA used (Total process time):
real time 0.60 seconds
cpu time 0.13 seconds
104 proc mixed;
105 title2 'Fit AR(1) with proc mixed';
106 model totlynch = year cotton2 / solution;
107 repeated / type=ar(1) subject=one;
108
109 /* Test for difference between AR(1) and ARMA(1,1), using
110 a likelihood ratio chi-squared test. AR(1) is the
111 reduced model. Fit the models with maximum likelihood. */
112
NOTE: Convergence criteria met.
NOTE: PROCEDURE MIXED used (Total process time):
real time 0.11 seconds
cpu time 0.09 seconds
113 proc mixed method=ml;
114 title2 'Reduced model is AR(1)';
115 model totlynch = year cotton2 / solution;
116 repeated / type=ar(1) subject=one;
117
NOTE: Convergence criteria met.
NOTE: PROCEDURE MIXED used (Total process time):
real time 0.08 seconds
cpu time 0.08 seconds
118 proc mixed method=ml;
119 title2 'Full model is Autoregressive Moving Average: ARMA(1,1)';
120 model totlynch = year cotton2 / solution;
121 repeated / type=arma(1,1) subject=one;
122
NOTE: Convergence criteria met.
NOTE: PROCEDURE MIXED used (Total process time):
real time 0.09 seconds
cpu time 0.08 seconds
123 proc iml;
NOTE: IML Ready
124 title2 'Difference between -2 Log Likelihood values is chi-squared';
125 Chisquare = 443.7-441.5;
125 ! df=1;
125 ! pvalue = 1-probchi(Chisquare,df);
126 print Chisquare df pvalue;
127
128
129
130 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
142