Example #1 – Word Document

advertisement
PRE 905: Spring 2014 – Lecture 9, Example 1 -- Page 1
Examples of Adding Predictors to Multivariate Models
Uses of the gls() Function with the Factor() Function
Comparisons of Multivariate Models with Classical MANOVA
The data for this example come from http://www.ats.ucla.edu/stat/sas/library/repeated_ut.htm
R Syntax for Data Manipulation – Converting from Wide Format to Long/Stacked Format:
Resulting R Data Set (personID = 1 and personID =18 shown)
๐‘ฆ๐‘1
112
R’s gls() function is modeling ๐’š๐‘ = [๐‘ฆ๐‘2 ], where ๐’š is the pulse rate. For personID = 1 this would be: ๐’š1 = [166]
๐‘ฆ๐‘3
215
Empty multivariate model predicting the mean pulse rate for each intensity level:
Multivariate model becomes (simultaneously): ๐’š๐‘ = ๐— ๐‘ ๐œท + ๐’†๐‘
๐‘ฆ๐‘1
๐‘’๐‘1
๐›ฝ0
1 0 0
๐‘ฆ
๐’š๐‘ = [ ๐‘2 ] ; ๐— ๐‘ = [1 1 0] ; ๐œท = [๐›ฝ๐ผ2 ] ; ๐’†๐‘ = [๐‘’๐‘2 ]
๐‘ฆ๐‘3
๐‘’๐‘3
๐›ฝ๐ผ3
1 0 1
2
๐œŽ๐‘’1
Where ๐’†๐‘ ∼ ๐‘3 (๐ŸŽ, ๐‘), and ๐‘ = [๐œŽ๐‘’1 ,๐‘’2
๐œŽ๐‘’1 ,๐‘’3
๐œŽ๐‘’1 ,๐‘’2
2
๐œŽ๐‘’2
๐œŽ๐‘’2 ,๐‘’3
๐œŽ๐‘’1 ,๐‘’3
๐œŽ๐‘’2 ,๐‘’3 ] (the unstructured error covariance matrix model).
2
๐œŽ๐‘’3
PRE 905: Spring 2014 – Lecture 9, Example 1 -- Page 2
Which leads to:
๐‘ฆ๐‘1 = ๐›ฝ0 + ๐‘’๐‘1
๐‘ฆ๐‘2 = ๐›ฝ0 + ๐›ฝ๐ผ2 + ๐‘’๐‘2
๐‘ฆ๐‘3 = ๐›ฝ0 + ๐›ฝ๐ผ3 + ๐‘’๐‘3
Interpret each effect…
Intercept:
observationF2:
observationF3:
PRE 905: Spring 2014 – Lecture 9, Example 1 -- Page 3
R Matrix Estimate
Adding a Predictor to a Multivariate Model
We will add diet (vegetarian or meat eater) as a predictor to the empty model:
Multivariate model becomes : ๐’š๐‘ = ๐— ๐‘ ๐œท + ๐’†๐‘
For meat eaters:
๐‘ฆ๐‘1
1 0 0
๐’š๐‘ = [๐‘ฆ๐‘2 ] ; ๐— ๐‘ = [1 1 0
๐‘ฆ๐‘3
1 0 1
0 0
0 0
0 0
๐›ฝ0
๐›ฝ๐ผ2
๐‘’๐‘1
0
๐›ฝ๐ผ3
; ๐’†๐‘ = [๐‘’๐‘2 ]
0] ; ๐œท =
๐›ฝ๐‘‰
๐‘’๐‘3
0
๐›ฝ๐‘‰∗๐ผ2
[๐›ฝ๐‘‰∗๐ผ3 ]
1 0
1 1
1 0
๐›ฝ0
๐›ฝ๐ผ2
๐‘’๐‘1
0
๐›ฝ๐ผ3
; ๐’†๐‘ = [๐‘’๐‘2 ]
0] ; ๐œท =
๐›ฝ๐‘‰
๐‘’๐‘3
1
๐›ฝ๐‘‰∗๐ผ2
[๐›ฝ๐‘‰∗๐ผ3 ]
For vegetarians:
๐‘ฆ๐‘1
1 0 0
๐’š๐‘ = [๐‘ฆ๐‘2 ] ; ๐— ๐‘ = [1 1 0
๐‘ฆ๐‘3
1 0 1
2
๐œŽ๐‘’1
Where ๐’†๐‘ ∼ ๐‘3 (๐ŸŽ, ๐‘), and ๐‘ = [๐œŽ๐‘’1 ,๐‘’2
๐œŽ๐‘’1 ,๐‘’3
๐œŽ๐‘’1 ,๐‘’2
2
๐œŽ๐‘’2
๐œŽ๐‘’2 ,๐‘’3
๐œŽ๐‘’1 ,๐‘’3
๐œŽ๐‘’2 ,๐‘’3 ] (the unstructured error covariance matrix model).
2
๐œŽ๐‘’3
Which leads to the following simultaneous linear models:
For meat eaters:
๐‘ฆ๐‘1 = ๐›ฝ0 + ๐‘’๐‘1
๐‘ฆ๐‘2 = ๐›ฝ0 + ๐›ฝ๐ผ2 + ๐‘’๐‘2
๐‘ฆ๐‘3 = ๐›ฝ0 + ๐›ฝ๐ผ3 + ๐‘’๐‘3
For vegetarians:
๐‘ฆ๐‘1 = ๐›ฝ0 + ๐›ฝ๐‘‰ + ๐‘’๐‘1
๐‘ฆ๐‘2 = ๐›ฝ0 + ๐›ฝ๐ผ2 + ๐›ฝ๐‘‰ + ๐›ฝ๐‘‰∗๐ผ2 + ๐‘’๐‘2
๐‘ฆ๐‘3 = ๐›ฝ0 + ๐›ฝ๐ผ3 + ๐›ฝ๐‘‰ + ๐›ฝ๐‘‰∗๐ผ3 + ๐‘’๐‘3
PRE 905: Spring 2014 – Lecture 9, Example 1 -- Page 4
The ๐‘ error covariance matrix has changed by adding the predictor – this is analogous to what happens in a univariate general
linear model – the predictor shrinks the error variance:
For intensity #1 (pulse after warm up):
2
2
Empty model ๐œŽ๐‘’1
= 279.9; After adding DIET as a predictor: ๐œŽ๐‘’1
= 188.6
2
Therefore ๐‘…๐ผ1
=
279.9−188.6
279.9
= 0.326
For intensity #2 (pulse after jogging):
2
2
Empty model ๐œŽ๐‘’2
= 473.1; After adding DIET as a predictor: ๐œŽ๐‘’2
= 328.4
2
Therefore ๐‘…๐ผ2
=
473.1−328.4
473.1
= 0.306
For intensity #3 (pulse after running):
2
2
Empty model ๐œŽ๐‘’3
= 770.0; After adding DIET as a predictor: ๐œŽ๐‘’3
= 530.1
2
Therefore ๐‘…๐ผ3
=
770.0−530.1
770.0
= 0.312
These ๐‘… 2 reflect the proportion of variance accounted for marginally for each variable. What about the covariances? Notice,
adding a predictor reduces those, too. What is needed is a joint description of how the combined variation of all three variables is
reduced by the predictor. To get that, we can use the generalized sample variance (the determinant of ๐‘)
For all three variables jointly:
Empty model generalized variance: |๐‘| =1,675,026; After adding DIET as a predictor: |๐‘| = 1,224,462
Therefore the overall ๐‘… 2 is: ๐‘… 2 =
1,675,026−1,224,462
1,675,026
= .269
This value is less than each of the marginal ๐‘… 2 values because of the contributions of the covariances.
PRE 905: Spring 2014 – Lecture 9, Example 1 -- Page 5
Because we are using the Residual Maximum Likelihood as our estimator, we can use a multivariate Wald test to determine if
DIET significantly improved model fit. This is essentially testing whether the multivariate ๐‘… 2 change is zero. More formally, we
are testing the hypothesis:
๐ป0 : ๐›ฝ๐‘‰ = ๐›ฝ๐‘‰∗๐ผ1 = ๐›ฝ๐‘‰∗๐ผ3 = 0
๐ป๐ด : At least one not equal to zero
We can conclude that DIET significantly improved the fit of the multivariate model – but, what that does not tell us is if it
improved the fit for each dependent variable marginally.
Interpret each effect…
Intercept:
observationF2:
observationF3:
dietF2:
observationF2:dietF2:
observationF3:dietF2:
PRE 905: Spring 2014 – Lecture 9, Example 1 -- Page 6
What we cannot find from our direct model output are some key hypothesis tests that show up for this type of analysis:
๏‚ท
๏‚ท
๏‚ท
Within subjects main effect of intensity (do mean pulse rates differ when pulse is taken after different intensities?)
o Should be 2 degrees of freedom (3 intensity levels - 1)
Between subjects main effect of diet type (do mean pulse rates differ for vegetarians and meat eaters?)
o Should be 1 degree of freedom (2 diet types - 1)
Interaction of within subjects intensity and between subjects diet type (are there differences in pulse rate for varying
combinations of intensity and diet?)
o Should be 2 degrees of freedom (3 intensity levels - 1)* (2 diet types - 1)
PRE 905: Spring 2014 – Lecture 9, Example 1 -- Page 7
Comparison of PROC MIXED Multivariate Analyses with Classical Multivariate Analysis of Variance (MANOVA)
A semi-frequent request when running multivariate analyses is for some type of “MANOVA” tests. Usually, this is due to the
person requesting the classical tests having been trained in a customary multivariate analysis course. This section of the handout
describes MANOVA and how what we have just done can provide a MANOVA-style test if you ever are asked for one.
We will begin our discussion of MANOVA by starting with the univariate ANOVA (a one-way ANOVA with one categorical
IV). In univariate ANOVA, we develop the hypothesis test of group differences in the group mean of the outcome using the
concept of sums of squares.
๐ป0 : ๐œ‡1 = ๐œ‡2 = โ‹ฏ = ๐œ‡๐บ
๐ป๐ด : at least one ๐œ‡ not equal to the others
Sums of squares between groups comes from the sum of squared differences from each group mean ๐‘ฆฬ…๐‘” from the overall grand
mean ๐‘ฆฬ… (where ๐‘๐‘” is the within-group sample size for group ๐‘”):
๐บ
2
๐‘†๐‘†๐ต = ∑ ๐‘๐‘” (๐‘ฆฬ…๐‘” − ๐‘ฆฬ…)
๐‘”=1
The sums of squares within groups (here referred to as the sums of squares for error) comes from the squared difference of each
person’s outcome and their group’s mean:
๐บ
๐‘๐‘”
2
๐‘†๐‘†๐ธ = ∑ ∑ (๐‘ฆ๐‘ − ๐‘ฆฬ…๐‘” )
๐‘”=1 ๐‘›๐‘” =1
The F-test is the ratio of these two terms, each divided by their respective degrees of freedom:
๐น=
๐‘†๐‘†๐ต /๐‘‘๐‘“๐ต
๐‘†๐‘†๐ธ /๐‘‘๐‘“๐ธ
A MANOVA extends a univariate ANOVA to test hypotheses about mean vectors across categorical independent variables. The
hypothesis test is now:
๐ป0 : ๐1 = ๐2 = โ‹ฏ = ๐๐บ
๐ป๐ด : at least one ๐ not equal to the others
๐œ‡๐‘”1
๐œ‡๐‘”2
Where ๐๐‘” = [ โ‹ฎ ], for ๐‘‰observed outcome variables (i.e., a multivariate analysis). The same concepts of univariate ANOVA still
๐œ‡๐‘”๐‘‰
apply, just with vectors and matrices instead of individual means. The matrix analog to the sums of squares between groups is the
Between Groups Sums of Squares and Cross Products matrix (using SAS’ notation ๐‡, which stands for Hypothesis) is formed
ฬ…๐‘” (size ๐‘‰ ๐‘ฅ 1) and the overall grand mean vector ๐’š
ฬ… (also size ๐‘‰ ๐‘ฅ 1)
using each group’s mean vector ๐’š
๐บ
๐‘‡
ฬ…๐‘” − ๐’š
ฬ…)(๐’š
ฬ…๐‘” − ๐’š
ฬ…)
๐‡(๐‘‰ ๐‘ฅ ๐‘‰) = ∑ ๐‘๐‘” (๐’š
๐‘”=1
PRE 905: Spring 2014 – Lecture 9, Example 1 -- Page 8
The matrix analog to the sums of squares within groups (here referred to as the sums of squares for error) is the Error Sums of
Squares and Cross Products Matrix which comes from comparing each person’s vector of outcomes ๐’š๐‘ with their group mean
ฬ…๐‘” :
vector ๐’š
๐บ
๐‘๐‘”
๐‘‡
ฬ…)(๐’š๐‘ − ๐’š
ฬ…)
๐„(๐‘‰ ๐‘ฅ ๐‘‰) = ∑ ∑ (๐’š๐‘ − ๐’š
๐‘”=1 ๐‘›๐‘” =1
๐‘ฌ
Note: for our multivariate models using maximum likelihood and an unstructured ๐‘ matrix, ๐‘ = ๐‘
Now, instead of forming an F-ratio, we can form a matrix that incorporates this ratio:
๐… = ๐„−1 ๐‡
Where MANOVA differs from univariate ANOVA is that there is no one best test statistic for summarizing ๐…. Instead, four
popular statistics are formed:
det(๐„)
det(๐‡+๐„)
๏‚ท
Wilk’s Lambda =
๏‚ท
๏‚ท
๏‚ท
Pillai’s trace = ๐‘ก๐‘Ÿ๐‘Ž๐‘๐‘’(๐‡(๐‡ + ๐„)−1 )
Hotelling-Lawley trace = ๐‘ก๐‘Ÿ๐‘Ž๐‘๐‘’(๐„−1 ๐‡)
Roy’s greatest (largest) root = largest eigenvalue of ๐„−1 ๐‡
(we will show how to get this using a modification of a likelihood ratio test)
What we seek to say is this: even though these statistics don’t directly come out of PROC MIXED, you can still obtain (at least
one of) them. Therefore, the analysis we have done subsumes classical MANOVA (or Multivariate Regression) into a more
general framework for investigating multivariate hypotheses. We will now compare a MANOVA with PROC GLM and show
how we can achieve the same result from PROC MIXED.
The four MANOVA test statistics are shown in the output below.
We can obtain Wilks Lambda from a model comparison of our previous two multivariate models in PROC MIXED:
Empty Model −2๐ฟ๐ฟ๐ธ๐‘€๐‘ƒ๐‘‡๐‘Œ = −198.5 ∗ −2 = 397.0
DIET Model −2๐ฟ๐ฟ๐ท๐ผ๐ธ๐‘‡ = −186.8 ∗ −2 = 373.6
Wilks Lambda =
Λ = exp (
−(−2๐ฟ๐ฟ๐ธ๐‘€๐‘ƒ๐‘‡๐‘Œ − −2๐ฟ๐ฟ๐ท๐ผ๐ธ๐‘‡ )
−(397.0 − 373.6)
) = exp (
) = 0.273
๐‘
18
Download