Loo 2.0 with very large stanfit crashes R

Unfortunately, I haven’t saved all of the transformed parameters I would need. Looks like I’ll have to restructure the code and rerun. I see now with this example that the method I was using previously with loo prior to 2.0.0 will not work with the current loo. Here is the test I used:

# Simulate data and draw from posterior
N <- 50; K <- 10; S <- 100; a0 <- 3; b0 <- 2
p <- rbeta(1, a0, b0)
y <- rbinom(N, size = K, prob = p)
a <- a0 + sum(y); b <- b0 + N * K - sum(y)
fake_posterior <- as.matrix(rbeta(S, a, b))
dim(fake_posterior) # S x 1
fake_data <- data.frame(y,K)
dim(fake_data) # N x 2

llfun <- function(data_i, draws) {
  # each time called internally within loo the arguments will be equal to:
  # data_i: ith row of fake_data (fake_data[i,, drop=FALSE])
  # draws: entire fake_posterior matrix
  dbinom(data_i$y, size = data_i$K, prob = draws, log = TRUE)
}

log_lik_matrix <- sapply(1:N, function(i) {
  llfun(data_i = fake_data[i,, drop=FALSE], draws = fake_posterior)
})

ll_fun <- function(data_i, draws) {
  data_i*draws
}

loo(ll_fun, data = t(log_lik_matrix), draws = rep(1, S))

Which the last statement returns this error:

Warning: Not enough tail samples to fit the generalized Pareto distribution in some or all columns of matrix 
of log importance ratios. Skipping the following columns: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ... [90 more not printed].

Error in log_weights[, n] : incorrect number of dimensions
In addition: Warning messages:
1: Relative effective sample sizes ('r_eff' argument) not specified.
For models fit with MCMC, the reported PSIS effective sample sizes and 
MCSE estimates will be over-optimistic. 
2: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.

It’s not clear to me why this result occurs, but clearly I need to dig deeper into the loo documentation.