mc_mixed: Mixed Models Structure

Description Usage Arguments Details Value Author(s) Source See Also Examples

View source: R/mc_mixed.R

Description

The function mc_mixed helps to build the components of the matrix linear predictor associated with mixed models. It is useful to model the covariance structure as a function of known covariates in a linear mixed model fashion (Bonat, et. al. 2016). The mc_mixed function was designed to analyse repeated measures and longitudinal data, where in general the observations are taken at a fixed number of groups, subjects or unit samples.

Usage

1

Arguments

formula

a formula model to build the matrix linear predictor. See details.

data

data set.

Details

The formula argument should be specified similar to the linear predictor for the mean structure, however the first component should be 0 and the second component should always indicate the name of the column containing the subject or unit sample index. It should be a factor. The other covariates are specified after a slash "\" in the usual way. For example, ~0 + SUBJECT/(x1 + x2) means that the column SUBJECT contains the subject or unit sample index, while the covariates that can be continuous or factors are given in the columns x1 and x2. Be careful the parenthesis after the "\" are mandatory, when including more than one covariate. The special case where only the SUBJECT effect is requested the formula takes the form ~ 0 + SUBJECT without any extra covariate. This structure corresponds to the well known compound symmetry structure. By default the function mc_mixed include all interaction terms, the users can ignore the interactions terms removing them from the matrix linear predictor.

Value

A list of matrices.

Author(s)

Wagner Hugo Bonat, wbonat@ufpr.br

Source

Bonat, W. H. (2018). Multiple Response Variables Regression Models in R: The mcglm Package. Journal of Statistical Software, 84(4):1–30.

Bonat, et. al. (2016). Modelling the covariance structure in marginal multivariate count models: Hunting in Bioko Island. Journal of Agricultural Biological and Environmental Statistics, 22(4):446–464.

See Also

mc_id, mc_conditional_test, mc_dist, mc_ma, mc_rw and mc_car.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
SUBJECT <- gl(2, 6)
x1 <- rep(1:6, 2)
x2 <- rep(gl(2,3),2)
data <- data.frame(SUBJECT, x1 , x2)
# Compound symmetry structure
mc_mixed(~0 + SUBJECT, data = data)
# Compound symmetry + random slope for x1 and interaction or correlation
mc_mixed(~0 + SUBJECT/x1, data = data)
# Compound symmetry + random slope for x1 and x2 plus interactions
mc_mixed(~0 + SUBJECT/(x1 + x2), data = data)

wbonat/mcglm documentation built on June 23, 2020, 11:06 a.m.