Build all embedded transition probability matrices of an inhomogeneous HSMM
tpm_emb_g.Rd
Hidden semi-Markov models are defined in terms of state durations and an embedded transition probability matrix that contains the conditional transition probabilities given that the current state is left. This matrix necessarily has diagonal entries all equal to zero as self-transitions are impossible. We can allow this matrix to vary with covariates, which is the purpose of this function.
It builds all embedded/ conditional transition probability matrices based on a design and parameter matrix. For each row of the matrix, the inverse multinomial logistic link is applied.
For a matrix of dimension c(N,N), the number of free off-diagonal elements is N*(N-2) which determines the number of rows of the parameter matrix.
Compatible with automatic differentiation by RTMB
Arguments
- Z
covariate design matrix with or without intercept column, i.e. of dimension c(n, p) or c(n, p+1)
If
Z
has only p columns, an intercept column of ones will be added automatically.- beta
matrix of coefficients for the off-diagonal elements of the embedded transition probability matrix
Needs to be of dimension c(N*(N-2), p+1), where the first column contains the intercepts. p can be 0, in which case the model is homogeneous.
- report
logical, indicating whether the coefficient matrix beta should be reported from the fitted model. Defaults to
TRUE
.