1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;5556 /* Lynch1.sas */57 title 'Hovland and Sears Lynching data';5859 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." */71NOTE: 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)=3083NOTE: 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 secondscpu time 0.00 seconds72 proc sgplot;73 title2 'Lynchings and Cotton Prices over Time';74 series x=year y=cotton2;75 series x=year y=totlynch / y2axis;7677 proc means;NOTE: PROCEDURE SGPLOT used (Total process time):real time 0.49 secondscpu time 0.12 secondsNOTE: 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 secondscpu time 0.06 seconds79 proc corr;80 var year -- olynch;8182NOTE: PROCEDURE CORR used (Total process time):real time 0.09 secondscpu time 0.09 seconds83 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 */88NOTE: The data set WORK.DIXIE has 48 observations and 9 variables.NOTE: PROCEDURE REG used (Total process time):real time 0.06 secondscpu time 0.06 seconds89 proc arima;90 title2 'Autocorrelations and partial autocorrelations';91 identify var = epsilonhat;9293 /* That looks like an AR(1) */9495 /* Apparently SAS university Edition does not include proc autoreg,96 so this does not work.9798 *********************************************************99 proc autoreg;100 title2 'Fit AR(1) with proc autoreg';101 model totlynch = year cotton2 / nlag=1 method=ml;102 *********************************************************/103NOTE: PROCEDURE ARIMA used (Total process time):real time 0.60 secondscpu time 0.13 seconds104 proc mixed;105 title2 'Fit AR(1) with proc mixed';106 model totlynch = year cotton2 / solution;107 repeated / type=ar(1) subject=one;108109 /* Test for difference between AR(1) and ARMA(1,1), using110 a likelihood ratio chi-squared test. AR(1) is the111 reduced model. Fit the models with maximum likelihood. */112NOTE: Convergence criteria met.NOTE: PROCEDURE MIXED used (Total process time):real time 0.11 secondscpu time 0.09 seconds113 proc mixed method=ml;114 title2 'Reduced model is AR(1)';115 model totlynch = year cotton2 / solution;116 repeated / type=ar(1) subject=one;117NOTE: Convergence criteria met.NOTE: PROCEDURE MIXED used (Total process time):real time 0.08 secondscpu time 0.08 seconds118 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;122NOTE: Convergence criteria met.NOTE: PROCEDURE MIXED used (Total process time):real time 0.09 secondscpu time 0.08 seconds123 proc iml;NOTE: IML Ready124 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;127128129130 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;142