ElMaestro ★★★ Denmark, 2009-09-07 23:16 (5711 d 22:16 ago) Posting: # 4161 Views: 10,140 |
|
Dear all, Following some previous discussion... drop1 in R gives a SS of roughly zero (plus minus something smaller than the internal convergence criterion for lm) for the sequence effect.When we have sequence imbalance, type I etc will not save us when we want an output that resembles the type III output from SAS*. If we really want to get a meaningful evaluation of the sequence effect and still use type III SS then we need to play around a little bit. The following is an elmaestrolophystic attempt at getting it right. drop1 for Sequence makes little sense in itself because of the Subject factor. A meaningful type III SS for Sequence therefore is evaluated by comparing the residual from a model with Per and Trt with the residual from a model with Per and Trt and Seq. So here's my ugly proposal: Lm1=lm(lnAuc~Per+Trt+Subj+Seq) ## standard model, right?T3A=drop1(Lm1, test="F") ## this is our type III anova which gives a dumb Seq SST3A[5,2] = anova(lm(lnAuc~Per+Trt))$Sum[3] - anova(lm(lnAuc~Per+Trt+Seq))$Sum[4]
## manually corrects the Seq SS accordingly to the text aboveThe rest is then plain sailing with conversion of the newly acquired Seq SS to the mean square, followed by evaluation against the between-Subj error. Best regards EM. *: This is just a reflection over the fact that some people want to be able to reproduce the SAS type III output. I am not claiming type III SS are superior; that aspect is better dealt with by others. |
yjlee168 ★★★ ![]() ![]() Kaohsiung, Taiwan, 2009-09-08 00:23 (5711 d 21:09 ago) @ ElMaestro Posting: # 4162 Views: 8,447 |
|
Dear Elmaestro, I've tested your codes and got the following. Dependent Variable: Cmax Find anything different from previous thread. Something can be wrong there... this is just a quick response. ❝ So here's my ugly proposal: ❝ ❝ ❝ Seq SS ❝ ❝ ❝ ## manually corrects the Seq SS accordingly to the text above I translated your codes as follows. cat(" Dependent Variable: Cmax \\n") Am I doing anything stupid here? Thanks. — All the best, -- Yung-jin Lee bear v2.9.2:- created by Hsin-ya Lee & Yung-jin Lee Kaohsiung, Taiwan https://www.pkpd168.com/bear Download link (updated) -> here |
ElMaestro ★★★ Denmark, 2009-09-08 18:49 (5711 d 02:44 ago) @ yjlee168 Posting: # 4170 Views: 8,356 |
|
Dear yjlee, ❝ Am I doing anything stupid here? Thanks. I am sure you are not. But I lost it slightly here, could you explain me what your concern is? Thanks and best regards, EM. |
yjlee168 ★★★ ![]() ![]() Kaohsiung, Taiwan, 2009-09-08 22:02 (5710 d 23:30 ago) @ ElMaestro Posting: # 4171 Views: 8,429 |
|
Dear Elmaestro, Firstly, if you look at this previous post and compare with what I got here (part of type I SS), you will find out that R does different calculations with the model of (Cmax ~ seq + prd + drug + subj) and the one (Cmax ~ prd + drug + subj + seq) for type I SS. 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. Secondly, due to the different type I SS calculation, the anova() function had different "sequence" list of these fixed variables. That's why I took a lot of time to locate "subj(seq)". That's weird. I checked with R on-line help (chm), and it said that "quoted...The models fit by, e.g., the lm and glm functions are specified in a compact symbolic form. The ~ operator is basic in the formation of such models. An expression of the form y ~ model is interpreted as a specification that the response y is modelled by a linear predictor specified symbolically by model. Such a model consists of a series of terms separated by + operators. The terms themselves consist of variable and factor names separated by : operators. Such a term is interpreted as the interaction of all the variables and factors appearing in the term..." in "formula". And also "quote...Models for lm are specified symbolically. A typical model has the form response ~ terms where response is the (numeric) response vector and terms is a series of terms which specifies a linear predictor for response. A terms specification of the form first + second indicates all the terms in first together with all the terms in second with duplicates removed. A specification of the form first:second indicates the set of terms obtained by taking the interactions of all terms in first with all terms in second..." in the section of Details of lm(stats). In the model that you proposed, it was written as (Cmax ~ prd + drug + subj + seq). 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? ❝ I am sure you are not. But I lost it slightly here, could you explain me ❝ what your concern is? — All the best, -- Yung-jin Lee bear v2.9.2:- created by Hsin-ya Lee & Yung-jin Lee Kaohsiung, Taiwan https://www.pkpd168.com/bear Download link (updated) -> here |
ElMaestro ★★★ Denmark, 2009-09-08 22:28 (5710 d 23:04 ago) @ yjlee168 Posting: # 4172 Views: 8,452 |
|
Dear yjlee, ❝ 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)) — Pass or fail! ElMaestro |
yjlee168 ★★★ ![]() ![]() Kaohsiung, Taiwan, 2009-09-08 23:36 (5710 d 21:56 ago) @ ElMaestro Posting: # 4173 Views: 8,476 |
|
Dear Elmaestro, ❝ [...] ❝ 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. O.k., does this sequential phenomenon occur with SAS for type I SS calculation? The suggested SAS codes for 2x2x2 crossover is PROC GLM DATA = KK; Looks like that we need to put seq before subj... ❝ The following elmaestrolophystic (probably bugged!) code illustrates it. The codes works great and are quite illustrating. many thanks. ![]() — All the best, -- Yung-jin Lee bear v2.9.2:- created by Hsin-ya Lee & Yung-jin Lee Kaohsiung, Taiwan https://www.pkpd168.com/bear Download link (updated) -> here |
ElMaestro ★★★ Denmark, 2009-09-08 23:43 (5710 d 21:49 ago) @ yjlee168 Posting: # 4174 Views: 8,372 |
|
Dear yjlee, ❝ O.k., does this sequential phenomenon occur with SAS for type I SS calculation? The suggested SAS codes for 2x2x2 crossover is ❝ Looks like that we need to put seq before subj... Yes to the first question. Type I is defined that way, so you will see the same phenomenon with SAS type I (unless SAS is does something clever as it does for the single term deletion stuff; this I don't know about as I do not use SAS). The SAS default I think includes type I and type III in the output. You can put Seq before Subj in type I analyses if you prefer. As explained previously that will ensure you get 'something' for the Seq SS. — Pass or fail! ElMaestro |