nLogLike: Penalized negative log-likelihood

Description Usage Arguments Value References Examples

View source: R/nLogLike.R

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

1
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<c3><9f>, C.H. (2019): Penalized Estimation of Flexible Hidden Markov Models for Time Series of Counts. arXiv:https://arxiv.org/pdf/1901.03275.pdf.

Examples

1
2
3
4
5
6
7
# 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)

countHMM documentation built on May 2, 2019, 1:06 p.m.

Related to nLogLike in countHMM...