Displaying 2 results from an estimated 2 matches for "ran_effects".
2007 Aug 13
0
R^2 for multilevel models
...ata$x * coef(lm1)[2]
plot(thedata$y, predicted)
# It's a noisy mess
cor(thedata$y, predicted)^2
# Now how about adjusting 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...
2007 Oct 08
0
Residuals for binomial lmer fits
...edata = merge(sub_noise, thedata)
thedata$x = rep(1:obs,people)
thedata$y = 23*thedata$x + 20 + thedata$rand_int + resids
thedata$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] +...