LoslegenKostenlos loslegen

Define, compile, and simulate

In your election quest, let \(p\) be the proportion of the underlying voting population that supports you. Built from previous polls & election data, your prior model of \(p\) is a Beta(\(a\),\(b\)) with shape parameters \(a = 45\) and \(b = 55\). For added insight into \(p\), you also polled \(n\) potential voters. The dependence of \(X\), the number of these voters that support you, on \(p\) is modeled by the Bin(\(n\),\(p\)) distribution.

In the completed poll, \(X = 6\) of \(n = 10\) voters supported you. The next goal is to update your model of \(p\) in light of these observed polling data! To this end, you will use the rjags package to approximate the posterior model of \(p\). We break this exercise down into the 3 rjags steps: define, compile, simulate.

Diese Übung ist Teil des Kurses

Bayesian Modeling with RJAGS

Kurs anzeigen

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# DEFINE the model
vote_model <- "model{
    # Likelihood model for X
    X ~ ___
    
    # Prior model for p
    p ~ ___
}"
Code bearbeiten und ausführen