# Chapter 10 Methods

Far better an approximate answer to the right question, which is often vague, than an exact answer to the wrong question, which can always be made precise - John W. Tukey, 1962

We describe our methods in this chapter.

## 10.3 Hierarchical Modeling

library(lme4)
library(arm)
data("sleepstudy")
fit_lme <- lmer(extra ~ group + (1 | ID), sleep)
display(fit_lme)
## lmer(formula = extra ~ group + (1 | ID), data = sleep)
##             coef.est coef.se
## (Intercept) 0.75     0.60
## group2      1.58     0.39
##
## Error terms:
##  Groups   Name        Std.Dev.
##  ID       (Intercept) 1.69
##  Residual             0.87
## ---
## number of obs: 20, groups: ID, 10
## AIC = 78, DIC = 71.1
## deviance = 70.5
ranef(fit_lme)
## \$ID
##    (Intercept)
## 1   -0.2118668
## 2   -1.7125900
## 3   -0.9622284
## 4   -1.8450067
## 5   -1.4477565
## 6    2.0833569
## 7    2.7013017
## 8   -0.3001446
## 9    0.6709115
## 10   1.0240229
library(brms)
library(ggplot2)
library(ggeffects)
library(sjPlot)
library(sjlabelled)
data(efc)

m <- brm(cbind(c82cop1, c83cop2, c84cop3) ~ c161sex + e42dep, data = efc)

plot_model(m)

### 10.3.1 Bayesian Hierarchical Modeling

data("sleep")
library(rjags)

#model_string <- 

## 10.4 Being Certain about What we can

Uncertainity reflects the lack of complete knolwedge about a paramet; variability refers to underlying differences among individuals or groups (Gelman and Hill 457)