I’m encountering an issue using moment matching on a CmdStanFit
object. I’ve followed the helpful info here to recreate a dummy model object, since I am running this on a bunch of models that I’ve fit using cmdstan
from the command line.
The issue I’m having is that fit$loo(moment_match = TRUE)
is not returning anything different from fit$loo()
. Below is the exact code that reproduces these results, with an image of the actual results below this block.
library(cmdstanr)
library(posterior)
library(tidyverse)
library(loo)
options(mc.cores = parallel::detectCores()/2)
mod1 <- cmdstan_model("stan/bivar_trunc_gamma_asym_log.stan", force_recompile = TRUE)
fit_dummy <- mod1$sample(data = "data/independent/low_1.json",
iter_warmup = 1,
iter_sampling = 1)
start_file_path <- paste0("stan/csv_fits/", "stacking", "/", "independent", "/", "asym_log", "/")
csvfiles <- paste0(start_file_path,
list.files(path = start_file_path,
pattern = paste0("low", "_", 1, "_\\d{1}.csv")))
fit_csv <- as_cmdstan_fit(csvfiles)
fit_dummy$.__enclos_env__$private$draws_ <- fit_csv$.__enclos_env__$private$draws_
loo1 <- fit_dummy$loo()
loo2 <- fit_dummy$loo(moment_match = TRUE)
Here’s what I get for both loo1
and loo2
:
As you can see, I get the exact same results both with and without moment_match = TRUE
. Do you have any ideas about what could be happening?
I’m happy to provide the actual .json
file, the model code, and the 3 .csv
files from this fit, if that’s helpful. But I didn’t want to overwhelm this initial post.
I’m using cmdstanr
v 0.7.1, CmdStan
v 2.34.1, and loo
v 2.7.0.9000.
Thank you in advance!