library(rstanarm) setwd("C:/Users/az310/Dropbox/Teaching/Teach Bayesian/NCRM Intro Bayesian analysis") rm(list=ls()) load("Turnout for logit.RData") # logit model of turnout # interest = interest in general election # knowledge = correct answers to the factual questions about politics # highschool = high school education # badegree = Bachelor's degree or higher ## A logistic regression estimated with MLE glm <- glm(voted ~ interest + knowledge + highschool + badegree, data=individual, family = binomial) summary(glm) ## A logistic regression estimated using Bayesian analysis fit <- stan_glm(voted ~ interest + knowledge + highschool + badegree, data=individual, family = binomial, seed=1234) ## Summary of the priors prior_summary(fit) ## Draws from the posterior distribution draws <- as.data.frame(fit) head(draws) summary(draws)