data(mtcars)
library(tidyverse)
library(rstanarm)
library(easystats)mtcars-post
bayes
post
estimation
exam-22
qm2
mtcars
qm2-pruefung2023
Aufgabe
Im Datensatz mtcars: Berichten Sie die Breite eines Schätzintervalls (89%, HDI) zum mittleren Spritverbrauch! Nutzen Sie Methoden der Bayes-Statistik.
Lösung
Setup:
Modell berechnen:
m1 <- stan_glm(mpg ~ 1,
data = mtcars,
seed = 42,
refresh = 0)Modellparameter auslesen, wobei wir als CI-Methode ein HDI auswählen, und als CI-Größe 89%:
parameters(m1, ci = .89, ci_method = "hdi")| Parameter | Median | CI | CI_low | CI_high | pd | Rhat | ESS | Prior_Distribution | Prior_Location | Prior_Scale |
|---|---|---|---|---|---|---|---|---|---|---|
| (Intercept) | 20.10377 | 0.89 | 18.26377 | 21.63711 | 1 | 1.000792 | 2838.234 | normal | 20.09062 | 15.06737 |
Im Standard wird ein 95%-Perzentilintervall berechnet, s. die Dokumentation zur Funktion hier.
Die Lösung lautet also:
solution <- 21.64 - 18.26
solution[1] 3.38
Categories:
- bayes
- post
- estimation
- exam-22