View source: R/CoxKnotSearch.R
| CoxKnotsearch_boot | R Documentation |
This function conduct bootstraps for @CoxKnotsearch
CoxKnotsearch_boot(
data,
time_start,
time_end,
status,
exposure,
knots_number,
latency,
adjusted_variable = NULL,
adjusted_model = NULL,
lag,
parallel = FALSE,
parallel_plan = c("multicore", "multisession"),
boot_iter = 10,
id = "id",
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 prespecified knot number |
latency |
prespecified latency |
adjusted_variable |
A vector of adjusted variables |
adjusted_model |
A vector of adjusted models |
lag |
A value of lag time |
parallel |
A boolean numeric to indicate whether to run the function in parallel |
parallel_plan |
A string to specify the future plan used when parallel = TRUE. It can be either "multicore" or "multisession". The default is "multicore" |
boot_iter |
Number of bootstrap iterations |
id |
A string of the column name that contains the subject ID |
criteria |
A string to specify the criteria for model selection. It can be either "AIC" or "BIC". The default is "AIC" |
A data.frame. The first column is the mean of log HR. The second column is the variance of log HR, the third and fourth columns are the 2.5 and 97.5 percentiles of log HR if parallel = TRUE
time_start <- "age_start"
time_end <- "age_end"
status <- "failure"
exposure <- paste0("lag", 0:15)
# 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 <- 16
adjusted_variable <- "L"
adjusted_model <- "L"
lag <- 2
boot_iter <- 2
id <- "id"
# use a subset of subjects to keep the example fast
ids <- unique(sim_data$id)[1:300]
small_data <- sim_data[sim_data$id %in% ids, ]
result <- CoxKnotsearch_boot(small_data, time_start, time_end, status,
exposure, knots_number = knots_number, latency,
lag = lag, parallel = FALSE, boot_iter = boot_iter, id = id)
# the bootstrap can also be run in parallel
result <- CoxKnotsearch_boot(small_data, time_start, time_end, status,
exposure, knots_number = knots_number, latency,
lag = lag, parallel = TRUE, boot_iter = boot_iter, id = id)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.