Method to fit a static model corresponding to a ddhazard
fit.
The method uses weights to ease the memory requirements. See
get_survival_case_weights_and_data
for details on weights.
The parallelglm_quick
and parallelglm_QR
methods are similar
to two methods used in bam
function in the mgcv
package (see
the `use.chol`
argument or Wood et al. 2015). parallelglm_QR
is more stable but slower. See Golub (2013) section 5.3 for a comparison of
the Cholesky decomposition method and the QR method.
static_glm(
formula,
data,
by,
max_T,
...,
id,
family = "logit",
model = FALSE,
weights,
risk_obj = NULL,
speedglm = FALSE,
only_coef = FALSE,
mf,
method_use = c("glm", "speedglm", "parallelglm_quick", "parallelglm_QR"),
n_threads = getOption("ddhazard_max_threads")
)
The returned list from the glm
call or just coefficients depending on the value of only_coef
.
coxph
like formula with Surv(tstart, tstop, event)
on the left hand site of ~
.
data.frame
or environment containing the outcome and covariates.
interval length of the bins in which parameters are fixed.
end of the last interval interval.
arguments passed to glm
or speedglm
. If only_coef = TRUE
then the arguments are passed to glm.control
if glm
is used.
vector of ids for each row of the in the design matrix.
"logit"
, "cloglog"
, or "exponential"
for a static equivalent model of ddhazard
.
TRUE
if you want to save the design matrix used in glm
.
weights to use if e.g. a skewed sample is used.
a pre-computed result from a get_risk_obj
. Will be used to skip some computations.
depreciated.
TRUE
if only coefficients should be returned. This will only call the speedglm::speedglm.wfit
or glm.fit
which will be faster.
model matrix for regression. Needed when only_coef = TRUE
method to use for estimation. glm
uses glm.fit
, speedglm::speedglm
uses speedglm::speedglm.wfit
and parallelglm_quick
and parallelglm_QR
uses a parallel C++
estimation method.
number of threads to use when method_use
is "parallelglm"
.
Wood, S.N., Goude, Y. & Shaw S. (2015) Generalized additive models for large datasets. Journal of the Royal Statistical Society, Series C 64(1): 139-155.
Golub, G. H., & Van Loan, C. F. (2013). Matrix computations (4th ed.). JHU Press.
library(dynamichazard)
fit <- static_glm(
Surv(time, status == 2) ~ log(bili), pbc, id = pbc$id, max_T = 3600,
by = 50)
fit$coefficients
Run the code above in your browser using DataLab