Skip to contents

Fits a Constrained Generalized Additive Model to estimate risk, given a vector of binary outcomes and a vector of scores.

Usage

getCGAMest(
  outcome,
  score,
  numknots = 0,
  smoother = "s.incr",
  logscores = FALSE,
  fitonPerc = TRUE
)

Arguments

outcome

Vector of binary outcome for each observation.

score

Numeric vector of continuous predicted risk score.

numknots

Numeric to specify the number of knots. Passed to the smoother function. Defaults to 3.

smoother

Character string to specify the smoother (from cgam package). Defaults to "s.incr".

logscores

Logical; if TRUE, fit gam on log scores. Defaults to FALSE.

fitonPerc

Logical; if TRUE, fit gam on risk percentiles. Defaults to TRUE.

Value

A data frame with 4 columns (score, score percentile, outcome, estimate).

Examples

# Read in example data
auroc <- read.csv(system.file("extdata", "sample.csv", package = "stats4phc"))
rscore <- auroc$predicted
truth <- as.numeric(auroc$actual)

tail(getCGAMest(outcome = truth, score = rscore), 10)
#>         score percentile outcome   estimate
#> 324 0.3472267 0.81081081       0 0.40075444
#> 325 0.2940563 0.63063063       0 0.35099559
#> 326 0.2956584 0.63963964       0 0.35801069
#> 327 0.3173334 0.70870871       0 0.39452407
#> 328 0.1957009 0.21621622       0 0.08465909
#> 329 0.2909602 0.61561562       0 0.33884696
#> 330 0.1466197 0.03603604       0 0.08465909
#> 331 0.2335213 0.40240240       0 0.18912208
#> 332 0.1310011 0.01201201       0 0.08465909
#> 333 0.3696760 0.85885886       0 0.40075444