
Randomly generate data from a mixture model
rMixglm.RdRandom generation of response variable from identified mixture model
Examples
if (FALSE) { # \dontrun{
set.seed(10)
n <- 200
x <- rnorm(n)
group <- rbinom(n, 1, 0.5)
y <- rnorm(n, 1 + 0.5 * x * c(-1, 1)[group + 1], 0.1)
plot(y ~ x)
dat <- data.frame(x, y)
mod <- mixglm(
stateValModels = y ~ x,
stateProbModels = ~ x,
statePrecModels = ~ x,
inputData = dat,
numStates = 2)
rMixglm(mod, n = 3)
# for newdata
rMixglm(mod, n = 3, newdata = data.frame(x = c(0, 0.5)))} # }