View source: R/CoxTermsearch.R
| extract_CoxTermsearch | R Documentation |
This is a function to extract log HR based on the resuls from CoxTermsearch
extract_CoxTermsearch(fit, lag, latency, knots)
fit |
A model from CoxKnotsearch |
lag |
A lag time, or a vector of lag times |
latency |
prespecified latency |
knots |
A vector of prespecified knots |
A data frame with one row per lag, giving the estimated log HR at each lag time
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.