tpm_g: Build all transition probability matrices of an inhomogeneous HMM
Description
In an HMM, we can model the influence of covariates on the state process, by linking them to the transition probabiltiy matrix.
Most commonly, this is done by specifying a linear predictor
for each off-diagonal element (\(i \neq j\)) and then applying the inverse multinomial logistic link to each row.
This function efficiently calculates all transition probabilty matrices for a given design matrix \(Z\) and parameter matrix beta.
Usage
tpm_g(Z, beta, byrow = FALSE)
Value
Array of transition probability matrices of dimension c(N,N,n)
Arguments
Z
Covariate design matrix (excluding intercept column) of dimension c(n, p), where p can also be one (i.e. Z can be a vector).
beta
Matrix of coefficients for the off-diagonal elements of the transition probability matrix.
Needs to be of dimension c(N*(N-1), p+1), where the first column contains the intercepts.
byrow
Logical that indicates if each transition probability matrix should be filled by row.
Defaults to FALSE, but should be set to TRUE if one wants to work with a matrix of beta parameters returned by popular HMM packages like moveHMM, momentuHMM, or hmmTMB.