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

Torsten Hothorn Torsten.Hothorn at rzmail.uni-erlangen.de
Fri Apr 1 11:28:45 CEST 2005


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 at 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/
> --------------------------------------------------------------
>
>



More information about the R-devel mailing list