Attempts to fit a beta distribution to a data frame of MCMC output from a previous run.

fit_beta_prior(
  chain_samples,
  par_name = "",
  error_tol = 999999999,
  try_attempts = 10,
  plot_fit = TRUE
)

Arguments

chain_samples

numeric vector of posterior samples to fit

par_name

optional parameter name used in the plot title

error_tol

tolerance for the optimisation error

try_attempts

maximum number of fitting attempts before giving up

plot_fit

if TRUE, plots the fitted distribution against the posterior density

Value

the model fit object returned by `optim`, or a list with missing parameters if fitting fails

Examples

if (FALSE) { # \dontrun{
## Posterior draws from a previous serosolver chain
chain <- rbeta(100, 2, 8)
results <- fit_beta_prior(chain, par_name="sigma1",plot_fit=FALSE)
} # }