5.14 Normal Model
Y∼N(μ,σ2)
f(y)=1√2πσ2exp[−(y−μ)22σ2/n] for yϵ(−∞,∞)
plot_normal(mean,sd)
library(bayesrules)
5.14.1 Prior X Likelihood = Posterior
f(→y|μ) x L(μ|→y)
Starting from the prior model:
μ∼N(6.5,0.42)
We are considering the adults with experience of concussion, in the football
dataset.
library(tidyverse)
%>%head football
## group years volume
## 1 control 0 6.175
## 2 control 0 6.220
## 3 control 0 6.360
## 4 control 0 6.465
## 5 control 0 6.540
## 6 control 0 6.780
%>%count(group) football
## group n
## 1 control 25
## 2 fb_concuss 25
## 3 fb_no_concuss 25
Let’s see the mean:
%>%
footballfilter(group == "fb_concuss")%>%
summarise(mean=mean(volume),sd=sd(volume))
## mean sd
## 1 5.7346 0.5933976
<- football%>%
concussion_subjects filter(group == "fb_concuss")
%>%
concussion_subjectsggplot(aes(x = volume)) +
geom_density()
L(y|→y)∝exp[−(5.735−μ)2(0.52/25)]
plot_normal_likelihood(y = concussion_subjects$volume, sigma = 0.5)
plot_normal_normal(mean = 6.5, sd = 0.4, sigma = 0.5,
y_bar = 5.735, n = 25)
summarize_normal_normal(mean = 6.5, sd = 0.4, sigma = 0.5,
y_bar = 5.735, n = 25)
## model mean mode var sd
## 1 prior 6.50 6.50 0.160000000 0.40000000
## 2 posterior 5.78 5.78 0.009411765 0.09701425