rmixlm {hhsmm} | R Documentation |
Random data generation from the mixture of Gaussian linear (Markov-switching) models for hhsmm model
Description
Generates vectors of covariate and response observations from mixture of Gaussian linear (Markov-switching) models in a specified state and using the parameters of a specified model
Usage
rmixlm(j, model, covar, ...)
Arguments
j |
a specified state |
model |
a |
covar |
either a function which generates the covariate vector or a list containing the following items:
|
... |
additional arguments of the |
Value
a random matrix of observations from mixture of Gaussian linear (Markov-switching) models, in which the first columns are associated with the responses and the last columns are associated with the covariates
Author(s)
Morteza Amini, morteza.amini@ut.ac.ir
References
Kim, C. J., Piger, J. and Startz, R. (2008). Estimation of Markov regime-switching regression models with endogenous switching. Journal of Econometrics, 143(2), 263-273.
Examples
J <- 3
initial <- c(1, 0, 0)
semi <- rep(FALSE, 3)
P <- matrix(c(0.5, 0.2, 0.3, 0.2, 0.5, 0.3, 0.1, 0.4, 0.5), nrow = J,
byrow = TRUE)
par <- list(intercept = list(3, list(-10, -1), 14),
coefficient = list(-1, list(1, 5), -7),
csigma = list(1.2, list(2.3, 3.4), 1.1),
mix.p = list(1, c(0.4, 0.6), 1))
model <- hhsmmspec(init = initial, transition = P, parms.emis = par,
dens.emis = dmixlm, semi = semi)
#use the covar as the list of mean and
#variance of the normal distribution
train1 <- simulate(model, nsim = c(20, 30, 42, 50), seed = 1234,
remission = rmixlm, covar = list(mean = 0, cov = 1))
plot(train1$x[,1] ~ train1$x[,2], col = train1$s, pch = 16,
xlab = "x", ylab = "y")
#use the covar as the runif function
#to generate one covariate from standard uniform distribution
train2 <- simulate(model, nsim = c(20, 30, 42, 50), seed = 1234,
remission = rmixlm, covar = runif, 1)
plot(train2$x[,1] ~ train2$x[,2], col = train2$s, pch = 16,
xlab = "x", ylab = "y")