/* RepeatedMonkey.sas */ title 'Primate hippocampal function: Zola-Morgan and Squire, 1990'; title2 'Covariance Structure approach to repeated measures (within-cases)'; data memory; infile '/folders/myfolders/monkey.data.txt' firstobs=2; input monkey $ treatment $ week2 week4 week8 week12 week16; /* Make 5 "cases" in the data set for each line in the raw data file. The output command generates a case. */ id = _n_; time = 2; score = week2; output; time = 4; score = week4; output; time = 8; score = week8; output; time = 12; score = week12; output; time = 16; score = week16; output; keep monkey treatment id time score; proc print; proc freq; tables time*treatment /norow nocol nopercent; tables monkey; proc mixed cl; 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. */ /* We did not reject the null hypothesis that observations from the same subject are independent. Try an ordinary 2-way ANOVA, mostly for the interaction plot. */ proc glm; title3 'Ordinary 2-way'; class time treatment; /* This order determines the plot. */ model score = treatment|time; /* Could justify compound symmetry: Each monkey brings her own special talent for discrimination learning. */ proc mixed cl; title3 'Compound Symmetry'; class treatment time; model score = treatment|time; repeated / type=cs subject=id r; /* Contrast statements to follow up the interaction are possible but challenging. */ data unimemory; infile '/folders/myfolders/monkey.data.txt' firstobs=2; input monkey $ treatment $ week2 week4 week8 week12 week16; twovs16 = week2-week16; /* Could do all 15 pairwise differences*/ proc glm; class treatment; model twovs16=treatment; proc glm data=memory; title3 'Classical (Same results as CS)'; class treatment time monkey; model score = treatment|time monkey(treatment); random monkey(treatment) / test;