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

fit_normal_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 <- rnorm(100, mean = 0, sd = 1)
results <- fit_normal_prior(chain, par_name="mu",plot_fit=FALSE)
} # }