# Title : LME.R
# Objective : Linear Mixed Effects
# Created by: greyhypotheses
# Created on: 11/03/2022
# the data
data(sleepstudy)
# summary
summary(object = sleepstudy)
#' Random Intercept, Fixed Effects Model
# ... Reaction > fixed, Subject > random
model <- lme(fixed = Reaction ~ Days, data = sleepstudy, random = ~1 | Subject)
estimates <- summary(model)
# ... the fixed effects regression coefficients \beta_{0} & \beta_{1}
estimates$coefficients$fixed
# ... variances
estimates$sigma
# ... ln-likelihood & AIC
estimates$logLik
estimates$AIC
# ... method
estimates$method
# ... alternative
alternative <- lme(fixed = Reaction ~ Days, data = sleepstudy, random = ~1 | Subject, method = 'ML')
summary(object = alternative)
# Residuals
# ... are the points randomly distributed about y = 0
plot(model, frame.plot = FALSE)
plot(x = model$fitted, y = model$residuals, frame.plot = FALSE)
# ... are the standardised residuals normally distributed?
# ... if the points lie along line y = x ... yes
qqnorm(model, frame.plot = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.