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)
Run the code above in your browser using DataLab