expl_rr: Explore the Risk Ratio with Cubic Spline

View source: R/expl_rr.R

expl_rrR Documentation

Explore the Risk Ratio with Cubic Spline

Description

plot the changes of risk ratio of a risk factor in relation to the outcome using predictions from a general model, and identify the threshold.

Usage

expl_rr(data,formula,low=0.01,high=0.99,ref = 'min')

Arguments

data

A data.frame containing the risk factor and the outcome prediction probability from a model.

formula

Formula. Specify the outcome prediction and risk factor like pred~x

low

Set x scale limits

high

Set x scale limits

ref

Set reference. Using the smallest("min"), mean("mean"), median("median") or customized value of loess prediction

Details

For health data, if it is a cohor study, it will calculate the Risk Ratio. The risk ratio is calculated through following approaches. First, fit the risk factor and outcome prediction with loess regression, and get the smallest(mean, median, customized) value of loess prediction. Using the smallest(mean, median, customized) value from loess prediction as reference, the risk ratio = outcome prediction/the smallest value. Plot the risk factor and risk ratio with cubic spline.

Value

p

Cubic Spline plot.

pred

Loess model prediction.

min_pred

Reference value. The smallest value from loess prediction.

threshold

Threshold value for the plot. Identified by youden index

Note

For health data, if it is a cohor study, it will calculate the Risk Ratio.

Examples


library(h2o)
data(iris)
attach(iris)
h2o.init()
hyper <- list(ntrees=c(2,3,5))
iris <- iris[1:100,c(5,1:4)]
idx <- sample(100,50)
traindata <- iris[idx,]
testdata <- iris[-idx,]
xcol <- names(iris)[2:5]
results <- APML(xcol=xcol,hyper=hyper,
                traindata=traindata,testdata=testdata,
                sort_by ='auc',distribution = 'bernoulli')
data <- as.h2o(iris)
pred<- h2o.predict(results$bestmodel,newdata=data)
data <- h2o.cbind(data,pred)
data <- as.data.frame(data)
plots <- expl_rr(data,setosa~Sepal.Length,ref = 'mean')
plots$p
h2o.shutdown(prompt=FALSE)
Sys.sleep(2)

APML documentation built on May 12, 2022, 9:06 a.m.

Related to expl_rr in APML...