logLik.smm: Log-likelihood, AIC and BIC of a Markov or semi-Markov model

logLik.smmR Documentation

Log-likelihood, AIC and BIC of a Markov or semi-Markov model

Description

Methods of the generic functions stats::logLik, stats::AIC and stats::BIC for the Markov and semi-Markov models of the package: models specified by the user (mm, smmparametric, smmnonparametric) and fitted models (fitmm, fitsmm).

Usage

## S3 method for class 'smmparametric'
logLik(object, ...)
## S3 method for class 'smmnonparametric'
logLik(object, ...)
## S3 method for class 'smmfit'
logLik(object, ...)
## S3 method for class 'mm'
logLik(object, ...)
## S3 method for class 'mmfit'
logLik(object, ...)

## S3 method for class 'smmparametric'
AIC(object, ...)
## S3 method for class 'smmnonparametric'
AIC(object, ...)
## S3 method for class 'smmfit'
AIC(object, ...)
## S3 method for class 'mm'
AIC(object, ...)
## S3 method for class 'mmfit'
AIC(object, ...)

## S3 method for class 'smmparametric'
BIC(object, ...)
## S3 method for class 'smmnonparametric'
BIC(object, ...)
## S3 method for class 'smmfit'
BIC(object, ...)
## S3 method for class 'mm'
BIC(object, ...)
## S3 method for class 'mmfit'
BIC(object, ...)

Arguments

object

An object of S3 class mm, mmfit, smm (smmparametric or smmnonparametric) or smmfit.

...

The argument sequences: a list of vectors representing the sequences for which the log-likelihood is computed (named ⁠sequences = ⁠ or given as the first unnamed argument). Required for the models specified by the user, optional for the fitted models.

Details

Notation (see smmR-package for the complete description of the models): \mathcal{L} is the likelihood, K the number of parameters of the model (see get.Kpar), n the total length of the sequences and s = \textrm{card}(E).

The log-likelihood \log \mathcal{L} is computed on the sequences given in the argument sequences. For a fitted model (class mmfit or smmfit), this argument is optional: by default, the value computed at the estimation, on the sequences used for the estimation, is returned. The information criteria are

AIC = -2 \log \mathcal{L} + 2 K, \qquad BIC = -2 \log \mathcal{L} + \log(n)\, K,

where K is the number of parameters of the model (see get.Kpar) and n the total length of the sequences.

Value

A numeric value: the log-likelihood, the AIC or the BIC.

References

V. S. Barbu, N. Limnios. (2008). Semi-Markov Chains and Hidden Semi-Markov Models Toward Applications - Their Use in Reliability and DNA Analysis. New York: Lecture Notes in Statistics, vol. 191, Springer.

See Also

get.Kpar, fitsmm, fitmm

Examples

states <- c("a", "c", "g", "t")
pij <- matrix(c(0, 0.2, 0.5, 0.3,
                0.2, 0, 0.3, 0.5,
                0.3, 0.5, 0, 0.2,
                0.4, 0.2, 0.4, 0), ncol = 4, byrow = TRUE)
x <- smmparametric(states = states, init = rep(1/4, 4), ptrans = pij,
                   type.sojourn = "f", distr = "pois", param = c(2, NA))
seqs <- simulate(x, nsim = 5000, seed = 150)
est <- fitsmm(sequences = seqs, states = states, type.sojourn = "f",
              distr = "pois")

# Fitted model: value at the estimation
logLik(est)
AIC(est)
BIC(est)

# Model specified by the user: the sequences must be given
logLik(x, sequences = seqs)
AIC(x, sequences = seqs)


smmR documentation built on Nov. 28, 2026, 1:06 a.m.