Introduction of Repeated Measures ANOVA Jia Chen
What is it ? Definition: - It is a technique used to test the equality of means.
When To Use It? It is used when all members of a random sample are measured under a number of different conditions. As the sample is exposed to each condition in turn, the measurement of dependent variable is repeated.
Introduction of One-Way Repeated Measures ANOVA Che-Wei, Lu Professor:Wei Zhu
One-Way Repeated Measures ANOVA Definition A one-way repeated measures ANOVA instead of having one score per subject, experiments are frequently conducted in which multiple score are gathered for each case. Concept of Repeated Measures ANOVA One factor with at least two levels, levels are dependent. Dependent means that they share variability in some way. The Repeated Measures ANOVA is extended from standard ANOVA.
One-Way Repeated Measures ANOVA When to Use Measuring performance on the same variable over time – for example looking at changes in performance during training or before and after a specific treatment The same subject is measured multiple times under different conditions – for example performance when taking Drug A and performance when taking Drug B The same subjects provide measures/ratings on different characteristics – for example the desirability of red cars, green cars and blue cars Note how we could do some RM as regular between subjects designs – For example, Randomly assign to drug A or B
One-Way Repeated Measures ANOVA Source of Variance in Repeated Measures ANOVA SStotal – Deviation of each individual score from the grand mean SSb/t subjects – Deviation of subjects' individual means (across treatments) from the grand mean. – In the RM setting, this is largely uninteresting, as we can pretty much assume that ‘subjects differ’ SSw/in subjects: How Ss vary about their own mean, breaks down into: – SStreatment As in between subjects ANOVA, is the comparison of treatment means to each other (by examining their deviations from the grand mean) However this is now a partition of the within subjects variation – SSerror Variability of individuals’ scores about their treatment mean
One-Way Repeated Measures ANOVA Partition of Sum of Square Repeated Measures ANOVAStandard ANOVA
One-Way Repeated Measures ANOVA Analysis of Variance(ANOVA Table) SSDfMSF Between Within Subjects Error Total
One-Way Repeated Measures ANOVA SSDfMSF Between Within Subjects Error Total
One-Way Repeated Measures ANOVA SAS Code DATA REPEAT; INPUT SUBJ BEFORE WEEK1 WEEK2; DATALINES; ; PROC ANOVA DATA=REPEAT; TITLE "One-Way ANOVA using the repeated Statment"; MODEL BEFORE WEEK1 WEEK2= / NOUNI; REPEATED TIME 3 (1 2 3); RUN; The Before, Week1, and Week2 are the time level at each participants. In here, we don’t have CLASS statement because our data set does not have an independent variable The NOUNI(no univariate) is a request not to conduct a separate analysis for each of the three times variables. This indicates the labels we want to printed for each level of times
One-Way Repeated Measures ANOVA SAS Result
Stating of the Hypothesis Within-Subjects Main EffectBetween-Subjects Main EffectBetween-Subjects Interaction Effect Within-Subjects By Between-Subjects Interaction Effects
Two-Factor ANOVA with Repeated Measures on One Factor
ANOVA TABLE SourceDFSSMSF Factor A a-1SSASSA/(a-1) MSA/MSWA ～ F (a-1),n(a-1) Factor B b-1SSBSSB/(b-1) MSB/MSE ～ F (b-1),n(a-1)(b-1) AB Interaction (a-1)(b-1)SSABSSAB/(a-1)(b-1) MSAB/MSE ～ F (a-1)(b-1,n(a-1)(b-1) Subjects within A (n-1)aSSW A SSWA/(n-1)a Error (n-1)a(b-1)SSESSE/((n-1)a(b-1) Total nab-1SST
Example The shape variable is the repeated variable. This produces an ANOVA with one between-subjects factor. If you were to examine the expected mean squares for this setup, you would find that the appropriate error term for the test of calib is subject|calib. The appropriate error term for shape and shape#calib is shape#subject|calib (which is the residual error since we do not include the term in the model).
SAS Code Data Q1; set pre.Q1; run; proc anova data=Q1; title' Two-way Anova with a Repeated Measure on One Factor'; class calib; model shape_1 shape_2 shape_3 shape_4 = calib/nouni; repeated shape 4; means calib; run;
MANOVA Test Criteria and Exact F Statistics for the Hypothesis of no shape Effect H = Anova SSCP Matrix for shape E = Error SSCP Matrix S=1 M=0.5 N=0 StatisticValueF ValueNum DFDen DFPr > F Wilks' Lambda Pillai's Trace Hotelling-Lawley Trace Roy's Greatest Root MANOVA Test Criteria and Exact F Statistics for the Hypothesis of no shape*calib Effect H = Anova SSCP Matrix for shape*calib E = Error SSCP Matrix S=1 M=0.5 N=0 StatisticValueF ValueNum DFDen DFPr > F Wilks' Lambda Pillai's Trace Hotelling-Lawley Trace Roy's Greatest Root At α=0.05,we reject the hypothesis and conclude that there is shape Effect At α=0.05,we cannot reject the hypothesis and conclude that there is no shape*calib Effect Analysis of SAS Output
SourceDFAnova SSMean SquareF ValuePr > F calib Error SourceDFAnova SSMean SquareF ValuePr > F Adj Pr > F G - GH - F shape shape*calib Error(shape) Univariate Tests of Hypotheses for Within Subject Effects Tests of Hypotheses for Between Subjects Effects
Two-Factor ANOVA with Repeated Measures on both Factors
SourceDFSSMSF Subjectsn-1SSSSSS/I-1MSS/MSE Factor A a-1SSASSA/(a-1) MSA/MSA*S ～ F(a-1),(n-1)(a-1) Factor B b-1SSBSSB/(b-1) MSB/MSB*S ～ F(b-1),(n-1)(b-1) AB Interaction (a-1)(b-1)SSABSSAB/((a-1)(b- 1)) MSAB/MSE ～ F(a-1)(b-1),(n-1)(a- 1)(b-1) A*Subjects (n-1)(a-1)SSA*SSSWA/((n-1)a)SSA*S/MSE F(a-1)(n-1),(n-1)(a-1)(b-1) B*Subjects (n-1)(b-1)SSB*SSSWB/((n-1)b)SSA*S/MSE F(n-1)(b-1),(n-1)(a-1)(b-1) Error(n-a)(a-1)(b-1)SSESSE/((n-1)(a- 1)(b-1)) Total nab-1SST ANOVA TABLE
Example Three subjects, each with nine accuracy scores on all combinations of the three different dials and three different periods. With subject a random factor and both dial and period fixed factors, the appropriate error term for the test of dial is the dial#subject interaction. Likewise, period#subject is the correct error term for period, and period#dial#subject (which we will drop so that it becomes residual error) is the appropriate error term for period#dial.
SAS Code Data Q2; Input Mins1-Mins9; Datalines; ; ODS RTF STYLE=BarrettsBlue; Proc anova data=Q2; Model Mins1-Mins9=/nouni; Repeated period 3, dail 3/nom; Run; ods rtf close;
SAS Output SourceDFAnova SSMean SquareF ValuePr > F Adj Pr > F G - GH - F period Error(period) Greenhouse-Geisser Epsilon Huynh-Feldt Epsilon SourceDFAnova SSMean SquareF ValuePr > F Adj Pr > F G - GH - F dail Error(dail) Greenhouse-Geisser Epsilon Huynh-Feldt Epsilon SourceDFAnova SSMean SquareF ValuePr > F Adj Pr > F G - GH - F period*dail Error(period*dail) Greenhouse-Geisser Epsilon Huynh-Feldt Epsilon Univariate Tests of Hypotheses for Within Subject Effects At α=0.05,we cannot reject the hypothesis and conclude the there is no period*dail Effect At α=0.05,we reject the hypothesis and conclude that there is dail Effect At α=0.05,we reject the hypothesis and conclude that there is period Effect
Three-factor Experiments with a repeated measure T. Sakamoto
35/87 Example of a marketing experiment Experiment The subjects who belong to a region X or Y see the Liquid Crystal Display A, B, or C. Each type of LCD is seen twice; once in the light and the other in the dark. The preferences of the LCD are measured by the subjects, on a scale from 1 to 5 (1= lowest, 5=highest). Case of this example A company which produces some Liquid Crystal Display wants to examine the characteristics of its prototype products.
36/87 Experimental Design and Data Three factors Type of LCD Regions to which the specimens belong In the light / In the dark Repeted measure factor : In the light / In the dark Type of LCD ABC subjlightdarksubjlightdarksubj lightdark REGION X Y
37/87 data lcd; input subj type $ region $ light dark datalines; 1 a a a a a a a a a a b b b b b b b b b b c c c c c c c c c c 4 3 ; run; proc anova data=lcd; title ’Three-way ANOVA with a Repeated Measure'; class type region; model light dark = type | region /nouni; repeated light_dark; means type | region; run; SAS PROGRAM
40/81 OUTPUT(Part 3/4):
Mixed Effect Models How-Chang Liu
Mixed Models When we have a model that contains random effect as well as fixed effect, then we are dealing with a mixed model. From the above definition, we see that mixed models must contain at least two factors. One having fixed effect and one having random effect.
Why use mixed models? When repeated measurements are made on the same statistical units, it would not be realistic to assume that these measurements are independent. We can take this dependence into account by specifying covariance structures using a mixed model
What if G and R are unknown?
Example Below is a table of growth measurements for 11 girls and 16 boys at ages 8, 10, 12, 14: Person gender age8 age10 age12 age14 1 F F F F F F F F F F F M M M Person gender age8 age10 age12 age14 15 M M M M M M M M M M M M M
Using SAS data pr; input Person Gender $ y1 y2 y3 y4; y=y1; Age=8; output; y=y2; Age=10; output; y=y3; Age=12; output; y=y4; Age=14; output; drop y1-y4; datalines; 1 F F … ; Run;
Using SAS proc mixed data=pr method=ml covtest; class Person Gender; model y = Gender Age Gender*Age / s; repeated / type=un subject=Person r; run;
Results Model Information Data SetWORK.PR Dependent Variabley Covariance StructureUnstructured Subject EffectPerson Estimation MethodML Residual Variance MethodNone Fixed Effects SE MethodModel-Based Degrees of Freedom MethodBetween-Within Class Level Information ClassLevelsValues Person Gender2F M As one can see, the covariance matrix is unstructured, as we are going to estimate it using the maximum likelihood method
Dimensions Covariance Parameters10 Columns in X6 Columns in Z0 Subjects27 Max Obs Per Subject4 Number of Observations Number of Observations Read108 Number of Observations Used108 Number of Observations Not Used0 Iteration History IterationEvaluations-2 Log LikeCriterion Convergence criteria met. As one can see, we do not have a Z matrix for this model the convergence of the Newton-Raphson algorithm means that we have found the maximum likelihood estimates
Solution for Fixed Effects EffectGenderEstimateStandard ErrorDFt ValuePr > |t| Intercept <.0001 GenderF GenderM0.... Age <.0001 Age*GenderF Age*GenderM0.... From this table, we see that the boys intercept is at , whole the girls intercept is at = The estimate of the boys’ slope is at 0.827, while the girls’ slpe is at =0.477 So the girls’ starting point is higher than the girls but their growth rate is only about half of that of the boys
Type 3 Tests of Fixed Effects EffectNum DFDen DFF ValuePr > F Gender Age <.0001 Age*Gender This is probably the most important table from our results: The gender row tests the null hypothesis that girls and boys have a common intercept. As we can see we cannot reject that hypothesis The Age tests the null hypothesis that age does not affect the growth rate. As we can see, we reject the null hypothesis as the F-value is large. The Age*gender tests reveals that there is a difference in slope at the 1% significance level.
Repeated Measures ANOVA vs. Independent Measures ANOVA Magarate Brown
Can we just use standard ANOVA with repeated measures data? No, Independent Measures (standard) ANOVA assumes the data are independent. Data from a repeated measures experiment not independent
How are standard ANOVA and repeated measures ANOVA the same? Independent measures ANOVA: an extension of the pooled variance t-test Repeated Measures ANOVA: an extension of the paired sample t-test
How are standard ANOVA and repeated measures ANOVA the same? Independent measures ANOVA: assumes the population variances are equal (homogeneity of variance) Repeated Measures ANOVA: sphericity assumption that the population variances of all the differences are equal
How are standard ANOVA and repeated measures ANOVA the same? Both assume Normality of the population
Advantages to using Repeated Measures instead of Independent Measures Limited number of subjects available Prefer to limit the number of subjects Less variability (finger tapping with caffeine example) Can examine effects over time
Drawbacks Practice effect Example: subjects get better at performing a task each time with “practice” Differential transfer: “This occurs when the effects of one condition persist and affect participants’ experiences during subsequent conditions.” (format: Example: medical treatments
Resources (to be formatted) 8r7_spring_2007/SolvingProblemsInSPSS/Solv ing%20Repeated%20Measures%20ANOVA%2 0Problems.pdf 8r7_spring_2007/SolvingProblemsInSPSS/Solv ing%20Repeated%20Measures%20ANOVA%2 0Problems.pdf res res y/shaugh/ch07_summary.html y/shaugh/ch07_summary.html