-
-
Notifications
You must be signed in to change notification settings - Fork 37
Closed
Labels
Description
I think I wrote about this some time back. But I find myself using this quite often, when I have my own likelihood values either from k-fold cross validation, or from a validation dataset.
print_dims.default <- function(x){}
## ll is the loglikelihood
elpd <- function(ll) {
elpd_pointwise <- colLogSumExps(ll) - log(nrow(ll))
elpd_sum <- sum(elpd_pointwise)
se_elpd <- sqrt(ncol(ll) * var(elpd_pointwise))
estimates <- matrix(c(elpd_sum, se_elpd), nrow = 1)
colnames(estimates) <- c("Estimate", "SE")
rownames(estimates) <- "elpd"
pointwise <- matrix(elpd_pointwise, ncol = 1)
colnames(pointwise) <- "elpd"
out <- list(estimates = estimates, pointwise = pointwise,
se_elpd_loo = se_elpd)
return(structure(out, class = c( "loo")))
}
If it's not wrong, maybe consider adding it? (I could do a pull request and add proper documentation, if this is useful).
Reactions are currently unavailable