Store the parameters of a fitted multinomial logistic
regression model. The model is used to predict probabilities of \(K\)
classes, which represent the probability of transitioning to particular health
state in a discrete time state transition model. Can be used as an element of a
params_mlogit_list to parameterize a CohortDtstmTrans object.
params_mlogit(coefs)A 3D array of stacked matrices containing samples of the regression
coefficients under sampling uncertainty. May also be a
list of objects (e.g., data frames) that can be coerced into matrices with
as.matrix(). Each matrix must have the same number of columns and the
number of matrices must be equal to \(K-1\).
An object of class params_mlogit, which is a list containing coefs
and n_samples, where n_samples is equal to the number of rows in each
element of coefs. The coefs element is always converted into
a 3D array of stacked matrices.
Multinomial logit models are used to predict the probability of membership for subject \(i\) in each of \(K\) classes as a function of covariates: $$Pr(y_i = c) = \frac{e^{\beta_c x_i}}{\sum_{k=1}^K e^{\beta_k x_i}}$$
# Consider a sick-sicker model and model transitions from the sick state
## We can instantiate from a list of data frames
params <- params_mlogit(
coefs = list(
### Transition from sick to sicker
sicker = data.frame(
intercept = c(-0.33, -.2, -.15),
treat = c(log(.75), log(.8), log(.9))
),
### Transition from sick to death
death = data.frame(
intercept = c(-1, -1.2, -.5),
treat = c(log(.6), log(.65), log(.55))
)
)
)
summary(params)
#> to term mean sd 2.5% 97.5%
#> <char> <char> <num> <num> <num> <num>
#> 1: sicker intercept -0.2266667 0.09291573 -0.3235000 -0.1525000
#> 2: sicker treat -0.2053954 0.09244748 -0.2844551 -0.1112497
#> 3: death intercept -0.9000000 0.36055513 -1.1900000 -0.5250000
#> 4: death treat -0.5131485 0.08355126 -0.5934864 -0.4347851
params
#> A "params_mlogit" object
#>
#> Summary of coefficients:
#> to term mean sd 2.5% 97.5%
#> <char> <char> <num> <num> <num> <num>
#> 1: sicker intercept -0.2266667 0.09291573 -0.3235000 -0.1525000
#> 2: sicker treat -0.2053954 0.09244748 -0.2844551 -0.1112497
#> 3: death intercept -0.9000000 0.36055513 -1.1900000 -0.5250000
#> 4: death treat -0.5131485 0.08355126 -0.5934864 -0.4347851
#>
#> Number of parameter samples: 3
#> Number of transitions: 2
## We can also instantiate from an array
coefs_sicker <- data.frame(
intercept = c(-0.33, -.2, -.15),
treat = c(log(.75), log(.8), log(.9))
)
coefs_death <- data.frame(
intercept = c(-1, -1.2, -.5),
treat = c(log(.6), log(.65), log(.55))
)
params2 <- params_mlogit(
coefs <- array(
data = c(as.matrix(coefs_sicker),
as.matrix(coefs_death)),
dim = c(3, 2, 2),
dimnames = list(NULL, c("intercept", "treat"), c("sicker", "death"))
)
)
params2
#> A "params_mlogit" object
#>
#> Summary of coefficients:
#> to term mean sd 2.5% 97.5%
#> <char> <char> <num> <num> <num> <num>
#> 1: sicker intercept -0.2266667 0.09291573 -0.3235000 -0.1525000
#> 2: sicker treat -0.2053954 0.09244748 -0.2844551 -0.1112497
#> 3: death intercept -0.9000000 0.36055513 -1.1900000 -0.5250000
#> 4: death treat -0.5131485 0.08355126 -0.5934864 -0.4347851
#>
#> Number of parameter samples: 3
#> Number of transitions: 2