FLXMRlmer | R Documentation |
This is a driver which allows fitting of mixtures of linear models with random effects.
FLXMRlmm(formula = . ~ ., random, lm.fit = c("lm.wfit",
"smooth.spline"), varFix = c(Random = FALSE, Residual =
FALSE), ...)
FLXMRlmer(formula = . ~ ., random, weighted = TRUE,
control = list(), eps = .Machine$double.eps)
formula |
A formula which is interpreted relative to the formula
specified in the call to |
random |
A formula for specifying the random effects. |
weighted |
A logical indicating if the model should be estimated with weighted ML. |
control |
A list of control parameters. See
|
eps |
Observations with a component-specific posterior smaller
than |
lm.fit |
A character string indicating if the coefficients should
be fitted using either a linear model or the function
|
varFix |
Named logical vector of length 2 indicating if the variance of the random effects and the residuals are fixed over the components. |
... |
Additional arguments to be passed to |
FLXMRlmm
allows only one random effect. FLXMRlmer
allows
an arbitrary number of random effects if weighted = FALSE
; a
certain structure of the model matrix of the random effects has to be
given for weighted ML estimation, i.e. where weighted = TRUE
.
Returns an object of class FLXMRlmer
and FLXMRlmm
inheriting from FLXMRglm
and FLXMR
, respectively.
For FLXMRlmer
the weighted ML estimation is only correct if the
covariate matrix of the random effects is the same for each
observation. By default weighted ML estimation is made and the
condition on the covariate matrix of the random effects is checked. If
this fails, only estimation with weighted = FALSE
is possible
which will maximize the classification likelihood.
Bettina Gruen
id <- rep(1:50, each = 10)
x <- rep(1:10, 50)
sample <- data.frame(y = rep(rnorm(unique(id)/2, 0, c(5, 2)), each = 10) +
rnorm(length(id), rep(c(3, 8), each = 10)) +
rep(c(0, 3), each = 10) * x,
x = x,
id = factor(id))
fitted <- flexmix(.~.|id, k = 2, model = FLXMRlmm(y ~ x, random = ~ 1),
data = sample, control = list(tolerance = 10^-3),
cluster = rep(rep(1:2, each = 10), 25))
parameters(fitted)
fitted1 <- flexmix(.~.|id, k = 2, model = FLXMRlmer(y ~ x, random = ~ 1),
data = sample, control = list(tolerance = 10^-3),
cluster = rep(rep(1:2, each = 10), 25))
parameters(fitted1)
fitted2 <- flexmix(.~.|id, k = 2,
model = FLXMRlmm(y ~ 0 + x, random = ~ 1,
lm.fit = "smooth.spline"),
data = sample, control = list(tolerance = 10^-3),
cluster = rep(rep(1:2, each = 10), 25))
parameters(fitted2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.