
Last chance! 50% off unlimited learning
Sale ends in
This function is used for getting the adjusted and unadjusted values
for a regression model. It takes a full model and walks through each
variable, removes in the regression all variables except one then
reruns that variable to get the unadjusted value. This functions not
intended for direct use, it's better to use printCrudeAndAdjustedModel()
that utilizes this function.
getCrudeAndAdjustedModelData(
model,
level = 0.95,
remove_interaction_vars = TRUE,
remove_strata = FALSE,
remove_cluster = FALSE,
var_select,
...
)# S3 method for getCrudeAndAdjustedModelData
[(x, i, j, ...)
Returns a matrix with the columns:
c("Crude", "2.5 %", "97.5 %", "Adjusted", "2.5 %", "97.5 %")
.
The row order is not changed from the original model. The percentages can vary depending
on the set level.
The regression model
The confidence interval level
Removes the interaction terms as they in the raw state are difficult to understand
Strata should most likely not be removed in the crude
version. If you want to force the removal of stratas you can specify the
remove_strata = TRUE
Cluster information should most likely also retain
just as the remove_strata
option. Clusters are sometimes used in
cox regression models, cluster()
A vector with regular expressions for choosing what variables
to return (the same format as for the order
argument in
printCrudeAndAdjustedModel()
call). It can be useful when working with
large datasets only to report a subsection of all tested variables. This
makes the function both run faster and the data presentation more concise.
Not used
This function saves a lot of time creating tables since it compiles a fully unadjusted list of all your used covariates.
If the model is an exponential poisson/logit/cox regression model then it automatically reports the exp() values instead of the original values
The function skips by default all spline variables since this becomes very complicated
and there is no simple
Note that the rms regression has a separate function that uses the rms:::summaryrms
function
that returns a matrix that is then pruned.
printCrudeAndAdjustedModel()
Other crudeAndAdjusted functions:
printCrudeAndAdjustedModel()
# simulated data to use
set.seed(10)
ds <- data.frame(
ftime = rexp(200),
fstatus = sample(0:1, 200, replace = TRUE),
x1 = runif(200),
x2 = runif(200),
x3 = runif(200),
x4 = runif(200),
x5 = runif(200)
)
library(rms)
dd <- datadist(ds)
options(datadist = "dd")
s <- Surv(ds$ftime, ds$fstatus == 1)
fit <- cph(s ~ x1 + x2 + x3, data = ds)
data_matrix <- getCrudeAndAdjustedModelData(fit)
print(data_matrix)
# If we have interaction then those variable are not
# reported
fit <- cph(s ~ x1 + x2 + x3 + x4 * x5, data = ds)
data_matrix <- getCrudeAndAdjustedModelData(fit)
print(data_matrix)
Run the code above in your browser using DataLab