clme_em: Constrained EM algorithm for linear fixed or mixed effects...

Description Usage Arguments Details Value Note See Also Examples

View source: R/clme.em.r

Description

clme_em_fixed performs a constrained EM algorithm for linear fixed effects models.

clme_em_mixed performs a constrained EM algorithm for linear mixed effects models.

clme_em is the general function, it will call the others. These Expectation-maximization (EM) algorithms estimate model parameters and compute a test statistic.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
clme_em_fixed(
  Y,
  X1,
  X2 = NULL,
  U = NULL,
  Nks = dim(X1)[1],
  Qs = dim(U)[2],
  constraints,
  mq.phi = NULL,
  tsf = lrt.stat,
  tsf.ind = w.stat.ind,
  mySolver = "LS",
  em.iter = 500,
  em.eps = 1e-04,
  all_pair = FALSE,
  dvar = NULL,
  verbose = FALSE,
  ...
)

clme_em_mixed(
  Y,
  X1,
  X2 = NULL,
  U = NULL,
  Nks = dim(X1)[1],
  Qs = dim(U)[2],
  constraints,
  mq.phi = NULL,
  tsf = lrt.stat,
  tsf.ind = w.stat.ind,
  mySolver = "LS",
  em.iter = 500,
  em.eps = 1e-04,
  all_pair = FALSE,
  dvar = NULL,
  verbose = FALSE,
  ...
)

clme_em(
  Y,
  X1,
  X2 = NULL,
  U = NULL,
  Nks = nrow(X1),
  Qs = ncol(U),
  constraints,
  mq.phi = NULL,
  tsf = lrt.stat,
  tsf.ind = w.stat.ind,
  mySolver = "LS",
  em.iter = 500,
  em.eps = 1e-04,
  all_pair = FALSE,
  dvar = NULL,
  verbose = FALSE,
  ...
)

Arguments

Y

Nx1 vector of response data.

X1

Nxp1 design matrix.

X2

optional Nxp2 matrix of covariates.

U

optional Nxc matrix of random effects.

Nks

optional Kx1 vector of group sizes.

Qs

optional Qx1 vector of group sizes for random effects.

constraints

list containing the constraints. See Details.

mq.phi

optional MINQUE estimates of variance parameters.

tsf

function to calculate the test statistic.

tsf.ind

function to calculate the test statistic for individual constrats. See Details for further information.

mySolver

solver to use in isotonization (passed to activeSet).

em.iter

maximum number of iterations permitted for the EM algorithm.

em.eps

criterion for convergence for the EM algorithm.

all_pair

logical, whether all pairwise comparisons should be considered (constraints will be ignored).

dvar

fixed values to replace bootstrap variance of 0.

verbose

if TRUE, function prints messages on progress of the EM algorithm.

...

space for additional arguments.

Details

Argument constraints is a list including at least the elements A, B, and Anull. This argument can be generated by function create.constraints.

Value

The function returns a list with the elements:

Note

There are few error catches in these functions. If only the EM estimates are desired, users are recommended to run clme setting nsim=0.

By default, homogeneous variances are assumed for the residuals and (if included) random effects. Heterogeneity can be induced using the arguments Nks and Qs, which refer to the vectors (n1, n2 ,... , nk) and (c1, c2 ,... , cq), respectively. See CLME-package for further explanation the model and these values.

See w.stat and lrt.stat for more details on using custom test statistics.

See Also

CLME-package clme create.constraints lrt.stat w.stat

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
data( rat.blood )

model_mats <- model_terms_clme( mcv ~ time + temp + sex + (1|id), data = rat.blood )

Y  <- model_mats$Y
X1 <- model_mats$X1
X2 <- model_mats$X2
U  <- model_mats$U

cons <- list(order = "simple", decreasing = FALSE, node = 1 )

clme.out <- clme_em(Y = Y, X1 = X1, X2 = X2, U = U, constraints = cons)

CLME documentation built on July 8, 2020, 5:49 p.m.