npllHSMM: negative penalised HSMM log-likelihood function

Description Usage Arguments Details Value References Examples

View source: R/npllHSMM.R

Description

Evaluates the negative penalised log-likelihood function of the HSMM (internal function, called by the function pmleHSMM).

Usage

1
2
3
npllHSMM(parvect ,N, y, R_vec, lambda, order_diff,
        y_dist=c("norm","gamma","pois","bern"),
        stationary=TRUE, T_y,  p_ref=2)

Arguments

parvect

vector of unconstraint working parameter as returned by the function n2wHSMM.

N

number of states of the HSMM, integer greater than 1.

y

vector containing the observed time series.

R_vec

vector of length N containing the lengths of the unstructured starts of the dwell-time distributions.

lambda

vector of length N containing the smoothing parameter values to weight the penalty term.

order_diff

order of the differences used for the penalty term, positive integer which does not exceed the length of the unstructured starts.

y_dist

character determining the class of state-dependent distributions. Supported values are "norm" (normal distribution), "gamma" (gamma distribution), "pois" (Poisson distribution) and "bern" (Bernoulli distribution).

stationary

Logical, if TRUE (default), stationarity is assumed, if FALSE, the underlying state-sequence is assumed to enter a new state at time t=1.

T_y

length of the observed time series.

p_ref

positive integer determining the reference dwell-time probability used for the multinomial logit parameter transformation. Default value is 2. Only needs to be changed if the dwell-time probability for dwell time r=2 is estimated very close to zero in order to avoid numerical problems.

Details

The penalised log-likelihood function relies on the exact HMM representation of the HSMM and is evaluated using the forward algorithm which is implemented in C++ to speed up the calculation.

Value

Returns the value of the negative penalised HSMM log-likelihood function for the given parameters and time series.

References

Pohle, J., Adam, T. and Beumer, L.T. (2021): Flexible estimation of the state dwell-time distribution in hidden semi-Markov models. arXiv:https://arxiv.org/abs/2101.09197.

Zucchini, W., MacDonald, I.L. and Langrock, R. (2016): Hidden Markov models for time series: An introduction using R. 2nd edition. Chapman & Hall/CRC, Boca Raton.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# 3-state gamma HSMM and hourly muskox step length
# natural parameters
p_list0<-list()
p_list0[[1]]<-c(dgeom(0:9,0.2),1-pgeom(9,0.2))
p_list0[[2]]<-c(dgeom(0:9,0.2),1-pgeom(9,0.2))
p_list0[[3]]<-c(dgeom(0:9,0.2),1-pgeom(9,0.2))
omega0<-matrix(0.5,3,3)
diag(omega0)<-0
mu0<-c(5,100,350)
sigma0<-c(3,90,300)
R_vec<-sapply(p_list0,length)-1 # lengths of the unstructured starts
# working parameter vector
parvect<-n2wHSMM(N=3,p_list=p_list0,mu=mu0,sigma=sigma0,
  omega=omega0,y_dist='gamma')
# evaluate the negative penalised log-likelihood function
npllHSMM(parvect,N=3,muskox$step,R_vec=R_vec,lambda=c(1000,1000,1000),
  order_diff=2,y_dist="gamma",T_y=nrow(muskox))

PHSMM documentation built on Feb. 9, 2021, 5:07 p.m.

Related to npllHSMM in PHSMM...