Learn R Programming

hhsmm (version 0.4.2)

predict.hhsmm: prediction of state sequence for hhsmm

Description

Predicts the state sequence of a fitted hidden hybrid Markov/semi-Markov model estimated by hhsmmfit for a new (test) data of class "hhsmmdata" with an optional prediction of the residual useful lifetime (RUL) for a left to right model

Usage

# S3 method for hhsmm
predict(
  object,
  newdata,
  ...,
  future = 0,
  method = "viterbi",
  RUL.estimate = FALSE,
  confidence = "max",
  conf.level = 0.95
)

Value

a list containing the following items:

  • x the observation sequence

  • s the predicted state sequence

  • N the vector of sequence lengths

  • p the state probabilities

  • RUL the point predicts of the RUL

  • RUL.low the lower bounds for the prediction intervals of the RUL

  • RUL.up the upper bounds for the prediction intervals of the RUL

Arguments

object

a fitted model of class "hhsmm" estimated by hhsmmfit

newdata

a new (test) data of class "hhsmmdata", which also can contain missing values (NA or NaN)

...

additional parameters for the dens.emission and mstep functions

future

number of future states to be predicted

method

the prediction method with two options:

  • "viterbi" (default) uses the Viterbi algorithm for prediction

  • "smoothing" uses the smoothing algorithm for prediction

RUL.estimate

logical. if TRUE the residual useful lifetime (RUL) of a left to right model, as well as the prediction interval will also be predicted (default is FALSE)

confidence

the method for obtaining the prediction interval of the RUL, with two cases:

  • "max" (default) the maximum probability as the point predict and the high probability critical values as the lower and upper bounds

  • "mean" the mean value as the point predict and the normal confidence lower and upper bounds as the prediction interval

conf.level

the confidence level of the prediction interval (default 0.95)

Author

Morteza Amini, morteza.amini@ut.ac.ir, Afarin Bayat, aftbayat@gmail.com

References

Guedon, Y. (2005). Hidden hybrid Markov/semi-Markov chains. Computational statistics and Data analysis, 49(3), 663-688.

OConnell, J., & Hojsgaard, S. (2011). Hidden semi Markov models for multiple observation sequences: The mhsmm package for R. Journal of Statistical Software, 39(4), 1-22.

See Also

predict.hhsmmspec

Examples

Run this code
J <- 3
initial <- c(1, 0, 0)
semi <- c(FALSE, TRUE, FALSE)
P <- matrix(c(0.8, 0.1, 0.1, 0.5, 0, 0.5, 0.1, 0.2, 0.7), nrow = J, 
byrow = TRUE)
par <- list(mu = list(list(7, 8), list(10, 9, 11), list(12, 14)),
sigma = list(list(3.8, 4.9), list(4.3, 4.2, 5.4), list(4.5, 6.1)),
mix.p = list(c(0.3, 0.7), c(0.2, 0.3, 0.5), c(0.5, 0.5)))
sojourn <- list(shape = c(0, 3, 0), scale = c(0, 10, 0), type = "gamma")
model <- hhsmmspec(init = initial, transition = P, parms.emis = par,
dens.emis = dmixmvnorm, sojourn = sojourn, semi = semi)
train <- simulate(model, nsim = c(10, 8, 8, 18), seed = 1234, remission = rmixmvnorm)
test <-  simulate(model, nsim = c(7, 3, 3, 8), seed = 1234, remission = rmixmvnorm)
clus = initial_cluster(train, nstate = 3, nmix = c(2, 2, 2),ltr = FALSE,
final.absorb = FALSE, verbose = TRUE)
semi <- c(FALSE, TRUE, FALSE)
initmodel1 = initialize_model(clus = clus,sojourn = "gamma",
M = max(train$N), semi = semi)
fit1 = hhsmmfit(x = train, model = initmodel1, M = max(train$N))
yhat1 <- predict(fit1, test)

Run the code above in your browser using DataLab