dynamichazard (version 0.6.0)

static_glm: Static glm Fit

Description

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.

Usage

static_glm(formula, data, by, max_T, ..., id, family = "logit", model = F,
  weights, risk_obj = NULL, speedglm = F, only_coef = FALSE, mf,
  method_use = c("glm", "speedglm", "parallelglm_quick", "parallelglm_QR"),
  n_threads = getOption("ddhazard_max_threads"))

Arguments

formula

coxph like formula with Surv(tstart, tstop, event) on the left hand site of ~.

data

data.frame or environment containing the outcome and covariates.

by

interval length of the bins in which parameters are fixed.

max_T

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.

id

vector of ids for each row of the in the design matrix.

family

"logit" or "exponential" for a static equivalent model of ddhazard.

model

TRUE if you want to save the design matrix used in glm.

weights

weights to use if e.g. a skewed sample is used.

risk_obj

a pre-computed result from a get_risk_obj. Will be used to skip some computations.

speedglm

depreciated.

only_coef

TRUE if only coefficients should be returned. This will only call the speedglm::speedglm.wfit or glm.fit which will be faster.

mf

model matrix for regression. Needed when only_coef = TRUE

method_use

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.

n_threads

number of threads to use when method_use is "parallelglm".

Value

The returned list from the glm call or just coefficients depending on the value of only_coef.

References

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.

Examples

Run this code
# NOT RUN {
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 DataCamp Workspace