Description Usage Arguments Details Value See Also Examples
View source: R/zero_matrix_trans.R
Create a structural zero matrix representing showing, permissible transitions between states, where, typically, many transitions are prohibited. Examples include transitions between marital statuses or between health statuses.
1 | zero_matrix_trans(trans, basename = "state")
|
trans |
A named list. |
basename |
Prefix used to construct dimension
names. Defaults to |
trans
is a named list. The names of the list
give the origin states, and the elements of the list
are character vectors with the destination states:
see below for examples.
If an origin state has no destination states (ie it is
an "absorbing" state), then the list element for that
origin can be a zero-length character vector, or
NULL
.
Transitions from a state to itself are allowed: a
an element of trans
can include its own name.
A square matrix of TRUE
s and FALSE
s,
with dimnames constructed from nest
.
zero_matrix_diag
deals with a common
special case.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | trans <- list(Single = c("Married", "Separated"),
Married = "Separated",
Separated = "Married")
zero_matrix_trans(trans)
zero_matrix_trans(trans, basename = "marital_status")
trans <- list(Primary = c("Primary", "Secondary"), # transition to self
Secondary = c("Secondary", "Tertiary"), # transition to self
Tertiary = "Tertiary") # transition to self
zero_matrix_trans(trans)
trans <- list(Healthy = c("Sick", "Dead"),
Sick = c("Healthy", "Dead"),
Dead = NULL) # absorbing state
zero_matrix_trans(trans)
trans <- list(Healthy = c("Sick", "Dead"),
Sick = c("Healthy", "Dead"),
Dead = character()) # character rather than NULL
zero_matrix_trans(trans)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.