lmerPV | R Documentation |
Fits a linear mixed-effects model using lmer and plausible values.
lmerPV(
formula,
data = NULL,
weights = NULL,
pvs,
relatedpvs = TRUE,
grandmean = NULL,
groupmean = NULL,
group = NULL,
nullmodel = FALSE,
...
)
formula |
a two-sided linear formula object describing both the
fixed-effects and random-effects part of the model, with the
response on the left of a |
data |
an optional data frame containing the variables named in
|
weights |
an optional vector of ‘prior weights’ to be used
in the fitting process. Should be |
pvs |
a list indicating which variables from |
relatedpvs |
a logical value indicating if |
grandmean |
a character vector indicating the names of columns of
|
groupmean |
a character vector indicating the names of columns of
|
group |
a string specifying the variable name (within |
nullmodel |
a logical value indicating if the null model should also be estimated. |
... |
Arguments passed on to
|
a list.
# Null model - with PVs
## Named list, with element names matching formula variables
pvs = list(MATH = paste0("Math",1:5))
m1 <- lmerPV(formula = MATH ~ 1 + (1|GROUP), # Intercept varies across GROUP
pvs = pvs, # Named list
data = repdata, # Data frame
weights = repdata$wt) # Weights vector
m1
## Fixed effects
m1$fixef
## Random effects
m1$ranef
## Models for each PV
summary(m1$models)
# Multiple regression
## Named list, with element names matching formula variables
pvs = list(MATH = paste0("Math",1:5))
m2 <- lmerPV(formula = MATH ~ 1 + GENDER + SES + schoolSES + (1|GROUP),
pvs = pvs, # Named list
data = repdata, # Data frame
weights = repdata$wt) # Weights vector
m2
# Multiple regression with grandmean centering
## Named list, with element names matching formula variables
pvs = list(MATH = paste0("Math",1:5))
m3 <- lmerPV(formula = MATH ~ 1 + GENDER + SES + schoolSES + (1|GROUP),
pvs = pvs, # Named list
data = repdata, # Data frame
weights = repdata$wt,
grandmean = c("SES","schoolSES"))
m3
# Multiple regression with groupmean centering
## Named list, with element names matching formula variables
pvs = list(MATH = paste0("Math",1:5))
m4 <- lmerPV(formula = MATH ~ 1 + GENDER + SES + schoolSES + (1|GROUP),
pvs = pvs, # Named list
data = repdata, # Data frame
weights = repdata$wt,
grandmean = "schoolSES",
groupmean = "SES",
group = repdata$GROUP)
m4
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.