I often am in the situation of having data sets consisting of an independent variable, a dependent variable, and a factor with multiple levels - for instance, calibration curves for an instrument measured on different days. I would like to know whether the data are best described by a single fit line or by a different fit line for each factor level; i.e., whether the data are best described by a single calibration curve based on all of the data, or whether there are significant differences in the individual curves for each day.
From what I understand, ANCOVA will tell me separately whether the factor interacts with the slope and then whether it interacts with the intercept. What I want to know is whether the factor has a significant effect on the slope and the intercept of the line.
An example in R:
require(reshape) # for melt()
#Set up some data
set.seed(0)
x <- seq(from=0, to=2, length.out=50)
y1 <- x + rnorm(length(x)) + 0.3
y2 <- 1.2*x + rnorm(length(x))
d <- data.frame(x=x, day1=y1, day2=y2)#, day3=y3, day4=y4)
dm <- melt(d, id.vars="x")
ggplot(dm, aes(x=x, y=value, colour=variable)) + geom_point() + geom_smooth(method="lm", se=T)
m <- lm(value ~ x*variable, data=dm)
summary(m)
Here, the effect of the factor and the interaction of the factor with the independent variable are each marginally significant - at alpha = 0.05 we would fail to reject the hypothesis that the factor has an effect on slope or intercept. However, taken together, perhaps they matter. Is there a good way to assess this?