-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconclusion.Rmd
67 lines (43 loc) · 2.22 KB
/
conclusion.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# (PART\*) Part V: Conclusion {-}
# Summary
Implementing Bayesian methods has never been easier
<span class="pack">rstanarm</span> and <span class="pack">brms</span> allow one to worry about the concepts instead of syntax
Bayesian analysis provides additional ways to:
- combat complex models
- diagnosis issues
- get creative with results
Even standard/traditional/basic models become more fun!
# Exercise
Whether a survey respondent agrees or disagrees with a conservative statement about the role of women in society
- 1974/1975 Survey
- Women should take care of running their homes and leave running the country up to men
- Modeled as a function of the gender and years of education (0-20) of the respondents
- Data from the <span class="pack">HSAUR3</span> package
- Observations are aggregate counts at education levels for men and women
```{r basic_logistic_data_prep, echo=FALSE, eval=FALSE}
data("womensrole", package = "HSAUR3")
womensrole = womensrole %>%
mutate(total = agree + disagree,
agree50 = agree/total >= .5)
readr::write_csv(womensrole, 'data/womensrole.csv')
```
Run a binomial logistic regression modeling the proportion of those who agreed
- If you are more familiar with binary logistic regression, you may 'unrole' this data to be disagree-agree for each individual (the analysis is the same)
```{r basic_logistic}
data("womensrole", package = "HSAUR3")
# alternative not requiring package
womensrole = readr::read_csv('https://github.com/m-clark/easy-bayes/raw/master/data/womensrole.csv')
womensrole_glm <- glm(cbind(agree, disagree) ~ education + gender,
data = womensrole,
family = binomial)
summary(womensrole_glm)
```
Now use <span class="pack">brms</span> or <span class="pack">rstanarm</span> to run the same analysis
Explore it fully by:
- plotting the coefficients (<span class="func">stanplot</span>)
- use <span class="pack">shinystan</span> to explore diagnostics (<span class="func">launch_shinystan</span>)
- explore the posterior predictive distribtution (<span class="func">pp_check</span>)
- plot the marginal effect of the predictor variables (<span class="func">marginal_effects</span>)
```{r basic_logistic_result}
my_model_bayes = ?
```