Displaying 2 results from an estimated 2 matches for "ran_effects_data".
2007 Oct 08
0
Residuals for binomial lmer fits
...ata$y.flat = 23*thedata$x + 20 + resids
# Fit a random intercept model
lmer1 = lmer(y ~ x + (1|id), data=thedata)
summary(lmer1)
# Get the intercepts
ranef(lmer1)$id[1]
ran_effects = data.frame(rownames(ranef(lmer1)$id), ranef(lmer1)$id[1])
names(ran_effects) = c("id", "b")
ran_effects_data = merge(thedata, ran_effects)
# Calculate the predicted y's using the fixed effects and flattening out
# using the random effects:
predicted.y = fixef(lmer1)[1] + ran_effects_data$x * fixef(lmer1)[2]
+ ran_effects_data$b
# Now how far off were we?
my.resids = predicted.y -...
2007 Aug 13
0
R^2 for multilevel models
...ng everyone's intercept towards the group
# intercept?
lmer1 = lmer(y ~ x + (1|id), data=thedata)
summary(lmer1)
# Get the random intercepts and stick them in a table
ran_effects = data.frame(rownames(ranef(lmer1)$id), ranef(lmer1)$id[1])
names(ran_effects) = c("id", "b")
ran_effects_data = merge(thedata, ran_effects)
# Now compute
predicted.ml = fixef(lmer1)[1] + ran_effects_data$x * fixef(lmer1)[2]
+ ran_effects_data$b
plot(thedata$y, predicted.ml)
cor(thedata$y, predicted.ml)^2
# Looks much nicer