weibull_glm_weight_function {lgspline} | R Documentation |
Weibull GLM Weight Function for Constructing Information Matrix
Description
Computes diagonal weight matrix \textbf{W}
for the information matrix
\textbf{G} = (\textbf{X}^{T}\textbf{W}\textbf{X} + \textbf{L})^{-1}
in Weibull accelerated failure time (AFT) models.
Usage
weibull_glm_weight_function(
mu,
y,
order_indices,
family,
dispersion,
observation_weights,
status
)
Arguments
mu |
Predicted survival times |
y |
Observed response/survival times |
order_indices |
Order of observations when partitioned to match "status" to "response" |
family |
Weibull AFT family |
dispersion |
Estimated dispersion parameter ( |
observation_weights |
Weights of observations submitted to function |
status |
Censoring indicator (1 = event, 0 = censored) Indicates whether an event of interest occurred (1) or the observation was right-censored (0). In survival analysis, right-censoring occurs when the full survival time is unknown, typically because the study ended or the subject was lost to follow-up before the event of interest occurred. |
Details
This function generates weights used in constructing the information matrix
after unconstrained estimates have been found. Specifically, it is used in
the construction of the \textbf{U}
and \textbf{G}
matrices following initial unconstrained
parameter estimation.
These weights are analogous to the variance terms in generalized linear
models (GLMs). Like logistic regression uses \mu(1-\mu)
, Poisson regression uses
e^{\mu}
, and Linear regression uses constant weights, Weibull AFT models use
\exp((\log y - \log \mu)/s)
where s
is the scale (= \sqrt{\text{dispersion}}
) parameter.
Value
Vector of weights for constructing the diagonal weight matrix \textbf{W}
in the information matrix \textbf{G} = (\textbf{X}^{T}\textbf{W}\textbf{X} + \textbf{L})^{-1}
.
Examples
## Demonstration of glm weight function in constrained model estimation
set.seed(1234)
n <- 1000
t1 <- rnorm(n)
t2 <- rbinom(n, 1, 0.5)
## Generate survival times
lambda <- exp(0.5 * t1 + 0.3 * t2)
yraw <- rexp(n, rate = 1/lambda)
## Introduce right-censoring
status <- rbinom(n, 1, 0.75)
y <- ifelse(status, yraw, runif(1, 0, yraw))
## Fit model demonstrating use of custom glm weight function
model_fit <- lgspline(y ~ spl(t1) + t2,
data.frame(y = y, t1 = t1, t2 = t2),
unconstrained_fit_fxn = unconstrained_fit_weibull,
family = weibull_family(),
need_dispersion_for_estimation = TRUE,
dispersion_function = weibull_dispersion_function,
glm_weight_function = weibull_glm_weight_function,
shur_correction_function = weibull_shur_correction,
status = status,
opt = FALSE,
K = 1)
print(summary(model_fit))