Skip to contents

Fit a logistic model for one bootstrap replicate

Usage

fit_logistic(data, formula, select)

Arguments

data

A data frame - one bootstrap replicate.

formula

Model formula offering the candidate terms.

select

List with method ("stepwise" or "none"), sle, sls, max_steps. %bootreg equivalents: SELECT=, SLE=, SLS=, MAXSTEP=.

Value

Named numeric vector of kept coefficients, or NULL if the fit errored or did not converge. Warnings - notably "fitted probabilities numerically 0 or 1" on a quasi-separated replicate - do not discard a converged fit.

Details

Under select = "stepwise", entry tests the score chi-square and removal tests Wald, matching PROC LOGISTIC SELECTION=STEPWISE.

Examples

set.seed(1)
n  <- 200
x1 <- rnorm(n)
df <- data.frame(y = as.integer(x1 + rnorm(n) > 0), x1 = x1,
                 noise = rnorm(n))

fit_logistic(df, y ~ x1 + noise,
             list(method = "stepwise", sle = 0.10, sls = 0.05,
                  max_steps = 0))
#> (Intercept)          x1 
#>  0.05094849  1.38932194