## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
set.seed(1)   # ipeb() draws an internal validation split; fix it for a reproducible vignette

## -----------------------------------------------------------------------------
library(iPEB)
data(ipeb_example)
str(ipeb_example)

## -----------------------------------------------------------------------------
train <- subset(ipeb_example, split == "train")
test  <- subset(ipeb_example, split == "test")

## -----------------------------------------------------------------------------
fit <- ipeb(train, markers = c("m1", "m2", "m3"),
            objective = "sensitivity", alpha = 0.95,
            innovation = "iid", slope = "off")
fit

## -----------------------------------------------------------------------------
head(predict(fit, test))

evaluate(fit, test, specificities = c(0.90, 0.95, 0.99))

## -----------------------------------------------------------------------------
fit_lt <- ipeb(train, markers = c("m1", "m2", "m3"),
               objective = "leadtime", innovation = "iid", slope = "off")
evaluate(fit_lt, test, specificities = 0.95)

## -----------------------------------------------------------------------------
fit_sel <- ipeb(train, markers = c("m1", "m2", "m3"),
                objective = "sensitivity", select = "backward", n_markers = 2,
                innovation = "iid", slope = "off")
fit_sel$markers

## -----------------------------------------------------------------------------
res <- ipeb_run(train, test, markers = c("m1", "m2", "m3"),
                objective = "sensitivity", innovation = "iid", slope = "off",
                specificities = c(0.90, 0.95, 0.99))
res$evaluation

