add_riskscore: Add Risk Score to Dataset

View source: R/add_riskscore.R

add_riskscoreR Documentation

Add Risk Score to Dataset

Description

This function computes a risk score for each observation in the dataset based on the provided Cox proportional hazards model or logistic regression.

Usage

add_riskscore(
  input,
  family = "cox",
  target = NULL,
  time = NULL,
  status = NULL,
  vars,
  new_var_name = "riskscore"
)

Arguments

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".

Value

The input data frame with an additional column containing the risk scores.

Author(s)

Dongqiang Zeng

Examples

data(ovarian)
ovarian$rscore <- add_riskscore(ovarian, time = "time", status = "status", vars=c("resid.ds", "rx", "ecog.ps"))

IOBR/IOBR documentation built on July 16, 2025, 8:12 p.m.