[R] Ques about the 'test.terms' argument in 'regTermTest'

Almirall, Daniel almirall at rand.org
Thu Aug 19 15:53:58 CEST 2004


Hi,

Z is a three level factor variables and ZB and ZC are its corresponding binary dummy variables.  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