fit1ts {TwoTimeScales} | R Documentation |
Fit a smooth hazard model with one time scale
Description
fit1ts()
fits a smooth hazard model with one time scale.
Three methods are implemented for the search of the optimal smoothing
parameter (and therefore optimal model): a numerical optimization of the
AIC or BIC of the model, a search for the minimum AIC or BIC of the
model over a grid of \log_{10}
values for the smoothing parameter and the
estimation using a sparse mixed model representation of P-splines.
Construction of the B-splines basis and of the penalty matrix is
incorporated within the function. If a matrix of covariates is provided,
the function will estimate a model with covariates.
Usage
fit1ts(
data1ts = NULL,
y = NULL,
r = NULL,
Z = NULL,
bins = NULL,
Bbases_spec = list(),
Wprior = NULL,
pord = 2,
optim_method = c("ucminf", "grid_search", "LMMsolver"),
optim_criterion = c("aic", "bic"),
lrho = 0,
ridge = 0,
control_algorithm = list(),
par_gridsearch = list()
)
Arguments
data1ts |
(optional) an object created by the function
|
y |
A vector of event counts of length ns, or an array of dimension ns by n. |
r |
A vector of exposure times of length ns, or an array of dimension ns by n. |
Z |
(optional) A regression matrix of covariates of dimension n by p. |
bins |
a list with the specification for the bins. This is created by
the function |
Bbases_spec |
A list with the specification for the B-splines basis with the following elements:
|
Wprior |
An optional vector of a-priori weights. |
pord |
The order of the penalty. Default is 2. |
optim_method |
The method to be used for optimization:
|
optim_criterion |
The criterion to be used for optimization:
|
lrho |
A number if |
ridge |
A ridge penalty parameter: default is 0. |
control_algorithm |
A list with optional values for the parameters of the iterative processes:
|
par_gridsearch |
A list of parameters for the grid_search:
|
Details
Some functions from the R-package LMMsolver
are used here.
We refer the interested readers to https://biometris.github.io/LMMsolver/
for more detail on LMMsolver
and its usage.
Value
An object of class haz1ts
, or of class haz1tsLMM
.
For objects of class haz1ts
this is
-
optimal_model
A list with:-
alpha
The vector of estimated P-splines coefficients of lengthcs
. -
SE_alpha
The vector of estimated Standard Errors for thealpha
coefficients, of lengthcs
. -
beta
The vector of estimated covariate coefficients of lengthp
(if model with covariates). -
se_beta
The vector of estimated Standard Errors for thebeta
coefficients of lengthp
(if model with covariates). -
eta
oreta0
. The vector of values of the (baseline) linear predictor (log-hazard) of lengthns
. -
H
The hat-matrix. -
Cov
The full variance-covariance matrix. -
deviance
The deviance. -
ed
The effective dimension of the model. -
aic
The value of the AIC. -
bic
The value of the BIC. -
Bbases
a list with the B-spline basisBs
(this is a list for compatibility with functions in 2d).
-
-
optimal_logrho
The optimal value oflog10(rho_s)
. -
P_optimal
The optimal penalty matrix P. -
AIC
(ifpar_gridsearch$return_aic == TRUE
) The vector of AIC values. -
BIC
(ifpar_gridsearch$return_bic == TRUE
) The vector of BIC values.
Objects of class haz1tsLMM
have a slight different structure. They are
a list with:
-
optimal_model
an object of classLMMsolve
-
AIC_BIC
a list with, among other things, the AIC and BIC values and the ED of the model -
n_events
the number of events -
ns
the number of bins over the s-axis -
cs
the number of B-splines over the s-axis -
covariates
an indicator for PH model
References
Boer, Martin P. 2023. “Tensor Product P-Splines Using a Sparse Mixed Model Formulation.” Statistical Modelling 23 (5-6): 465–79. https://doi.org/10.1177/1471082X231178591.#'
Examples
## preparing data - no covariates
dt1ts <- prepare_data(data = reccolon2ts,
s_in = "entrys",
s_out = "timesr",
events = "status",
ds = 180)
## fitting the model with fit1ts() - default options, that is ucminf optimization
mod1 <- fit1ts(dt1ts)
## fitting with LMMsolver
mod2 <- fit1ts(dt1ts,
optim_method = "LMMsolver")
## preparing the data - covariates
dt1ts_cov <- prepare_data(data = reccolon2ts,
s_in = "entrys",
s_out = "timesr",
events = "status",
ds = 180,
individual = TRUE,
covs = c("rx", "node4", "sex"))
## fitting the model with fit1ts() - grid search over only two log_10(rho_s) values
mod3 <- fit1ts(dt1ts_cov,
optim_method = "grid_search",
lrho = c(1, 1.5))