Skip to contents

IRLS fit with the prediction path attached. The 0.5 threshold minimises error rate only under equal misclassification costs and roughly balanced classes; on imbalanced data it will predict the majority class everywhere.

Usage

morie_esl_logistic_reg(X, y, newdata = NULL, threshold = 0.5, ...)

Arguments

X

Design matrix, n by p.

y

Binary 0/1 response.

newdata

Points to predict at; defaults to X.

threshold

Probability cut-off in (0, 1).

...

Passed to morie_esl_iwls().

Value

List with beta, se, p_value, odds_ratio, prob, class, accuracy, confusion, loglik, deviance.

References

Hastie, T., et al. (2009). ESL (2nd ed.), Sec 4.4. Springer.

Examples

set.seed(1)
X <- matrix(rnorm(1000), ncol = 1)
y <- rbinom(1000, 1, plogis(0.3 + 2 * X[, 1]))
round(morie_esl_logistic_reg(X, y)$beta[2], 1)
#> [1] 2