From Torsten.Hothorn at rzmail.uni-erlangen.de  Fri Apr  1 11:28:45 2005
From: Torsten.Hothorn at rzmail.uni-erlangen.de (Torsten Hothorn)
Date: Fri Apr  1 11:30:44 2005
Subject: [Rd] Re: simtest with lm object: depends on order in formula
In-Reply-To: <16973.4348.501231.667259@stat.math.ethz.ch>
References: <16973.4348.501231.667259@stat.math.ethz.ch>
Message-ID: <Pine.LNX.4.51.0504011128200.26417@artemis.imbe.med.uni-erlangen.de>

On Fri, 1 Apr 2005, Christoph Buser wrote:

> Hi
>
> I used the simtest function from the package multcomp. When
> using simtest with an lm object, it seems to depend on the order
> of the variables in the formula. See the code for an example:
>
> library(multcomp)
> set.seed(1)
> # response
> y <- rnorm(21)
> # one factor
> f1 <- factor(c(rep(c("A", "B", "C"), 7)))
> # and one continuous covariable
> x <- rnorm(21)
> testdata <- cbind(as.data.frame(y), f1, x)
>
> # the same model, just change the order in the formula
> reg1 <- lm(y ~ x + f1, data=testdata)
> reg2 <- lm(y ~ f1 + x, data=testdata)
> summary(simtest(reg1))
> > Coefficients:
> >             Estimate t value Std.Err. p raw p Bonf p adj
> > (Intercept)    0.427  -1.670    0.347 0.113  0.453 0.307
> > x              0.295  -0.599    0.256 0.557  1.000 0.848
> > f1B            0.204  -0.406    0.503 0.690  1.000 0.866
> > f1C            0.089  -0.255    0.493 0.802  1.000 0.866
> summary(simtest(reg2))
> > Coefficients:
> >             Estimate t value Std.Err. p raw p Bonf p adj
> > (Intercept)    0.427  -1.670    0.347 0.113  0.453 0.307
> > f1B            0.295  -0.599    0.503 0.557  1.000 0.848
> > f1C            0.204  -0.406    0.493 0.690  1.000 0.866
> > x              0.089  -0.255    0.256 0.802  1.000 0.866
>
> The tabular is fix, but the names of the variables are
> permutated, maybe a bug in extracting the formula from the lm
> object.
> You can avoid the problem by using a formula instead of an lm
> object, but in the help is mentioned that simtest works with an
> lm object, too.

you are right, thanks for the hint!

Torsten

>
>
> Regards,
>
> Christoph Buser
>
> --------------------------------------------------------------
> Christoph Buser <buser@stat.math.ethz.ch>
> Seminar fuer Statistik, LEO C11
> ETH (Federal Inst. Technology)	8092 Zurich	 SWITZERLAND
> phone: x-41-1-632-5414		fax: 632-1228
> http://stat.ethz.ch/~buser/
> --------------------------------------------------------------
>
>


[Rd] Re: simtest with lm object: depends on order in formula
Torsten Hothorn