[R] The 'test.terms' argument in 'regTermTest' in package 'survey'
Almirall, Daniel
almirall at rand.org
Thu Aug 19 08:30:11 CEST 2004
This is a question regarding the 'regTermTest' function in the 'survey' package. Imagine Z as a three level factor variable, and code ZB and ZC as the two corresponding dummy variables. X is a continuous variable. In a 'glm' of Y on Z and X, say, how do the two test specifications
test.terms = c("ZB:X","ZC:X") # and
test.terms = ~ ZB:X + ZC:X
in 'regTermTest' differ? I thought that both would return the same joint (Wald) test for the two Z:X interactions. Why does the second one specify a 1 degree of freedom test? The code below should help clarify my question.
Thanks much,
Danny
## I'm currently using: R Version 1.9.1 / Windows 2000 / P4/2.8 Ghz
Z <- as.factor(rep(LETTERS[1:3],20))
Y <- rep(0:1, 30)
X <- rnorm(60)
glm1 <- glm(Y ~ Z + X + Z:X, family=binomial)
summary(glm1)$coeff
regTermTest( model=glm1 , test.terms=~Z:X)
ZB <- ifelse(Z=="B",1,0)
ZC <- ifelse(Z=="C",1,0)
glm2 <- glm(Y ~ ZB + ZC + X + ZB:X + ZC:X, family=binomial)
summary(glm2)$coeff ## Okay, same as glm1
regTermTest( model=glm2 , test.terms= c("ZB:X","ZC:X"))
regTermTest( model=glm2 , test.terms= ~ ZB:X + ZC:X)
More information about the R-help
mailing list