library(dplyr)
set.seed(123)
n <- 200
dat <- tibble(
age = rnorm(n, mean = 55, sd = 7),
insured = rbinom(n, 1, 0.7),
screened = rbinom(n, 1, plogis(-5 + 0.06 * age + 0.8 * insured))
)
fit <- glm(screened ~ age + insured,
data = dat,
family = binomial)
summary(fit)
Call:
glm(formula = screened ~ age + insured, family = binomial, data = dat)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -6.27215 1.56494 -4.008 6.13e-05 ***
age 0.08266 0.02651 3.118 0.00182 **
insured 0.84025 0.40401 2.080 0.03755 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 229.22 on 199 degrees of freedom
Residual deviance: 214.30 on 197 degrees of freedom
AIC: 220.3
Number of Fisher Scoring iterations: 4