Recipe function for creating regime switching (Markov transition) functions

1 | ```
prep.regimes(values, params, covariates, deviation = FALSE, refRow)
``` |

`values` |
matrix giving the values. Should have (number of Regimes) rows and (number of regimes x number of covariates) columns |

`params` |
matrix of the same size as "values" consisting of the names of the parameters |

`covariates` |
a vector of the names of the covariates to be used in the regime-switching functions |

`deviation` |
logical. Whether to use the deviation form or not. See Details. |

`refRow` |
numeric. Which row is treated at the reference. See Details. |

Note that each row of the transition probability matrix must sum to one. To accomplish this fix at least one transition log odds parameter in each row of "values" (including its intercept and the regression slopes of all covariates) to 0.

When `deviation=FALSE`

, the non-deviation form of the multinomial logistic regression is used. This form has a separate intercept term for each entry of the transition probability matrix (TPM). When `deviation=TRUE`

, the deviation form of the multinomial logistic regression is used. This form has an intercept term that is common to each column of the TPM. The rows are then distinguished by their own individual deviations from the common intercept. The deviation form requires the same reference column constraint as the non-deviation form; however, the deviation form also requires one row to be indicated as the reference row (described below). By default the reference row is taken to be the same as the reference column.

The `refRow`

argument determines which row is used as the intercept row. It is only
used in the deviation form (i.e. `deviation=TRUE`

). In the deviation form, one row of `values`

and `params`

contains the intercepts, other rows contain deviations from these intercepts. The `refRow`

argument says which row contains the intercept terms. The default behavior for `refRow`

is to be the same as the reference column. The reference column is automatically detected. If we have problems detecting which is the reference column, then we provide error messages that are as helpful as we can make them.

1 2 3 4 5 6 7 8 9 10 11 12 | ```
#Regime-switching with no covariates (self-transition ID)
b <- prep.regimes(values=matrix(0, 3, 3),
params=matrix(c(0, 'p1', 'p2', 'p3', 0, 'p4', 'p5', 'p6', 0), 3, 3))
#Regime switching with no covariates (second regime ID)
b <- prep.regimes(values=matrix(0, 3, 3),
params=matrix(c('p1', 'p2', 'p3', 0, 0, 0, 'p4', 'p5', 'p6'), 3, 3))
#2 regimes with three covariates
b <- prep.regimes(values=matrix(c(0), 2, 8),
params=matrix(c(paste0('p', 8:15), rep(0, 8)), 2, 8),
covariates=c('x1', 'x2', 'x3'))
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.