library(tidyverse) # data cleaning and plotting
library(bayesrules)
library(tidyverse)
library(rstan)
library(rstanarm)
library(bayesplot)
library(tidybayes)
library(janitor)
library(broom.mixed)
Diarrhea Disease Transmission
Bayesian Statistics Learning Objectives
- Build a Bayesian simple linear regression model
- Interpret appropriate prior models for the regression parameters;
- Simulate the posterior model of the regression parameters; and
- Use simulation results to build a posterior understanding of the relationship between Y and
X and to build posterior predictive models of
- Compare these models to a model with multiple linear regression.
Libraries
Introducing the data
<- read_csv("data/ecDataCompID.csv") ecData
Rows: 9 Columns: 6
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
dbl (6): city, pop, meandeg, meanind, lnmeanind, remoteness
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
ecData
# A tibble: 9 × 6
city pop meandeg meanind lnmeanind remoteness
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1 879 5.10 113. 4.73 -1.98
2 2 153 6 31.7 3.46 0.472
3 3 99 5.7 43.4 3.77 0.065
4 4 230 7.90 40.4 3.70 3.58
5 5 84 2.54 507. 6.23 -0.918
6 6 146 8.05 37.3 3.62 -0.263
7 7 285 2.54 153. 5.03 -2.47
8 8 478 5.95 107. 4.67 -0.997
9 9 319 6.79 45.7 3.82 2.51
The data contains information on:
city
: the city idpop
: population (number of people)meandeg
:meanind
:lnmeanind
:remoteness
: measure of remoteness