Skip to content

Using a covariate only for one of the transition probabilities #26

Answered by TheoMichelot
RonEfrat asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, yes this is possible. You can specify the formula argument of MarkovChain$new() as a matrix, where each entry is the formula corresponding to a transition probability.

  • The formulas in the matrix should be strings, e.g., "~x1", or "~ x1 * x2". The mgcv formula syntax for non-linear and random effects uses quotes, and those should be written as single quotes here, e.g., "~s(ID, bs = 're')".

  • The diagonal entries should be "." because diagonal transition probabilities are not estimated so they can't have a formula.

Here is an example with a dummy data set, just to illustrate the syntax.

library(hmmTMB)

data <- data.frame(x1 = rnorm(1000))

# Include effect of x1 on Pr(1 > 2) but no…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@RonEfrat
Comment options

Answer selected by RonEfrat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants