[R] ANOVA with both discreet and continuous variable

From: array chip <arrayprofile_at_yahoo.com>
Date: Sat 23 Apr 2005 - 14:31:38 EST


Hi all,

I have dataset with 2 independent variable, one (x1) is continuous, the other (x2) is a categorical variable with 2 levels. The dependent variable (y) is continuous. When I run linear regression y~x1*x2, I found that the p value for the continuous independent variable x1 changes when different contrasts was used (helmert vs. treatment), while the p values for the categorical x2 and interaction are independent of the contrasts used. Can anyone explain why? I guess the p value for x1 is testing different hypothesis under different contrasts? If the interaction is NOT significant, what contrast should I use to test the hypothesis that x1 is not significantly related with y?

x1<-rnorm(50,9,2)
x2<-as.factor(as.numeric(runif(50)<0.35)) y<-rnorm(50,30,5)

options(contrasts=c('contr.treatment','contr.poly')) summary(lm(y~x1*x2))

options(contrasts=c('contr.helmert','contr.poly')) summary(lm(y~x1*x2))



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Apr 23 17:00:27 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:23 EST