1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;5556 /******************** 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 ******************************************************************/6162 title 'Noise data';6364 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.65NOTE: PROCEDURE FORMAT used (Total process time):real time 0.00 secondscpu time 0.00 seconds66 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';72NOTE: 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)=8700NOTE: 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 secondscpu time 0.00 seconds73 proc freq;74 tables sex*age*noise / norow nocol nopercent;75NOTE: There were 300 observations read from the data set WORK.LOUD.NOTE: PROCEDURE FREQ used (Total process time):real time 0.07 secondscpu time 0.08 seconds76 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;8283 /* Expected mean squares show that not all the hypotheses84 are testable with the classical mixed model approach.85 SAS is buying testability of the hypotheses by assuming86 that you're only interested in an effect if all the87 higher-order interactions involving that effect are88 absent.8990 Also, we can't use the covariate and it's not clear how91 to do multiple comparisons. */92NOTE: 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 secondscpu time 0.36 seconds93 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;99100101NOTE: Convergence criteria met.NOTE: PROCEDURE MIXED used (Total process time):real time 0.10 secondscpu time 0.09 seconds102 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 0115 mu2-mu3 = mu3-mu4 => 0 1 -2 1 0116 mu3-mu4 = mu4-mu5 => 0 0 1 -2 1 */117118 /* Compare results with unknown covariance structure */119NOTE: Convergence criteria met.NOTE: PROCEDURE MIXED used (Total process time):real time 0.32 secondscpu time 0.31 seconds120 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;130131132 /* Test for difference between covariance structures133 using a full versus reduced model approach.134 Difference between Likelihood Ratio chisquares is135 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 to138 the unknown structure. */139NOTE: Convergence criteria met.NOTE: PROCEDURE MIXED used (Total process time):real time 0.21 secondscpu time 0.20 seconds140 proc iml;NOTE: IML Ready141 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;146147148149150151152153154 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;166