CoxTermsearch_boot: This function conduct bootstraps for @CoxTermsearch

View source: R/CoxTermsearch.R

CoxTermsearch_bootR Documentation

This function conduct bootstraps for @CoxTermsearch

Description

This function conduct bootstraps for @CoxTermsearch

Usage

CoxTermsearch_boot(
  data,
  time_start,
  time_end,
  status,
  exposure,
  knots,
  latency,
  adjusted_variable = NULL,
  adjusted_model = NULL,
  lag,
  parallel = FALSE,
  parallel_plan = c("multicore", "multisession"),
  boot_iter = 10,
  id = "id",
  criteria = "AIC"
)

Arguments

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

A vector of prespecified knots

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"

Value

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

Examples

time_start <- "age_start"
time_end <- "age_end"
status <- "failure"
exposure <- paste0("lag", 0:15)
knots <- seq(0, 15, by = 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 <- CoxTermsearch_boot(small_data, time_start, time_end,
status, exposure, knots = knots, latency,
lag = lag, parallel = FALSE, boot_iter = boot_iter, id = id)

# the bootstrap can also be run in parallel
result <- CoxTermsearch_boot(small_data, time_start, time_end,
status, exposure, knots = knots, latency,
lag = lag, parallel = TRUE, boot_iter = boot_iter, id = id)


LatencyA documentation built on Oct. 21, 2026, 5:14 p.m.