Description Usage Arguments Details Value References See Also Examples
Fit a null two-level random intercept model using closed-form formulas provided by Snijders nd Bosker (1999)
1 2 3 4 |
y |
numeric, dependent variable |
g |
numeric, grouping factor |
data |
data frame, optional dataset where the variables should be looked for |
x |
object of class "nullModel" |
... |
other arguments passed to/from other methods |
The function fits a random effect model of the form:
Y_ij = mu + U_j + R_ij
where Y_ij is the value of the dependent variable (y
)
for i-th object within j-th group, mu is the population mean,
U_j is the effect specific to group j, and R_ij is the
within-grup error.
The function estimates between-group and pooled within-group variances as well as the intra-class correlation coefficient. The closed-form expressions are provided by Snijders and Bosker (1999, p. 18–21).
The function returns a list of S3 class "nullModel" which contains the following components:
character, name of the dependent variable
character, name of the grouping factor
numeric, number of groups
numeric, total number of observations
numeric, pooled within-group variance
numeric, between-group variance
numeric, estimate of the population between-group variance
numeric, intra-class correlation coefficient
Snijders, T.A.B., Bosker, R. (1999) "Multilevel Analysis. An Introduction to Basic and Advanced Multilevel Modelling". London: Sage
lmer
in package lme4 for general fitting of mixed-effects
models.
1 2 3 4 5 6 7 8 9 10 | ## Not run:
# fit null model with lmer
library(lme4)
system.time(mm <- lmer( Reaction ~ 1 | Subject, sleepstudy ))
# fit with closed-form formulas
system.time(m <- nullModel( sleepstudy$Reaction, sleepstudy$Subject ))
mm
m
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.