View source: R/getCrudeAndAdjustedModelData.R
getCrudeAndAdjustedModelData | R Documentation |
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 class 'getCrudeAndAdjustedModelData'
x[i, j, ...]
model |
The regression model |
level |
The confidence interval level |
remove_interaction_vars |
Removes the interaction terms as they in the raw state are difficult to understand |
remove_strata |
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_cluster |
Cluster information should most likely also retain
just as the |
var_select |
A vector with regular expressions for choosing what variables
to return (the same format as for the |
... |
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
\beta
to display. For the same reason it skips any interaction variables since it's probably better to display these as a contrast table.
Note that the rms regression has a separate function that uses the rms:::summaryrms
function
that returns a matrix that is then pruned.
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.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.