extract_CoxTermsearch: This is a function to extract log HR based on the resuls from...

View source: R/CoxTermsearch.R

extract_CoxTermsearchR Documentation

This is a function to extract log HR based on the resuls from CoxTermsearch

Description

This is a function to extract log HR based on the resuls from CoxTermsearch

Usage

extract_CoxTermsearch(fit, lag, latency, knots)

Arguments

fit

A model from CoxKnotsearch

lag

A lag time, or a vector of lag times

latency

prespecified latency

knots

A vector of prespecified knots

Value

A data frame with one row per lag, giving the estimated log HR at each lag time

Examples

time_start <- "age_start"
time_end <- "age_end"
status <- "failure"
exposure <- paste0("lag", 0:19)
knots <- seq(0, 15, by = 3)
latency <- 20
fit <- CoxTermsearch(sim_data, time_start, time_end, status, exposure, knots = knots, latency)
extract_CoxTermsearch(fit, 10, latency = latency, knot = knots)
extract_CoxTermsearch(fit, c(0, 5, 10), latency = latency, knot = knots)
#In this example, we will generate a random covariate L and adjust for it in our model
sim_data$L <- rbinom(nrow(sim_data), 1, 0.5)
adjusted_variable <- "L"
adjusted_model <- "L+I(L^2)"
fit <- CoxTermsearch(sim_data, time_start, time_end, status, exposure, knots = knots, latency,
adjusted_variable = adjusted_variable, adjusted_model = adjusted_model)
#L is selected into the final model but L^2 was not
extract_CoxTermsearch(fit, 10, latency = latency, knot = knots)

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