RE: [R] unbalanced design
This is a standard "gotcha" in linear models. Gets me, too. Try ?C and ?contr.sum to help you understand. Also Venables's and Ripley's MASS 4 , section 6.2 gives a short not too technical summary; any linear models text will provide a more complete (and more technical) discussion. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA "The business of the statistician is to catalyze the scientific learning process." - George E. P. Box > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Damián Cirelli > Sent: Wednesday, December 01, 2004 2:03 PM > To: [EMAIL PROTECTED] > Subject: Re: [R] unbalanced design > > > Thanks Peter, > > I still wonder why it thinks it's unbalanced... > > __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] unbalanced design
Thanks Peter, I still wonder why it thinks it's unbalanced... The se's of the contrasts are different than the se's of the means, which is the point of se=T in model.tables (type "means") I would have thought. No big deal though, the following code makes a nice table with the se's of the means to use in further CI's be it t's or Bonferroni: kidney.mse <- kidney.anova[length(row.names(kidney.anova)),3] means=se=means.a=se.a=means.b=se.b=rep(0,6) kidney.means <- data.frame(means,se,means.a,se.a,means.b,se.b,a,b) for (i in 1:6){ kidney.means[i,1] = mean(kidney$dhosp.trans[kidney$a.b==i]) if (i < 4){ if (i < 3){ kidney.means[i,3] = mean(kidney$dhosp.trans[kidney$duration==i]) kidney.means[i,4] = kidney.mse/length(kidney$duration[kidney$duration==i]) } kidney.means[i,5] = mean(kidney$dhosp.trans[kidney$wgain==i]) kidney.means[i,6] = kidney.mse/length(kidney$wgain[kidney$wgain==i]) kidney.means[i,7] = 1 kidney.means[i,8] = i } if (i > 3){ kidney.means[i,7] = 2 kidney.means[i,8] = i-3 } kidney.means[i,2] = kidney.mse/length(kidney$dhosp.trans[kidney$a.b==i]) } > kidney.means means se means.ase.a means.bse.b a b 1 0.4434824 0.01012537 0.7867166 0.003375125 0.4208548 0.005062687 1 1 2 0.8099675 0.01012537 0.6151953 0.003375125 0.6954658 0.005062687 1 2 3 1.1066998 0.01012537 0.000 0.0 0.9865472 0.005062687 1 3 4 0.3982271 0.01012537 0.000 0.0 0.000 0.0 2 1 5 0.5809641 0.01012537 0.000 0.0 0.000 0.0 2 2 6 0.8663947 0.01012537 0.000 0.0 0.000 0.0 2 3 Thanks again Peter Alspach wrote: >Damián > >I asked a similar question a few months ago (3 August 2004): > > > >>temp.aov <- aov(S~rep+trt1*trt2*trt3, data=dummy.data) >>model.tables(temp.aov, type='mean', se=T) >> >>Returns the means, but states "Design is unbalanced - use se.contrasts >>for se's" which is a little surprising since the design is balanced. >> >> > >To which Prof Ripley replied: If you used the default treatment contrasts, it >is not. Try Helmert >contrasts with aov(). > >If I recall correctly, following Prof Ripley's suggestion led aov() to accept >the design was balanced, but model.tables() still did not (but that could have >been my error). However, se.contrast() worked. > >Cheers > >Peter Alspach > > > > > Damián Cirelli <[EMAIL PROTECTED]> 02/12/04 09:50:13 >>> >Hi all, >I'm new to R and have the following problem: >I have a 2 factor design (a has 2 levels, b has 3 levels). I have an >object kidney.aov which is an aov(y ~ a*b), and when I ask for >model.tables(kidney.avo, se=T) I get the following message along with >the table of effects: > >Design is unbalanced - use se.contrast() for se's > >but the design is NOT unbalanced... each fator level combination has the >same n > >I' d appreciate any help. >Thanks. > >__ >[EMAIL PROTECTED] mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > > >__ > >The contents of this e-mail are privileged and/or confidential to the >named recipient and are not to be used by any other person and/or >organisation. If you have received this e-mail in error, please notify >the sender and delete all material pertaining to this e-mail. >__ > > > [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] unbalanced design
Damián I asked a similar question a few months ago (3 August 2004): > temp.aov <- aov(S~rep+trt1*trt2*trt3, data=dummy.data) > model.tables(temp.aov, type='mean', se=T) > > Returns the means, but states "Design is unbalanced - use se.contrasts > for se's" which is a little surprising since the design is balanced. To which Prof Ripley replied: If you used the default treatment contrasts, it is not. Try Helmert contrasts with aov(). If I recall correctly, following Prof Ripley's suggestion led aov() to accept the design was balanced, but model.tables() still did not (but that could have been my error). However, se.contrast() worked. Cheers Peter Alspach >>> Damián Cirelli <[EMAIL PROTECTED]> 02/12/04 09:50:13 >>> Hi all, I'm new to R and have the following problem: I have a 2 factor design (a has 2 levels, b has 3 levels). I have an object kidney.aov which is an aov(y ~ a*b), and when I ask for model.tables(kidney.avo, se=T) I get the following message along with the table of effects: Design is unbalanced - use se.contrast() for se's but the design is NOT unbalanced... each fator level combination has the same n I' d appreciate any help. Thanks. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ The contents of this e-mail are privileged and/or confidenti...{{dropped}} __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] unbalanced design for anova with low number of replicates
Arne, For this sort of things, my suggestion is that you try to seek assistance from local statistician(s), and I'd be very surprised if there's none for you. Data arising from unbalanced designs need no special tools for model fitting. The garden variety linear models work just fine. The problem is what do you do with the model(s): The inference is where the problem is. Unbalanced design introduce (partial) confounding among factors, which makes assessment of effects tricky. It really depends on what your goal is. As long as you can formulate that in terms of parameters in the `fullest' model you are willing to consider, then it just comes down to testing specific (general) linear hypotheses, which can be done `by hand'. (I believe Greg also has a glh() or something like that in the gregmisc package. I'd guess Prof. Fox's `car' package also has something similar.) [BTW, if you are going to treat `batch' as a random effect, you might want to look into mixed effect models; i.e., lme() in either lme4 or nlme.] Best, Andy > From: [EMAIL PROTECTED] > > Hello, > > I'm wondering what's the best way to analyse an unbalanced > design with a low number of replicates. I'm not a > statistician, and I'm looking for some direction for this problem. > > I've a 2 factor design: > > Factor batch with 3 levels, and factor dose within each batch > with 5 levels. Dose level 1 in batch one is replicated 4 > times, level 3 is replicated only 2 times. all other levels > are replicated 3 times, except for batch level 3, for which > dose 4 is missing. > > I've realised that the other of the factors is critical for > the outcome of the anova (using lm and anova). > > I guess the impact wouldn't be strong if there was a > reasonably large numbe rof replicates within each cell (even > though not balanced). However, since I've only 0 to 4 > replicates I'm worried that the standard anova may not be the > way to go. > > Are there special packages for unbalanced designs like this? > > kind regards, > > Arne > > -- > Arne Muller, Ph.D. > Toxicogenomics, Aventis Pharma > arne dot muller domain=aventis com > > __ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html