# These examples take more than 5 seconds to run, so they are not run by default.
# Use parallel processing (the default) to speed up.
# \donttest{
# Create a sample data frame of MCMC samples
samples <- data.frame(
log_N = log(runif(50, 2, 10)),
log_k0 = log(runif(50, 1, 5)),
log_cooling_rate = log(runif(50, 0.01, 0.1)),
log_c_repulsion = log(runif(50, 0.1, 1)),
NLL = runif(50, 20, 100)
)
# Calculate profile likelihood
pl_result <- profile_likelihood("log_N", samples, grid_size = 10)
# Plot with maximum likelihood from samples
LL_max <- max(-samples$NLL)
# The plot function requires the ggplot2 package
if (requireNamespace("ggplot2", quietly = TRUE)) {
plot(pl_result, LL_max, width = 4, height = 3)
}
# }
Run the code above in your browser using DataLab