View source: R/add_riskscore.R
add_riskscore | R Documentation |
This function computes a risk score for each observation in the dataset based on the provided Cox proportional hazards model or logistic regression.
add_riskscore(
input,
family = "cox",
target = NULL,
time = NULL,
status = NULL,
vars,
new_var_name = "riskscore"
)
input |
A data frame containing the data to be analyzed. |
family |
A character string specifying whether to use "cox" for Cox regression or "binary" for logistic regression. Defaults to "cox". |
target |
The name of the target variable (only used if family = "binary"). |
time |
The name of the time to event variable (only used if family = "cox"). |
status |
The name of the event status variable (only used if family = "cox"). |
vars |
A vector of variable names to include in the model. |
new_var_name |
The name of the new variable to be created for storing risk scores. Defaults to "riskscore". |
The input data frame with an additional column containing the risk scores.
Dongqiang Zeng
data(ovarian)
ovarian$rscore <- add_riskscore(ovarian, time = "time", status = "status", vars=c("resid.ds", "rx", "ecog.ps"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.