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