I want to check whether a group of patients are significantly different from their control group. However, I also want to check if the p-value is still significant in case a covariate is taken into account. For that I created a simple data frame in R:
data <- data.frame(group = c(rep("CTRL", 10), rep("P", 10)),
response = c(10,11,14,16,17,17,19,20,21,22, 10,11,11,11,12,13,14,14,15,16),
age = c(40,41,45,43,50,51,55,57,60,62, 40,42,43,43,45,46,46,50,52,54))
First of all, I performed a normal ANOVA using the lm
function. I tried 3 different ways to see if the results are the same. And they are:
anova(lm(data$response ~ data$group))
summary(lm(data$response ~ data$group))
summary(aov(data$response ~ data$group)
To check if the covariate age
is correlated with the response
variable I performed a correlation test:
cor.test(data$response, data$age)
Seeing a high and significant correlation I concluded that the significance between the control group and the patient group might be due to the effect of age.
I am now unsure how to perform the ANCOVA analysis to check if the effect between the two groups is really there or if it is just because of the covariate age.
To check this I did the following:
m1 <- lm(data$response ~ data$group + data$age)
m2 <- lm(data$response ~ data$group)
anova(m1, m2)
Comparing the two models resulted in a significant p-value. I would have thought of a p-value of much less significant then the one obtained with the normal anova. Is it actually right to compare the two models or can I achieve this by using only one model? I am really stuck here and hoping to find some helpful answers here.