Hi there,

I tried to use the function ancova to analyze covariance in my model.
my model is like the following; I want to include two treatments(trt1, trt2)
, their interaction and one covariate (covar1)
y ~ trt1+trt2+trt1*trt2+ covar1

R code:
mydata$trt1=factor(mydata$trt1) # 2 levels
contrasts(mydata$trt1)=contr.treatment(2)
mydata$trt2=factor(mydata$trt2) # 2 levels
contrasts(mydata$trt2)=contr.treatment(2)
mydata$trt1.trt2=interaction(mydata$trt1,mydata$trt2)
contrasts(mydata$trt1.trt2) <- contr.treatment(4)

model=ancova(y ~ trt1*trt2+ covar1, data=mydata)  # there is no error
message

model1=ancova(y ~ trt1+trt1*trt2+covar1, data=mydata) there is error message

*Error in ancova(DELTA_PANSS ~ drug + drug.SULT + BASE, data = mydata_drug)
:
  ancova requires exactly one factor and exactly one numeric variable.
*
model2=ancova(y ~ trt1+trt2+trt1*trt2+covar1, data=mydata)

*Error in .subset2(x, i, exact = exact) :
  recursive indexing failed at level 2
In addition: Warning message:
In formula.plot[[3]][2:3] <- formula[[3]][2 + classes] :
  number of items to replace is not a multiple of replacement length
*
It will be really helpful if you could point out my mistake or point me to
the right model and function I should use.
Thank you,
Qian

	[[alternative HTML version deleted]]

