View source: R/CoxKnotSearch.R
| CoxKnotsearch | R Documentation |
This function implments GridSearch of natural cubic splines in Cox regression for latency analysis This is GreadSearching by knots
CoxKnotsearch(
data,
time_start,
time_end,
status,
exposure,
knots_number,
latency,
adjusted_variable = NULL,
adjusted_model = NULL,
criteria = "AIC"
)
data |
A data frame containing the data |
time_start |
start time |
time_end |
end time |
status |
survival status. 1 for death and 0 for censored |
exposure |
Name of the time-varying exposure variable. From the most recent to the furthest in time. |
knots_number |
A vector of potential number of knots |
latency |
pre-specified latency |
adjusted_variable |
A vector of adjusted variables |
adjusted_model |
A vector of adjusted models |
criteria |
A string to specify the criteria for model selection. It can be either "AIC" or "BIC". The default is "AIC" |
A list. The first element is the best knots with the lowest AIC. The second element is a Cox model
time_start <- "age_start"
time_end <- "age_end"
status <- "failure"
exposure <- paste0("lag", 0:19)
# knots can be set as as a vector of potential number of knots, here we use 3 to save time
knots_number <- c(3)
latency <- 20
fit <- CoxKnotsearch(sim_data, time_start, time_end, status, exposure, knots_number, latency)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.