How can I (1) compare two linear models between years and (2) Can I compare 2 models with different response variables?
My data have 4 variables: y_meas, x, year, y_calc. "y_meas" is a lab measured response varibale, and "y_calc" is an estimate of the same variable, using a standard calculation. "x " is a dosage, similar(ish) between two years:
#create dataset
set.seed(100)
dat <- within(data.frame(x = rep(1:10, times=2)),
{
year <- rep(1990:1991, each = 10)
y_meas <- 0.5 * x* (1:20) + rnorm(20)
y_calc <- 0.3 * x* (1:20) + rnorm(20)
year <- factor(year) # convert to a factor
}
)
I have two related questions: (1) Is there any difference between slope/intercept of models for 1990 and 1991?
m.1990<-lm(y_meas~x, data=subset(dat, year==1990))
m.1991<-lm(y_meas~x, data=subset(dat, year==1991))
anova(m.1990)
anova(m.1991)
# both models are significant
I can't run anova(m.1990,m.1991)
because the models are not nested? Do I need to use year as a dummy variable and run ANCOVA? What does this look like (roughly)?
(2) Assuming I can combine 1990 and 1991, can I compare the slope/intercept of 'y_meas~x' and 'y_calc~x'? Yes, two different response variables, but are on the same scale.