Closed brettmelbourne closed 3 years ago
Thanks for reporting this. I am not able to reproduce this on my Mac so this may just be a Windows issue. @bgoodri Can you reproduce this on Windows?
Also @brettmelbourne, if you have time can you try a few quick things that might help us figure this out?
traceback()
after you get the error does it give you more information? If so can you share that? cores=1
instead of cores=2
? Thanks!
Also, I'm not 100% sure but until we fix this you may be able to get around it like this by extracting the log-likelihood and then directly calling the loo package (instead of the loo method in rstanarm).
loglik <- log_lik(fit1)
loo::loo(loglik)
Thanks. It does work without error when cores =1
. Here's the traceback after cores =2
:
12: get(name, envir = envir)
11: serialize(data, node$con)
10: sendData.SOCKnode(con, list(type = type, data = value, tag = tag))
9: sendData(con, list(type = type, data = value, tag = tag))
8: postNode(con, "EXEC", list(fun = fun, args = args, return = return,
tag = tag))
7: sendCall(cl[[i]], fun, list(...))
6: clusterCall(cl, gets, name, get(name, envir = envir))
5: parallel::clusterExport(cl, "draws")
4: relative_eff.function(x = likfun, chain_id = chain_id, data = args$data,
draws = args$draws, cores = cores, ...)
3: loo::relative_eff(x = likfun, chain_id = chain_id, data = args$data,
draws = args$draws, cores = cores, ...)
2: loo.stanreg(fit1, cores = 2)
1: loo(fit1, cores = 2)
Warning messages:
1: In if (.Internal(islistfactor(x, recursive))) { :
closing unused connection 5 (<-LAPTOP-FE8PH8RN:11446)
2: In if (.Internal(islistfactor(x, recursive))) { :
closing unused connection 4 (<-LAPTOP-FE8PH8RN:11446)
Thanks for the extra info. There's a chance that we fixed this in the next version of the loo package that we'll be releasing soon but I'm not 100% sure yet if it's the same issue. If you have time can you try installing the development version of the loo package from github and seeing if there's still an error? You can install that with
devtools::install_github("stan-dev/loo")
Thanks. I installed the loo development version as suggested. This works now on my Win10 machine.
Ok great, thanks for checking. I'm going to go ahead and close this since we're in the process of submitting that patched version of loo to CRAN.
Summary:
The function loo gives an error "object 'draws' not found"
Description:
After fitting a simple model from the examples in the rstanarm help for loo(), the following error is given:
Reproducible Steps:
library(rstanarm) fit1 <- stan_glm(mpg ~ wt, data = mtcars, refresh = 0) loo(fit1, cores = 2)
RStanARM Version:
2.21.1
R Version:
4.0.2
Operating System:
Windows 10
Reproduced on multiple windows systems.