| catpredi | R Documentation |
Returns an object with the optimal cut points to categorise a continuous predictor variable in a logistic regression model
catpredi(
formula,
cat.var,
cat.points = 1,
data,
method = c("addfor", "genetic", "backaddfor"),
range = NULL,
correct.AUC = FALSE,
control = controlcatpredi(),
...
)
formula |
An object of class |
cat.var |
Name of the continuous variable to categorise. |
cat.points |
Number of cut points to look for. |
data |
Data frame containing all needed variables. |
method |
The algorithm selected to search for the optimal cut points.
|
range |
The range of the continuous variable in which to look for the cut
points. By default |
correct.AUC |
A logical value. If |
control |
Output of the |
... |
Further arguments for passing on to the function |
Returns an object of class "catpredi" with the following components:
The matched call.
The algorithm selected in the call.
The model formula used in the call.
Name of the continuous variable to categorise.
The data frame used in the call.
Logical value indicating whether bias-corrected AUC was used.
A list containing estimated cut points, AUC and bias-corrected AUC for each method.
The control parameters used in the call.
Irantzu Barrio, Maria Xose Rodriguez-Alvarez, Inmaculada Arostegui, Javier Roca-Pardinas and Xabier Amutxastegi.
I Barrio, J Roca-Pardinas and I Arostegui (2021). Selecting the number of categories of the lymph node ratio in cancer research: A bootstrap-based hypothesis test. Statistical Methods in Medical Research, 30(3), 926-940.
I Barrio, I Arostegui, M.X Rodriguez-Alvarez and J.M Quintana (2017). A new approach to categorising continuous variables in prediction models: proposal and validation. Statistical Methods in Medical Research, 26(6), 2586-2602.
S.N Wood (2006). Generalized Additive Models: An Introduction with R. Chapman and Hall/CRC.
controlcatpredi,
comp.cutpoints,
plot.catpredi,
summary.catpredi
library(CatPredi)
## Not run:
set.seed(127)
#Simulate data
n = 100
#Predictor variable
xh <- rnorm(n, mean = 0, sd = 1)
xd <- rnorm(n, mean = 1.5, sd = 1)
x <- c(xh, xd)
#Response
y <- c(rep(0,n), rep(1,n))
#Covariate
zh <- rnorm(n, mean=1.5, sd=1)
zd <- rnorm(n, mean=1, sd=1)
z <- c(zh, zd)
# Data frame
df <- data.frame(y = y, x = x, z = z)
# Select optimal cut points using the AddFor algorithm
res.addfor <- catpredi(formula = y ~ z, cat.var = "x", cat.points = 2,
data = df, method = "addfor", range=NULL, correct.AUC=FALSE,
control=controlcatpredi(grid=20))
# Select optimal cut points using the BackAddFor algorithm
res.backaddfor <- catpredi(formula = y ~ z, cat.var = "x", cat.points = 3,
data = df, method = "backaddfor", range=NULL, correct.AUC=FALSE)
## End(Not run)
## Not run:
set.seed(127)
#Simulate data
n = 200
#Predictor variable
xh <- rnorm(n, mean = 0, sd = 1)
xd <- rnorm(n, mean = 1.5, sd = 1)
x <- c(xh, xd)
#Response
y <- c(rep(0,n), rep(1,n))
#Covariate
zh <- rnorm(n, mean=1.5, sd=1)
zd <- rnorm(n, mean=1, sd=1)
z <- c(zh, zd)
# Data frame
df <- data.frame(y = y, x = x, z = z)
# Select optimal cut points using the AddFor algorithm
res.addfor <- catpredi(formula = y ~ z, cat.var = "x", cat.points = 3,
data = df, method = "addfor", range=NULL, correct.AUC=FALSE)
# Select optimal cut points using the BackAddFor algorithm
res.backaddfor <- catpredi(formula = y ~ z, cat.var = "x", cat.points = 3,
data = df, method = "backaddfor", range=NULL, correct.AUC=FALSE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.