PROC IMPORT OUT= WORK.autism DATAFILE= "C:\temp\autism.csv" DBMS=CSV REPLACE; GETNAMES=YES; DATAROW=2; RUN; data autism2; set autism; age_2 = age-2; age_2sq = age_2*age_2; run; title "Model 6.3 (REML)"; ods output influence=inf_dat solutionR=eblup_dat; ods exclude influence solutionR; proc mixed data = autism2 covtest; class childid sicdegp; model vsae = sicdegp age_2 age_2sq age_2*sicdegp / solution ddfm=sat influence residual outpred=outp_dat outpredm=outpm_dat; random age_2 age_2sq / subject = childid solution g v vcorr type = un; run; goptions reset=all; goptions device=win target=winprtm ftext=swissb fby=swissb hby=2 ; /*Figure 6.6: Studentized Conditional Residuals vs. Predicted Values*/ axis1 order= -6 to 8 by 2 label=(height=1.5 angle=90 "Studentized Residual"); axis2 order= 0 to 200 by 50 label=(height=1.5 "Fitted Values"); symbol1 color=black value=circle r=156; proc sort data=outp_dat; by sicdegp ; run; title "Figure 6.6"; proc gplot data=outp_dat; by sicdegp; plot StudentResid * Pred / vref=0 vaxis=axis1 haxis=axis2; run; quit; /*Figure 6.7: Conditional Raw Residuals vs. Age_2*/ axis1 order= -30 to 50 by 20 label=(height=1.5 angle=90 "Residuals"); axis2 order= 0 to 12 by 2 offset=(4,4) label=(height=1.5 "AGE_2"); title "Figure 6.7"; proc gplot data=outp_dat; plot Resid * Age_2 / vref=0 vaxis=axis1 haxis=axis2; run; quit; /*Figure 6.8: Normal QQ Plot of Conditional Residuals by SICDEGP*/ /*Note: SAS reverses order of X and Y axes for QQ plot compared to R*/ title "Figure 6.8"; proc univariate data=outp_dat noprint; by sicdegp; var Resid; qqplot / normal (mu=est sigma=est); run; /*Figure 6.9: Normal QQ Plot of EBLUPS for Random Effects*/ /*Again Note: SAS reverses X and Y axes compared to R for QQ plots*/ title "Figure 6.9 for Age_2"; proc univariate data=eblup_dat noprint; where effect="age_2"; var Estimate; qqplot / normal (mu=est sigma=est); format estimate 4.2; run; title "Figure 6.9 for Age_2 Squared"; proc univariate data=eblup_dat noprint; where effect="age_2sq"; var Estimate; format estimate 4.2; qqplot / normal (mu=est sigma=est); run; /*Figure 6.10: Scatterplots of EBLUPS for AGE_2SQ vs. AGE_2 */ /*Note: Some data base manipulation is required to get set up for the graph*/ /*Create new data sets, one for each set of EBLUPS*/ data eb1(rename=(estimate=Age_2)) eb2(rename=(estimate=Age_2Sq)); set eblup_dat; if effect = "age_2" then output eb1; if effect = "age_2sq" then output eb2; run; /*Create a data set with one observation per child, that includes SICDEGP to merge with EBLUPS, so we can use SICDEGP in the plots*/ proc freq noprint data=autism; tables childid * sicdegp / out=tabdat; run; data eb; merge tabdat eb1 eb2; by childid; run; proc sort data=eb; by sicdegp; run; title "Figure 6.10"; axis1 order= -1 to 1 by .5 label=(height=1.5 angle=90 "Age_2 Squared"); axis2 order= -6 to 14 by 4 offset=(4,4) label=(height=1.5 "AGE_2"); proc gplot data=eb; by sicdegp; plot age_2sq * age_2 / vaxis=axis1 haxis=axis2; format age_2 2. age_2sq 3.1; run; quit; /*Figure 6.11: Scatterplots of Observed vs. Conditional Predicted Scores by SICDEGP */ proc sort data=outp_dat; by sicdegp; run; axis1 order= 0 to 200 by 50 offset=(4,4) label=(height=1.5 angle=90 "VSAE"); axis2 order= 0 to 200 by 50 offset=(4,4) label=(height=1.5 "Fitted Values"); title "Figure 6.11"; proc gplot data=outp_dat; by sicdegp; plot vsae*pred/ vaxis=axis1 haxis=axis2; run; quit; /*This has to be run using SAS 9.2*/ /* proc template; define statgraph mygraphs.datalattice; layout gridded; entrytitle 'VSAE Over Time'; layout lattice columnvar= sicdegp rowvar=childid/ headerlabeldisplay=value rowaxisopts=(griddisplay=on label=' ') columnaxisopts=(griddisplay=on label=' '); layout prototype; seriesplot x=age y=vsae; endlayout; endlayout; endlayout; end; run; proc template; define statgraph mygraphs.datapanel; layout gridded; entrytitle 'VSAE Over Time'; layout datapanel classvars=(childid sicdegp)/ rows=3 order=rowmajor rowaxisopts=(griddisplay=on label=' ') columnaxisopts=(griddisplay=on label=' '); layout prototype; seriesplot x=date y=actual; endlayout; endlayout; endlayout; end; run; */