nLogLike {countHMM}R Documentation

Penalized negative log-likelihood

Description

Computes the penalized negative log-likelihood using the forward algorithm as described in Adam et al. (2019). Not intended to be run by the user (internal function, called by the function fitMod).

Usage

nLogLike(parvect,x,N,stationary,lambda,sup,m,inflation)

Arguments

parvect

Vector of working parameters (as returned by pn2pw).

x

Vector of observed counts.

N

Integer, number of states.

stationary

Logical, determines whether the initial distribution of the Markov chain underlying the observed counts is the stationary distribution.

lambda

Vector of length N which contains the smoothing parameters associated with the different state-dependent distributions.

sup

Integer, determines the upper bound of the support of the state-dependent distributions. If NULL, then the maximum of x is used.

m

Integer, order of the difference penalties.

inflation

Count probabilities to be excluded from penalization (e.g. in the presence of zero-inflation).

Value

Numeric, the penalized negative log-likelihood.

References

Adam, T., Langrock, R., and WeiƟ, C.H. (2019): Penalized Estimation of Flexible Hidden Markov Models for Time Series of Counts. arXiv:https://arxiv.org/pdf/1901.03275.pdf.

Examples

# importing example data
x = read.table("http://www.hmms-for-time-series.de/second/data/earthquakes.txt")$V2
# computing the penalized negative log-likelihood
parvect = pn2pw(N=2,probs=cbind(dpois(x=0:41,lambda=14),dpois(x=0:41,lambda=26)),
gamma=matrix(c(0.95,0.05,0.05,0.95),ncol=2),delta=NULL,stationary=TRUE)
lambda = rep(10^4,2)
nLogLike(parvect=parvect,x=x,N=2,stationary=TRUE,lambda=lambda,sup=41,m=3,inflation=FALSE)

[Package countHMM version 0.1.0 Index]