From buser at stat.math.ethz.ch  Fri Apr  1 11:14:36 2005
From: buser at stat.math.ethz.ch (Christoph Buser)
Date: Fri Apr  1 11:14:50 2005
Subject: [Rd] simtest with lm object: depends on order in formula
Message-ID: <16973.4348.501231.667259@stat.math.ethz.ch>

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.


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] simtest with lm object: depends on order in formula
Christoph Buser