Live demo
Open this example in Shinylive
The app runs entirely in the browser with webR; no local R installation is required for the demo.
A Beta input provides a direct way to shape a prior over a probability.
If the prior is
and we observe successes in Bernoulli trials, the conjugate posterior is
The example uses bslib::page_sidebar(): the editable
prior and trial controls live in the sidebar, while the prior/posterior
plot is shown in a bslib::card().
The Shiny input provides the current alpha and
beta values:
bslib::sidebar(
modist_input(
"prior",
family = "beta",
value = list(alpha = 2, beta = 2)
),
sliderInput("n", "Trials", min = 1, max = 100, value = 20),
sliderInput("x", "Successes", min = 0, max = 20, value = 12)
)The prior and posterior curves need only base R’s
dbeta().
Run the complete example with:
shiny::runApp(
system.file("examples/bayes-beta-binomial", package = "shinymodist")
)