create_Z: Create matrix Z

Description Usage Arguments Details Value Examples

View source: R/create_Z.R

Description

Function create_Z creates matrix Z which contains covariates of random effects

Usage

1
2
3
4
5
6
7
create_Z(
  model = c("NERM", "FHM", "RIRS"),
  clusterID,
  nrandom = 1,
  X = NULL,
  intercept = TRUE
)

Arguments

model

Type of mixed model: NERM, FHM, RIRS (random slopes and random intercepts)

clusterID

Vector with cluster labels

nrandom

Which slopes should be random? Default: 1

X

Matrix with covariates for fixed effects. Default: NULL

intercept

Is column of ones, representing the intercept, present in X Default: TRUE

Details

Matrix X is only needed if we select an option model = "RIRS".

Value

Z

Matrix of covariates for random effects

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#NERM
clusterID = rep(1:5, 2:6)
Z = create_Z("NERM", clusterID)

#FHM
clusterID = c(1:5)
Z = create_Z("FHM", clusterID)

#RIRS
clusterID = rep(1:5, 10)
n = 50
p = 10
X = matrix(rnorm(n * p), n, p)
Z = create_Z("RIRS", clusterID, nrandom = 4,
             X, intercept = FALSE)

KatarzynaReluga/postcAIC documentation built on Jan. 25, 2022, 12:33 a.m.