additive_reg_mstep {hhsmm} | R Documentation |
the M step function of the EM algorithm
Description
The M step function of the EM algorithm for the Gaussian linear (Markov-switching) regression as the emission distribution using the responses and covariates matrices and the estimated weight vectors
Usage
additive_reg_mstep(x, wt, control = list(K = 5, lambda0 = 0.01, resp.ind = 1))
Arguments
x |
the observation matrix |
wt |
the state probabilities matrix (number of observations times number of states) |
control |
the parameters to control the M-step function.
The simillar name is chosen with that of
|
Value
list of emission (nonparametric mixture of splines) parameters:
Author(s)
Morteza Amini, morteza.amini@ut.ac.ir, Reza Salehian, reza.salehian@ut.ac.ir
References
Langrock, R., Adam, T., Leos-Barajas, V., Mews, S., Miller, D. L., and Papastamatiou, Y. P. (2018). Spline-based nonparametric inference in general state-switching models. Statistica Neerlandica, 72(3), 179-200.
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)
train <- simulate(model, nsim = c(20, 30, 42, 50), seed = 1234,
remission = rmixlm, covar = list(mean = 0, cov = 1))
clus = initial_cluster(train = train, nstate = 3, nmix = NULL,
ltr = FALSE, final.absorb = FALSE, verbose = TRUE, regress = TRUE)
initmodel = initialize_model(clus = clus ,mstep = additive_reg_mstep,
dens.emission = dnorm_additive_reg, sojourn = NULL, semi = rep(FALSE, 3),
M = max(train$N),verbose = TRUE)
fit1 = hhsmmfit(x = train, model = initmodel, mstep = additive_reg_mstep,
M = max(train$N))
plot(train$x[, 1] ~ train$x[, 2], col = train$s, pch = fit1$yhat,
xlab = "x", ylab = "y")
text(0,30, "colors are real states",col="red")
text(0,28, "characters are predicted states")
pred <- addreg_hhsmm_predict(fit1, train$x[, 2], 5)
yhat1 <- pred[[1]]
yhat2 <- pred[[2]]
yhat3 <- pred[[3]]
lines(yhat1[order(train$x[, 2])]~sort(train$x[, 2]),col = 2)
lines(yhat2[order(train$x[, 2])]~sort(train$x[, 2]),col = 1)
lines(yhat3[order(train$x[, 2])]~sort(train$x[, 2]),col = 3)