This takes any values that are better (lower) than the desired negative log likelihood and reflects them across the best_neglnL + delta line, "denting" the likelihood surface.

dent_likelihood(neglnL, best_neglnL, delta = 2)

Arguments

neglnL

The original negative log likelihood

best_neglnL

The negative log likelihood at the optimum; other values will be greater than this.

delta

How far from the optimal negative log likelihood to focus samples

Value

The transformed negative log likelihood

Examples

sims <- stats::rnorm(100, mean=17)
possible_means <- seq(from=16, to=18, length.out=100)
results_normal <- rep(NA, length(possible_means))
results_dented <- results_normal
dnorm_to_run <- function(par, sims) {
  return(-sum(dnorm(x=sims, mean=par, log=TRUE)))
}
best_neglnL <- optimize(dnorm_to_run,interval=range(possible_means), 
  sims=sims, maximum=FALSE)$objective
for (i in seq_along(possible_means)) {
  results_normal[i] <- dnorm_to_run(possible_means[i], sims=sims)
  results_dented[i] <- dent_likelihood(results_normal[i], best_neglnL=best_neglnL, delta=2)
}

plot(possible_means, results_normal)
lines(possible_means, results_dented)