get.Kpar: Number of parameters of a Markov or semi-Markov model

View source: R/allgenerics.R

get.KparR Documentation

Number of parameters of a Markov or semi-Markov model

Description

Returns the number of parameters of a Markov or semi-Markov model, used in the computation of the information criteria AIC and BIC (see logLik.smm).

Usage

get.Kpar(x)

Arguments

x

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

Details

Notation (see smmR-package for the complete description of the models): s = \textrm{card}(E) is the number of states, k the order of a Markov chain and k_{max} the maximal sojourn time of a nonparametric semi-Markov model.

The number of parameters is:

  • Markov chain of order k (mm, mmfit): the number of free transition probabilities, (s - 1) s^k;

  • parametric semi-Markov model (smmparametric): the number of parameters of the sojourn time distributions, i.e. the sum over the distributions of distr of 1 ("geom", "pois", "unif") or 2 ("nbinom", "dweibull");

  • nonparametric semi-Markov model (smmnonparametric) with maximal sojourn time k_{max}: s (s - 2) (k_{max} - 1) for "fij", s (k_{max} - 1) for "fi" and "fj", and k_{max} - 1 for "f".

Value

A positive integer giving the number of parameters.

See Also

logLik.smm, mm, smmparametric, smmnonparametric

Examples

# Markov chain of order 2 on 2 states: (2 - 1) * 2^2 = 4 parameters
x <- mm(states = c("a", "b"), init = rep(1/4, 4), k = 2,
        ptrans = matrix(c(0.9, 0.1, 0.5, 0.5, 0.2, 0.8, 0.3, 0.7),
                        nrow = 4, byrow = TRUE))
get.Kpar(x)

# Parametric semi-Markov model: geom (1) + pois (1) + dweibull (2) = 4
ptrans <- matrix(c(0, 0.6, 0.4,
                   0.5, 0, 0.5,
                   0.7, 0.3, 0), nrow = 3, byrow = TRUE)
param <- matrix(c(0.3, 2, 0.6,
                  NA, NA, 0.8), nrow = 3)
y <- smmparametric(states = c("a", "b", "c"), init = c(1/3, 1/3, 1/3),
                   ptrans = ptrans, type.sojourn = "fi",
                   distr = c("geom", "pois", "dweibull"), param = param)
get.Kpar(y)


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