This function computes the hierarchical two level model with random intercepts and random slopes. The full maximum likelihood estimation is conducted by means of an EM algorithm (Raudenbush & Bryk, 2002).

BIFIE.twolevelreg( BIFIEobj, dep, formula.fixed, formula.random, idcluster,
   wgtlevel2=NULL, wgtlevel1=NULL, group=NULL, group_values=NULL,
   recov_constraint=NULL, se=TRUE, globconv=1E-6, maxiter=1000 )

# S3 method for BIFIE.twolevelreg
summary(object,digits=4,...)

# S3 method for BIFIE.twolevelreg
coef(object,...)

# S3 method for BIFIE.twolevelreg
vcov(object,...)

Arguments

BIFIEobj

Object of class BIFIEdata

dep

String for the dependent variable in the regression model

formula.fixed

An R formula for fixed effects

formula.random

An R formula for random effects

idcluster

Cluster identifier. The cluster identifiers must be sorted in the BIFIE.data object.

wgtlevel2

Name of Level 2 weight variable

wgtlevel1

Name of Level 1 weight variable. This is optional. If it is not provided, wgtlevel is calculated from the total weight and wgtlevel2.

group

Optional grouping variable

group_values

Optional vector of grouping values. This can be omitted and grouping values will be determined automatically.

recov_constraint

Matrix for constraints of random effects covariance matrix. The random effects are numbered according to the order in the specification in formula.random. The first column in recov_constraint contains the row index in the covariance matrix, the second column the column index and the third column the value to be fixed.

se

Optional logical indicating whether statistical inference based on replication should be employed. In case of se=FALSE, standard errors are computed as maximum likelihood estimates under the assumption of random sampling of level 2 clusters.

globconv

Convergence criterion for maximum parameter change

maxiter

Maximum number of iterations

object

Object of class BIFIE.twolevelreg

digits

Number of digits for rounding output

...

Further arguments to be passed

Details

The implemented random slope model can be written as $$y_{ij}=\bold{X}_{ij} \bold{\gamma} + \bold{Z}_{ij} \bold{u}_j + \varepsilon_{ij}$$ where \(y_{ij}\) is the dependent variable, \(\bold{X}_{ij}\) includes the fixed effects predictors (specified by formula.fixed) and \(\bold{Z}_{ij}\) includes the random effects predictors (specified by formula.random). The random effects \(\bold{u}_j\) follow a multivariate normal distribution.

The function also computes a variance decomposition of explained variance due to fixed and random effects for the within and the between level. This variance decomposition is conducted for the predictor matrices \(\bold{X}\) and \(\bold{Z}\). It is assumed that \( \bold{X}_{ij}=\bold{X}_j^B + \bold{X}_{ij}^W\). The different sources of variance are computed by formulas as proposed in Snijders and Bosker (2012, Ch. 7).

Value

A list with following entries

stat

Data frame with coefficients and different sources of variance.

output

Extensive output with all replicated statistics

...

More values

References

Raudenbush, S. W., & Bryk, A. S. (2002). Hierarchical linear models: Applications and data analysis methods. Thousand Oaks: Sage.

Snijders, T. A. B., & Bosker, R. J. (2012). Multilevel analysis: An introduction to basic and advanced multilevel modeling. Thousand Oaks: Sage.

See also

The lme4::lmer function in the lme4 package allows only weights at the first level.

See the WeMix package (and the function WeMix::mix) for estimation of mixed effects models with weights at different levels.

Examples