Learn R Programming

hsmm (version 0.3-2)

hsmm: Hidden Semi-Markov Models

Description

Fitting Hidden Semi-Markov Models

Usage

hsmm(x, od, rd, pi.par, tpm.par, od.par, rd.par,
                 M         = NA,
                 Q.max     = 500, 
                 epsilon   = 1e-08,  
                 censoring = 1,
                 prt       = TRUE,
                 detailed  = FALSE,
                 r.lim     = c(0.01, 100), 
                 p.log.lim = c(0.001, 0.999),
                 nu.lim    = c(0.01, 100))

Arguments

x
the observed process, a vector of length $\tau$
od
character with the name of the conditional distribution of the observations: "bern" = Bernoulli, "norm" = Normal, "pois" = Poisson, "t" = Student-t
rd
character with the name of the runlength distribution (or sojourn time, dwell time distribution): "nonp" = Non-parametric, "geom" = Geometric, "nbinom" = Negative Binomial, "log" = Logarithmic, , "pois" = Poisson
pi.par
vector of length $J$ with the initial values for the initial probabilities of the semi-Markov chain
tpm.par
matrix of dimension $J x J$ with the initial values for the transition probability matrix of the embedded Markov chain. The diagonal entries must all be zero; absorbing states are not permitted
rd.par
list with the initial values for the parameters of the runlength distributions. See further details below (section 'List Objects rd.par and od.par')
od.par
list with the initial values for the parameters of the conditional observation distributions. See further details below (section 'List Objects rd.par and od.par')
M
positive integer containing the maximum runlength
Q.max
positive integer containing the maximum number of iterations
epsilon
positive scalar giving the tolerance at which the relative change of log-likelihood is considered close enough to zero to terminate the algorithm.
censoring
integer. if equal to $1$, the last visited state contributes to the likelihood. If equal to $0$, the partial likelihood estimator, which ignores the contribution of the last visited state, is used. For details see
prt
logical. if TRUE, the log-likelihood and number of iterations carried out are printed for each iteration
detailed
logical. if TRUE, a list of the parameters at every iteration step is written into the ctrl list
r.lim
upper and lower bound for the r parameter of the negative binomial distribution in the M-step, bisection is applied to determine this parameter
p.log.lim
upper and lower bound for the parameter of the logarithmic distribution in the M-step, bisection is applied to determine this parameter
nu.lim
upper and lower bound for the degrees of freedom of parameter of the t distribution in the M-step, bisection is applied to determine this parameter

Value

  • callcall
  • iterpositive integer containing the number of iterations carried out
  • logldouble containing log-likelihood of the fitted model
  • paralist object containing the parameter estimates
  • ctrllist object containing additional control variables. These are solution.reached, error, and details. solution.reached is TRUE, if the stopping criterion is fulfilled. error returns an error code: 0 = no error, 1 = internal probability less or equal to zero, 2 = memory exception, 3 = file error (internal output from C routine, disabled by default). details contains the parameter values of every iteration.

List Objects rd.par and od.par

The list objects rd.par and od.par contain parameter values for the runlength and conditional observation distribution, respectively. For a model with $J$ states, the length of all parameter vectors is equal to $J$. For non-parametric runlength distribution, the corresponding entry is a matrix of dimension $M x J$. The names of the list entries have to be as follows. od.par "bern" (Bernoulli): "b" "norm" (Normal): "mean", "var" "pois" (Poisson): "lambda" "t" (Student-t): "mean", "var", "df" rd.par "nonp" (Non-parametric): "np" "geom" (Geometric): "p" "nbinom" (Negative Binomial): "r", "pi" "log" (Logarithmic): "p" "pois" (Poisson): "lambda"

Details

The function hsmm fits a Hidden Semi-Markov Model using the EM-Algorithm for parameter estimation. The estimation algorithms are based on the right-censored approach initially described in Guedon (2003).

References

Bulla, J. (2006), Stylized facts of financial time series and hidden semi-Markov models. Ph.D. thesis, Goettingen. Guedon, Y. (2003), Estimating Hidden Semi-Markov Chains From Discrete Sequences. JCGS, 12 (3), pp 604-639.

See Also

hsmm.smooth, hsmm.viterbi, hsmm.sim