/* monkey2.sas (2018 version) */ title 'Covariance structure approach on the monkey data'; title2 'Primate hippocampal function: Zola-Morgan and Squire (1990)'; /* Science, Vol. 250 (12 Oct. 1990) , Pages 288-290 */ data remember; infile '/folders/myfolders/441s18/Lecture/monkey.data.txt' firstobs=2; input monkey $ treatment $ week2 week4 week8 week12 week16; /* Need one line per response */ id = _n_; /* A little more convenient than the monkeys' names */ t2=2; t4=4; t8=8; t12=12; t16=16; /* Time since learning the task in weeks */ array t{5} t2 -- t16; array week{5} week2 -- week16; do j = 1 to 5; time = t{j}; score = week{j}; output; end; keep monkey treatment id time score; proc print data=remember (obs=10); /* Just first 10 lines */ run; proc mixed data=remember; title3 'Unstructured Covariance Matrix'; class treatment time; model score = treatment|time; repeated / type=un subject=id r; /* Could have used subject=monkey, but then monkey must be declared in class because it's character-valued. */ run; /* Could justify compound symmetry: Each monkey brings her own special talent for discrimination learning. */ proc mixed data=remember; title3 'Compound Symmetry'; class treatment time; model score = treatment|time; repeated / type=cs subject=id r; run; /* You can test hypotheses with proc mixed that are out of reach with other software. */ data forget; set remember; if treatment = 'CONTROL' then treat=1; else treat=2; combo = 100*treat + time; /* proc freq; tables (treatment time) * combo / norow nocol nopercent missing; */ proc means mean maxdec=3; class combo; var score; quit; ods select Contrasts Estimates; proc mixed data=forget; title3 'Test treatment effect at each week, and estimate one difference'; class combo; model score = combo; repeated / type=cs subject=id r; /* Control Treated */ /* 2 4 8 12 16 2 4 8 12 16 */ /* ------------------------------- */ contrast 'TreatAtWeek2' combo 1 0 0 0 0 -1 0 0 0 0; contrast 'TreatAtWeek4' combo 0 1 0 0 0 0 -1 0 0 0; contrast 'TreatAtWeek8' combo 0 0 1 0 0 0 0 -1 0 0; contrast 'TreatAtWeek12' combo 0 0 0 1 0 0 0 0 -1 0; contrast 'TreatAtWeek16' combo 0 0 0 0 1 0 0 0 0 -1; /* Estimate difference between Treated at Week 2 and Control at Week 16 */ estimate 'Control16 minus Treated2' combo 0 0 0 0 1 -1 0 0 0 0 / CL; run;