fasthmmfit.cont: Fast gradient descent algorithm to learn the parameters in a...

Description Usage Arguments Value References Examples

View source: R/fasthmmfit.cont.R

Description

Fast gradient descent algorithm to learn the parameters in a specialized continuous-time zero-inflated hidden Markov model, where zero-inflation only happens in State 1. And if there were covariates, they could only be the same ones for the state-dependent log Poisson means and the logit structural zero proportion.

Usage

1
2
fasthmmfit.cont(y, x = NULL, M, prior_init, tpm_init, emit_init, zero_init,
  yceil = NULL, timeindex, method = "Nelder-Mead", hessian = FALSE, ...)

Arguments

y

observed time series values

x

matrix of covariates for the log poisson means and logit zero proportion. Default to NULL.

M

number of latent states

prior_init

a vector of initial values for prior probability for each state

tpm_init

a matrix of initial values for transition rate matrix

emit_init

a vector of initial values for the means for each poisson distribution

zero_init

a scalar initial value for the structural zero proportion

yceil

a scalar defining the ceiling of y, above which the values will be truncated. Default to NULL.

timeindex

a vector containing the time points

method

method to be used for direct numeric optimization. See details in the help page for optim() function. Default to Nelder-Mead.

hessian

Logical. Should a numerically differentiated Hessian matrix be returned? Note that the hessian is for the working parameters, which are the generalized logit of prior probabilities (except for state 1), the generalized logit of the transition probability matrix(except 1st column), the logit of non-zero zero proportions, and the log of each state-dependent poisson means

...

Further arguments passed on to the optimization methods

Value

the maximum likelihood estimates of the zero-inflated hidden Markov model

References

Liu, Yu-Ying, et al. "Efficient learning of continuous-time hidden markov models for disease progression." Advances in neural information processing systems. 2015.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
priorparm <- 0
tpmparm <- c(-1,-2)
zeroindex <- c(1,0)
zeroparm <- c(0,-1,1)
emitparm <- c(2,0.5,-0.5,3,0.3,-0.2)
workparm <- c(priorparm,tpmparm,zeroparm,emitparm)
timeindex <- rep(1,1000)
for(i in 2:1000) timeindex[i] <- timeindex[i-1] + sample(1:4,1)

designx <- matrix(rnorm(2000),nrow=1000,ncol=2)
result <- hmmsim2.cont(workparm,2,1000,zeroindex,emit_x=designx,
                      zeroinfl_x=designx,timeindex=timeindex)
y <- result$series
state <- result$state

fit2 <-  fasthmmfit.cont(y=y,x=designx,M=2,prior_init=c(0.5,0.5),
  tpm_init=matrix(c(-0.2,0.2,0.1,-0.1),2,2,byrow=TRUE),
  zero_init=0.4,emit_init=c(7,21), timeindex=timeindex,
  hessian=FALSE, method="BFGS", control=list(trace=1))

ziphsmm documentation built on May 2, 2019, 6:10 a.m.