I'm slowly working through multilevel models and have a pretty specific question/though checking.
Here's some R code:
This is a called a null model correct? This is because you're predicting the outcome based solely using the grand mean as the prediction.
I assume this is correct because I can achieve the same results by:
So now let's look at a similar model in the lme4 package.
My take on this is that it is nearly identical to:
Is this true? The only difference is that the lme function is using REML? So basically this model is predicting based on the group mean as demonstrated by the code below?
Again the only difference between the two fm1 and fm2 is that fm1 is using REML and fm2 is using OLS?
Can some smarter people just check/critique my thinking?
Here's some R code:
Code:
library(lme4); data(Dyestuff)
mod <- lm(Yield ~ 1 , Dyestuff)
resid(mod)
I assume this is correct because I can achieve the same results by:
Code:
Dyestuff$Yield - mean(Dyestuff$Yield)
Code:
fm1 <- lmer(Yield ~ 1 + (1|Batch), Dyestuff)
resid(fm1)
Code:
fm2 <- lm(Yield ~ Batch, Dyestuff)
resid(fm2)
Code:
with(Dyestuff, ave(Yield, Batch, FUN=function(x) x - mean(x)))
Can some smarter people just check/critique my thinking?