catpredi: Function to obtain optimal cut points to categorise a...

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/catpredi.R

Description

Returns an object with the optimal cut points to categorise a continuous predictor variable in a logistic regression model

Usage

1
2
3
catpredi(formula, cat.var, cat.points = 1, data,
method = c("addfor", "genetic"), range = NULL, 
correct.AUC = TRUE, control = controlcatpredi(), ...)

Arguments

formula

An object of class formula giving the model to be fitted in addition to the continuous covariate is aimed to categorise. This argument allows the user to specify whether the continuous predictor should be categorised in a univariable context, or in presence of other covariates or cofounders, i.e in a multiple logistic regression model. For instance, Y ~ 1 indicates that the categorisation should be done in a univariable setting, with Y being the response variable. If the predictor variable is aimed to be categorised in a multivariable setting, this argument allows to specify whether the covariates should be modelled using linear or non linear effects. In the latest, the effects are estimated using the mgcv package.

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. "addfor" if the AddFor algorithm is choosen and "genetic" otherwise.

range

The range of the continuous variable in which to look for the cut points. By default NULL, i.e, all the range.

correct.AUC

A logical value. If TRUE the bias corrected AUC is estimated.

control

Output of the controlcatpredi() function.

...

Further arguments for passing on to the function genoud of the package rgenoud.

Value

Returns an object of class "catpredi" with the following components:

call

the matched call.

method

the algorithm selected in the call.

formula

an object of class formula giving the model to be fitted in addition to the continuous covariate is aimed to categorise.

cat.var

name of the continuous variable to categorise.

data

the data frame with the variables used in the call.

correct.AUC

The logical value used in the call.

results

a list with the estimated cut points, AUC and bias corrected AUC.

control

the control parameters used in the call.

For each of the methods used in the call, a list with the following components is obtained:

"cutpoints"

Estimated optimal cut points.

"AUC"

Estimated AUC.

"AUC.cor"

Estimated bias corrected AUC.

Author(s)

Irantzu Barrio, Maria Xose Rodriguez-Alvarez and Inmaculada Arostegui

References

I Barrio, I Arostegui, M.X Rodriguez-Alvarez and J.M Quintana (2015). A new approach to categorising continuous variables in prediction models: proposal and validation. Statistical Methods in Medical Research (in press).

S.N Wood (2006). Generalized Additive Models: An Introduction with R. Chapman and Hall/CRC.

See Also

See Also as controlcatpredi, comp.cutpoints, plot.catpredi, summary.catpredi.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
library(CatPredi)


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)
 

CatPredi documentation built on Jan. 10, 2022, 5:07 p.m.