pROC: Interfaces for pROC package for data science pipelines.

Description Usage Arguments Details Value Author(s) Examples

Description

Interfaces to pROC functions that can be used in a pipeline implemented by magrittr.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10

Arguments

data

data frame, tibble, list, ...

...

Other arguments passed to the corresponding interfaced function.

Details

Interfaces call their corresponding interfaced function.

Value

Object returned by interfaced function.

Author(s)

Roberto Bertolusso

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
## Not run: 
library(intubate)
library(magrittr)
library(pROC)

## NOTE: pROC examples below use both formula and non-formula variants.
##       In examples for other packages, almost always only
##       the formula variant is shown, but in those cases also
##       the non-formula variants should work.

## ntbt_auc: Compute the area under the ROC curve
data(aSAH)

## Original function to interface
auc(outcome ~ s100b, data = aSAH)
## For non-formula variants, either:
## 1) need to attach
attach(aSAH)
auc(outcome, s100b)
detach()
## or use $
auc(aSAH$outcome, aSAH$s100b)

## The interface puts data as first parameter
## NOTE: in this case the formula version fails, and I have found no
##       way to trick auc into accepting the formula (so far).
##       Maybe (only maybe) there is a problem with auc, as formula
##       variant may not be used, so it was probably not
##       reported as a bug before. The rest of the interfaced
##       functions seem to work fine.
## ntbt_auc(data = aSAH, outcome ~ s100baSAH)
## The non-formula variant works fine
ntbt_auc(aSAH, outcome, s100b)

## so it can be used easily in a pipeline.
#aSAH %>%
#  ntbt_auc(outcome ~ s100baSAH)
aSAH %>%
  ntbt_auc(outcome, s100b)


## ntbt_ci: Compute the confidence interval of a ROC curve
## Original function to interface
ci(outcome ~ s100b, data = aSAH)
## For non-formula variants, either:
## 1) need to attach
attach(aSAH)
ci(outcome, s100b)
detach()
## or use $
ci(aSAH$outcome, aSAH$s100b)

## The interface puts data as first parameter
ntbt_ci(aSAH, outcome ~ s100b)
ntbt_ci(aSAH, outcome, s100b)

## so it can be used easily in a pipeline.
aSAH %>%
  ntbt_ci(outcome ~ s100b)
aSAH %>%
  ntbt_ci(outcome, s100b)


## ci.auc: Compute the confidence interval of the AUC
## Original function to interface
ci.auc(outcome ~ s100b, data = aSAH)
## For non-formula variants, either:
## 1) need to attach
attach(aSAH)
ci.auc(outcome, s100b)
detach()
## or use $
ci.auc(aSAH$outcome, aSAH$s100b)

## The interface puts data as first parameter
ntbt_ci.auc(aSAH, outcome ~ s100b)
ntbt_ci.auc(aSAH, outcome, s100b)

## so it can be used easily in a pipeline.
aSAH %>%
  ntbt_ci.auc(outcome ~ s100b)
aSAH %>%
  ntbt_ci.auc(outcome, s100b)


## ntbt_ci.coords: Compute the confidence interval of arbitrary coordinates
## Original function to interface
set.seed(1)
ci.coords(outcome ~ s100b, data = aSAH, x="best", input = "threshold", 
          ret=c("specificity", "ppv", "tp"))
set.seed(1)
ci.coords(aSAH$outcome, aSAH$s100b, x="best", input = "threshold", 
          ret=c("specificity", "ppv", "tp"))
## For non-formula variants, either:
## 1) need to attach
attach(aSAH)
set.seed(1)
ci.coords(outcome, s100b, x="best", input = "threshold", 
          ret=c("specificity", "ppv", "tp"))
detach()
## or use $
set.seed(1)
ci.coords(aSAH$outcome, aSAH$s100b, x="best", input = "threshold", 
          ret=c("specificity", "ppv", "tp"))

## The interface puts data as first parameter
set.seed(1)
ntbt_ci.coords(aSAH, outcome ~ s100b, x="best", input = "threshold", 
               ret=c("specificity", "ppv", "tp"))
set.seed(1)
ntbt_ci.coords(aSAH, outcome, s100b, x="best", input = "threshold", 
               ret=c("specificity", "ppv", "tp"))

## so it can be used easily in a pipeline.
set.seed(1)
aSAH %>%
  ntbt_ci.coords(outcome ~ s100b, x="best", input = "threshold", 
                 ret=c("specificity", "ppv", "tp"))
set.seed(1)
aSAH %>%
  ntbt_ci.coords(outcome, s100b, x="best", input = "threshold", 
                 ret=c("specificity", "ppv", "tp"))


## ntbt_ci.se: Compute the confidence interval of sensitivities at given specificities
## Original function to interface
set.seed(1)
ci.se(outcome ~ s100b, data = aSAH)
## For non-formula variants, either:
## 1) need to attach
attach(aSAH)
set.seed(1)
ci.se(outcome, s100b)
detach()
## or use $
set.seed(1)
ci.se(aSAH$outcome, aSAH$s100b)

## The interface puts data as first parameter
set.seed(1)
ntbt_ci.se(aSAH, outcome ~ s100b)
set.seed(1)
ntbt_ci.se(aSAH, outcome, s100b)

