Sequential phenomena and some R code [🇷 for BE/BA]
Dear yjlee,
R's defualt method of doing the anova in conjunction with the model is the tyype I approach, which means it fits the factors one-on-top-of-the-other.
so when you have a model like lm(Y~A+B+C ... etc) then R first notes the total variance in the raw data. This is the null residual. Then it fits a model with only A as factor, and notes the new residual. The difference between the null residual and the new residual is the ascribed to factor A. Then it fits a model with A and B as factors and notes the new residual. The difference between this and the previous is ascribed to factor B, and so forth. This is what type I SS is about. They are also called sequential, because the magnitude of the SS for a given factor may depend on the order of which it is mincluded in the model, so and anova on lm(Y~A+B+C) may not be the same as the anova on lm(Y~C+A+B).
Given the nature of type I SS you will see that when Seq is included after Subj there is no (addition to) the SS, because of the good old "Subjects nested in Sequence". Thus the neglect. Hence you can try and include Seq before Subj - and then suddenly you have a Seq SS using type I SS. Think about it, it actually makes sense.
The following elmaestrolophystic (probably bugged!) code illustrates it.
❝ Apparently, the list "sequence" of fixed variables can result in differences for type I SS. The seq was disappeared! Amazing thing, another finding in lm() of R.
R's defualt method of doing the anova in conjunction with the model is the tyype I approach, which means it fits the factors one-on-top-of-the-other.
so when you have a model like lm(Y~A+B+C ... etc) then R first notes the total variance in the raw data. This is the null residual. Then it fits a model with only A as factor, and notes the new residual. The difference between the null residual and the new residual is the ascribed to factor A. Then it fits a model with A and B as factors and notes the new residual. The difference between this and the previous is ascribed to factor B, and so forth. This is what type I SS is about. They are also called sequential, because the magnitude of the SS for a given factor may depend on the order of which it is mincluded in the model, so and anova on lm(Y~A+B+C) may not be the same as the anova on lm(Y~C+A+B).
❝ R automatically drops the variable (or factor) seq out of its included with this model in calculation type I SS, but not with the previous of (Cmax ~ seq + prd + drug + subj) or others. I'm playing with lm() right now with different list sequences of fixed variables to see what I can get. Interesting, uh?
Given the nature of type I SS you will see that when Seq is included after Subj there is no (addition to) the SS, because of the good old "Subjects nested in Sequence". Thus the neglect. Hence you can try and include Seq before Subj - and then suddenly you have a Seq SS using type I SS. Think about it, it actually makes sense.
The following elmaestrolophystic (probably bugged!) code illustrates it.
Subj=as.factor(c(1,2,3,4,5,6,7,1,2,3,4,5,6,7))
Seq=as.factor (c(1,1,1,1,2,2,2,1,1,1,1,2,2,2))
Per=as.factor (c(1,1,1,1,1,1,1,2,2,2,2,2,2,2))
Trt=as.factor (c(1,1,1,1,2,2,2,2,2,2,2,1,1,1))
lnAuc= c(10,11,12,8,7,8,9,10,11,12,9,10,12,10)
## a VERY small BE study!
Lm1=lm(lnAuc~Per+Trt+Subj+Seq)
Lm2=lm(lnAuc~Per+Trt+Seq+Subj)
anova(Lm1)
anova(Lm2)
## no Seq SS because Seq comes after Subj for Lm1
## all of a sudden there is a Seq SS for Lm2 - note the actual value!
## but we want type III SS because we worship the holy power!
## and since this is an unbalanced study type I is not same as type III SS
## therefore we try drop1
drop1(Lm1, test="F")
## ouch! The Seq SS is zero because when Seq is dropped Subj is already in
## so dropping Seq is the same as dropping nothing
## therefore zero SS for Seq
## panic panic!
## Solution: We make a drop of Seq from a model which does not include Subj
## from this we extract the Seq SS
T3A=drop1(Lm1, test="F")
T3A[5,2] = anova(lm(lnAuc~Per+Trt+Seq))$Sum[3]
## This is a smart way of doing it - it works because of the type I sequence!
T3A
## and there we go!
—
Pass or fail!
ElMaestro
Pass or fail!
ElMaestro
Complete thread:
- Imbalance + Type III SS = Tricky for the sequence evaluation ElMaestro 2009-09-07 21:16
- Imbalance + Type III SS = Tricky for the sequence evaluation yjlee168 2009-09-07 22:23
- Imbalance + Type III SS = Tricky for the sequence evaluation ElMaestro 2009-09-08 16:49
- Imbalance + Type III SS = Tricky for the sequence evaluation yjlee168 2009-09-08 20:02
- Sequential phenomena and some R codeElMaestro 2009-09-08 20:28
- Sequential phenomena and some R code yjlee168 2009-09-08 21:36
- Default in SAS ElMaestro 2009-09-08 21:43
- Sequential phenomena and some R code yjlee168 2009-09-08 21:36
- Sequential phenomena and some R codeElMaestro 2009-09-08 20:28
- Imbalance + Type III SS = Tricky for the sequence evaluation yjlee168 2009-09-08 20:02
- Imbalance + Type III SS = Tricky for the sequence evaluation ElMaestro 2009-09-08 16:49
- Imbalance + Type III SS = Tricky for the sequence evaluation yjlee168 2009-09-07 22:23