rcsOR {interactionRCS} | R Documentation |
Restricted cubic spline interaction OR for more than 3 knots
Description
Generate OR values in a logistic model for a 1 unit increase in a variable at specified points of another interacting variable splined with rcs(df >= 3)
Usage
rcsOR(
var2values,
model,
data = NULL,
var1,
var2,
ci = TRUE,
conf = 0.95,
ci.method = "delta",
ci.boot.method = "perc",
R = 100,
parallel = "multicore",
...
)
Arguments
var2values |
numeric vector of var2 points to estimate |
model |
model of class lrm, Glm or glm family binomial. If data is NULL, the function expects to find the data in model$x. |
data |
data used in the model. If absent, we will attempt to recover the data from the model. Only used for bootstrap and glm class models |
var1 |
variable that increases by 1 unit from 0 |
var2 |
variable to spline. var2values belong to var2 |
ci |
calculate 95% CI? |
conf |
confidence level. Default 0.95 |
ci.method |
confidence interval method. "delta" performs delta method. "bootstrap" performs bootstrapped CI (slower) |
ci.boot.method |
one of the available bootstrap CI methods from |
R |
number of bootstrap samples if ci.method = "bootstrap". Default 100 |
parallel |
can take values "no", "multicore", "snow" if ci.method = "bootstrap". Default multicore |
... |
other parameters for boot |
Value
if ci = FALSE, a dataframe with initial values and OR
Examples
library(rms)
library(mlbench)
data(PimaIndiansDiabetes)
# Set age on a 5-year scale
PimaIndiansDiabetes$age <- PimaIndiansDiabetes$age/5
# Recode diabetes as 0/1
PimaIndiansDiabetes$diabetes <- ifelse(PimaIndiansDiabetes$diabetes=="pos" , 1 , 0)
myformula <- diabetes ~ mass + age * rcs( glucose , 4 )
model <- glm(myformula , data = PimaIndiansDiabetes , family = "binomial")
rcsOR( var2values = 20:80
, model = model , data = PimaIndiansDiabetes , var1 ="age", var2="glucose"
, ci=TRUE , conf = 0.95 , ci.method = "delta")