******************************************************************; *Author: Anand Vidyashankar ; *Title : rats_mixed model _1_analysis.sas ; ******************************************************************; *Accesses the data set from the library ; libname rats "C:\Teaching_Fall 2004\Teaching\Fall_2006\ILRST711"; *Create SAS data set from the library; %macro hide; data one; set rats.rats; run; *Prints the SAS dataset; proc print data=one; run; *Sorts the dataset; proc sort data=one; by rat; run; *Prints the sorted data; proc print data=one; title "sorted data"; run; *Keep just the control data; data onec; set one; if treat="con"; run; proc print data=onec; title "control data"; run; %mend hide; data one; set one; t1=t; run; proc mixed data=one; class rat; model y=t/s; random rat/s; make "solutionR" out=rs; run; proc mixed data=one ; class rat; model y=t /outpred=op1 outpredm=opm1 s ; random rat/s; ods output solutionR=rs1; title "random effects solutions from ods"; run; proc print data=op1; title "predicted values"; run; proc print data=opm1; title "means of predicted values"; run; proc means data=onec; var y; by rat; output out=oonec mean=amean; run; proc print data=oonec; title "Mean values from each Rat"; run; data rs1; merge oonec rs1; by rat; run; data rs1; set rs1; if amean=. then delete; run; proc print data=rs1; title "Random effect solutions from ods"; run; *marginal model; proc mixed data=one ; class rat t; model y= /s; repeated t /type=cs sub=rat; title "marginal model"; run; *conditional model; proc mixed data=one ; class rat; model y= /s; random rat; title "conditional model"; run; *Methods of Estimation; *Maximum likelihood under conditional specification; proc mixed data=one method=ml; class rat treat; model y=t treat/s; random rat; title "maximum likelihood for treatment comparisons"; run; *Autocorrelated errors Model; proc mixed data=one method=ml; class rat treat t1; model y=t treat/s; random rat/type=vc grp=treat; repeated /type=ar(1) sub=rat; title "maximum likelihood for treatment comparisons with autocorrelated residuals"; run; *Autocorrelated errors with group dependent slopes Model; proc mixed data=one method=ml; class rat treat t1; model y=t*treat treat/s; random rat/type=vc grp=treat; repeated /type=ar(1) sub=rat; title "maximum likelihood for treatment comparisons with autocorrelated residuals"; run; proc mixed data=one method=ml; class rat treat t1; model y=t*treat treat/s; random rat/type=vc grp=treat; repeated /type=ar(1) sub=rat; title "maximum likelihood for treatment comparisons with autocorrelated residuals"; run;