1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
55
56 /******************** RepeatedNoise.sas ***********************
57 * Participants listened to political discussions under different *
58 * levels of background noise. "Discrimination score" is a measure *
59 * of how well they could tell what was being said. *
60 ******************************************************************/
61
62 title 'Noise data';
63
64 proc format;
64 ! value sexfmt 0 = 'Male' 1 = 'Female' ;
NOTE: Format SEXFMT is already on the library WORK.FORMATS.
NOTE: Format SEXFMT has been output.
65
NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
66 data loud;
67 infile '/folders/myfolders/noise.data.txt'; /* Univariate data read */
68 input ident interest sex age noise time discrim ;
69 format sex sexfmt.;
70 label interest = 'Interest in topic (politics)'
71 time = 'Order of presenting noise level';
72
NOTE: The infile '/folders/myfolders/noise.data.txt' is:
Filename=/folders/myfolders/noise.data.txt,
Owner Name=root,Group Name=vboxsf,
Access Permission=-rwxrwx---,
Last Modified=08Mar2016:00:31:45,
File Size (bytes)=8700
NOTE: 300 records were read from the infile '/folders/myfolders/noise.data.txt'.
The minimum record length was 27.
The maximum record length was 27.
NOTE: The data set WORK.LOUD has 300 observations and 7 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
73 proc freq;
74 tables sex*age*noise / norow nocol nopercent;
75
NOTE: There were 300 observations read from the data set WORK.LOUD.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.07 seconds
cpu time 0.08 seconds
76 proc glm;
77 title2 'Classical mixed model repeated measures';
78 class ident age sex noise;
79 model discrim = age|sex|noise ident(age*sex);
80 random ident(age*sex) / test;
81 means noise age;
82
83 /* Expected mean squares show that not all the hypotheses
84 are testable with the classical mixed model approach.
85 SAS is buying testability of the hypotheses by assuming
86 that you're only interested in an effect if all the
87 higher-order interactions involving that effect are
88 absent.
89
90 Also, we can't use the covariate and it's not clear how
91 to do multiple comparisons. */
92
NOTE: TYPE I EMS not available without the E1 option.
NOTE: Means from the MEANS statement are not adjusted for other terms in the model. For adjusted means, use the LSMEANS statement.
NOTE: PROCEDURE GLM used (Total process time):
real time 3.60 seconds
cpu time 0.36 seconds
93 proc mixed;
94 title2 'Covariance structure (cs) with proc mixed';
95 title3 'Replicate the classical tests';
96 class age sex noise;
97 model discrim = age|sex|noise;
98 repeated / type=cs subject=ident;
99
100
101
NOTE: Convergence criteria met.
NOTE: PROCEDURE MIXED used (Total process time):
real time 0.10 seconds
cpu time 0.09 seconds
102 proc mixed;
103 title2 'Include covariate, multiple comparisons, contrasts';
104 class age sex noise;
105 model discrim = interest age|sex|noise / solution;
106 /* solution shows the beta-hat values (interest) */
107 repeated / type=cs subject=ident r;
108 lsmeans age / pdiff tdiff adjust = bon;
109 lsmeans noise / pdiff tdiff adjust = bon;
110 contrast 'Noise Linear' noise 1 -2 1 0 0,
111 noise 0 1 -2 1 0,
112 noise 0 0 1 -2 1;
113 /* In the test for departure from linearity,
114 mu1-mu2 = mu2-mu3 => 1 -2 1 0 0
115 mu2-mu3 = mu3-mu4 => 0 1 -2 1 0
116 mu3-mu4 = mu4-mu5 => 0 0 1 -2 1 */
117
118 /* Compare results with unknown covariance structure */
119
NOTE: Convergence criteria met.
NOTE: PROCEDURE MIXED used (Total process time):
real time 0.32 seconds
cpu time 0.31 seconds
120 proc mixed cl;
121 title2 'Unknown covariance structure';
122 class age sex noise;
123 model discrim = interest age|sex|noise;
124 repeated / type=un subject=ident r;
125 lsmeans age / pdiff tdiff adjust = bon;
126 lsmeans noise / pdiff tdiff adjust = bon;
127 contrast 'Noise Linear' noise 1 -2 1 0 0,
128 noise 0 1 -2 1 0,
129 noise 0 0 1 -2 1;
130
131
132 /* Test for difference between covariance structures
133 using a full versus reduced model approach.
134 Difference between Likelihood Ratio chisquares is
135 chi-squared, with df = difference of degrees of freedom.
136 H0 is compound symmetry, alternative is unstructured.
137 Any model for the covariance matrix is reduced compared to
138 the unknown structure. */
139
NOTE: Convergence criteria met.
NOTE: PROCEDURE MIXED used (Total process time):
real time 0.21 seconds
cpu time 0.20 seconds
140 proc iml;
NOTE: IML Ready
141 title2 'Test for difference between covariance structures';
142 title3 'Compound symmetry versus unknown';
143 ChiSquared = 51.44-42.90;
143 ! df = 14-1;
144 pvalue = 1-probchi(ChiSquared,df);
145 print ChiSquared df pvalue;
146
147
148
149
150
151
152
153
154 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
166