## so it can be used easily in a pipeline.
set.seed(1)
aSAH %>%
  ntbt_ci.se(outcome ~ s100b)
set.seed(1)
aSAH %>%
  ntbt_ci.se(outcome, s100b)


## ntbt_ci.sp: Compute the confidence interval of specificities at given sensitivities
## Original function to interface
set.seed(1)
ci.sp(outcome ~ s100b, data = aSAH)
## For non-formula variants, either:
## 1) need to attach
attach(aSAH)
set.seed(1)
ci.sp(outcome, s100b)
detach()
## or use $
set.seed(1)
ci.sp(aSAH$outcome, aSAH$s100b)

## The interface puts data as first parameter
set.seed(1)
ntbt_ci.sp(aSAH, outcome ~ s100b)
set.seed(1)
ntbt_ci.sp(aSAH, outcome, s100b)

## so it can be used easily in a pipeline.
set.seed(1)
aSAH %>%
  ntbt_ci.sp(outcome ~ s100b, x="best", input = "threshold", 
             ret=c("specificity", "ppv", "tp"))
set.seed(1)
aSAH %>%
  ntbt_ci.sp(outcome, s100b, x="best", input = "threshold", 
             ret=c("specificity", "ppv", "tp"))


## ntbt_ci.thresholds: Compute the confidence interval of thresholds
## Original function to interface
set.seed(1)
ci.thresholds(outcome ~ s100b, data = aSAH)
## For non-formula variants, either:
## 1) need to attach
attach(aSAH)
set.seed(1)
ci.thresholds(outcome, s100b)
detach()
## or use $
set.seed(1)
ci.thresholds(aSAH$outcome, aSAH$s100b)

## The interface puts data as first parameter
set.seed(1)
ntbt_ci.thresholds(aSAH, outcome ~ s100b)
set.seed(1)
ntbt_ci.thresholds(aSAH, outcome, s100b)

## so it can be used easily in a pipeline.
set.seed(1)
aSAH %>%
  ntbt_ci.thresholds(outcome ~ s100b)
set.seed(1)
aSAH %>%
  ntbt_ci.thresholds(outcome, s100b)


## ntbt_multiclass.roc: Multi-clmulticlass.roc Multi-class AUCass AUC
## Original function to interface
multiclass.roc(gos6 ~ s100b, data = aSAH, levels = c(3, 4, 5))
## For non-formula variants, either:
## 1) need to attach
attach(aSAH)
multiclass.roc(gos6, s100b, levels = c(3, 4, 5))
detach()
## or use $
multiclass.roc(aSAH$gos6, aSAH$s100b, levels = c(3, 4, 5))

## The interface puts data as first parameter
ntbt_multiclass.roc(aSAH, gos6 ~ s100b, levels = c(3, 4, 5))
ntbt_multiclass.roc(aSAH, gos6, s100b, levels = c(3, 4, 5))

## so it can be used easily in a pipeline.
aSAH %>%
  ntbt_multiclass.roc(gos6 ~ s100b, levels = c(3, 4, 5))
aSAH %>%
  ntbt_multiclass.roc(gos6, s100b, levels = c(3, 4, 5))


## ntbt_plot.roc: Plot a ROC curve
## Original function to interface
plot.roc(outcome ~ s100b, data = aSAH, type="b", pch=21, col="blue", bg="grey")
## For non-formula variants, either:
## 1) need to attach
attach(aSAH)
plot.roc(outcome, s100b, type="b", pch=21, col="blue", bg="grey")
detach()
## or use $
plot.roc(aSAH$outcome, aSAH$s100b, type="b", pch=21, col="blue", bg="grey")

## The interface puts data as first parameter
ntbt_plot.roc(aSAH, outcome ~ s100b, type="b", pch=21, col="blue", bg="grey")
ntbt_plot.roc(aSAH, outcome, s100b, type="b", pch=21, col="blue", bg="grey")

## so it can be used easily in a pipeline.
aSAH %>%
  ntbt_plot.roc(outcome ~ s100b, type="b", pch=21, col="blue", bg="grey")
aSAH %>%
  ntbt_plot.roc(outcome, s100b, type="b", pch=21, col="blue", bg="grey")


## ntbt_roc: Build a ROC curve
## Original function to interface
roc(outcome ~ s100b, data = aSAH, type="b", pch=21, col="blue", bg="grey")
## For non-formula variants, either:
## 1) need to attach
attach(aSAH)
roc(outcome, s100b, type="b", pch=21, col="blue", bg="grey")
detach()
## or use $
roc(aSAH$outcome, aSAH$s100b, type="b", pch=21, col="blue", bg="grey")

## The interface puts data as first parameter
ntbt_roc(aSAH, outcome ~ s100b, type="b", pch=21, col="blue", bg="grey")
ntbt_roc(aSAH, outcome, s100b, type="b", pch=21, col="blue", bg="grey")

## so it can be used easily in a pipeline.
aSAH %>%
  ntbt_roc(outcome ~ s100b, type="b", pch=21, col="blue", bg="grey")
aSAH %>%
  ntbt_roc(outcome, s100b, type="b", pch=21, col="blue", bg="grey")

## End(Not run)

intubate documentation built on May 2, 2019, 2:46 p.m.