Skip to contents

Computes the "effective coefficients" matrix for a fitted ordinal model. For vglm objects, this matrix combines the raw coefficients with the constraint matrices. For orm objects, threshold coefficients are stored in the intercept column and slope coefficients are replicated across thresholds. In both cases this allows fast linear predictor calculation via simple matrix multiplication with the "small" design matrix.

Usage

get_effective_coefs(model, beta = NULL)

Arguments

model

A fitted vglm or orm object.

beta

Optional coefficient vector to use instead of coef(model). This is used internally for simulation draws.

Value

A matrix \(\Gamma\) with dimensions \(L \times q\), where \(L\) is the number of linear predictors (\(K - 1\) for an ordinal model with \(K\) states) and \(q\) is the number of columns in the small design matrix, including its intercept column.

Details

Let \(\beta\) contain all model coefficients. For small-design column \(j = 1,\ldots,q\), let \(C_j\) be its \(L \times p_j\) constraint matrix and \(\beta_j\) its block of \(p_j\) coefficients from \(\beta\). The complete coefficient count is \(p = \sum_{j=1}^q p_j\). The contribution to the column vector of linear predictors \(\eta\) is \(x_j C_j \beta_j\), where \(x_j\) is that design-column value. This function calculates \(\Gamma_j = C_j \beta_j\) and places this length-\(L\) vector in column \(j\) of \(\Gamma\). For orm models, only full proportional odds models are supported, so each slope coefficient contributes equally to every threshold-specific linear predictor.

For a new observation with length-\(q\) design row \(\mathbf{x}\), prediction is \(\eta = \Gamma \mathbf{x}^\top\), where \(\top\) denotes transpose. The dimensions are \((L \times q)(q \times 1)\).

Examples

trial <- sim_markov("actt2", n_patients = 40, follow_up_time = 6, seed = 1)
markov_data <- prepare_markov_data(trial, absorbing_state = 8)
fit <- rms::orm(
  y ~ time + tx + yprev,
  data = markov_data,
  x = TRUE,
  y = TRUE,
  opt_method = "LM",
  scale = TRUE
)

effective <- get_effective_coefs(fit)
dim(effective)
#> [1] 6 9