[R] Contrast matrix with a continuous variable

Carlos Alvarez Roa carlosalvarezroa at hotmail.com
Wed Jun 1 13:31:34 CEST 2016









































Hi all, 

I was wondering if someone could help me designing a contrast matrix when 

you have a continuous variable (Days). 



My model looks like this: 



model<-lme(Y~A*B*Days, data=data_over_time) 



The factor A has two levels (A1 and A2) and factor B has three levels (B1, 

B2, and B3). I measured the response variable Y every two or three days over 

70 days (Days). 

I need to look at only a few comparisons over the 70 days such us: 
                        
A1 and B1 vs A2 and B1, 
                        
A2 and B2 vs A2 and B1, 
                        
A1 and B2 vs A2 and B2 

I could use the function contrast from the package contrast to design the 

matrix with all three comparisons. I know how to do it for specific days at a 

time. This would give me the first comparison for day 1.

a=contrast(model, 
           a=list(A='A1',B='B1',Days=1), 
           b=list(A='A2',B='B1',Days=1)
   ) 


However, I need to run the comparison over the 70 days not at 

individual time points at a time. 



I was wondering if someone could help me designing this contrast matrix. 



Any help would be much appreciated 

Cheers











 		 	   		  
	[[alternative HTML version deleted]]



More information about the R-help mailing list