Q: Using the affairs.csv file \([\dots]\) [r]un a binary logistic model with had_affair as an outcome, and gender, children, and religiousness as predictors.
What is the coefficient for the religiousness variable?
library(tidyverse)
df <- read_csv('https://raw.githubusercontent.com/mark-andrews/ntupsychology-data/main/data-sets/affairs.csv')
df <- mutate(df, had_affair = affairs > 0)
model <- glm(had_affair ~ gender + religiousness + children,
data = df,
family = binomial(link = "logit"))
b <- coef(model)
b['religiousness']
religiousness
-0.3052493