# MinutePlot validation -- Binary logistic regression (mtcars: am ~ wt + hp)
# Install once: nothing -- this script uses base R only

# Versions (compare against those stated on this page):
cat(R.version.string, "\n")

# Load data:
d <- mtcars[, c("am", "wt", "hp")]   # built-in; or: d <- read.csv("mtcars_am_wt_hp.csv")

# Analysis (one print per table shown on the page, in page order):
fit <- glm(am ~ wt + hp, data = d, family = binomial)
print(summary(fit))                                     # log-odds coefficients, SE, z, p, deviances, AIC
cat("Log-likelihood:", as.numeric(logLik(fit)), "  Null log-likelihood:", as.numeric(logLik(update(fit, . ~ 1))), "\n")
