Operating System: Ubuntu 18.04.3 LTS
Interface Version: rstan from development branch, version 2.19.9
Compiler/Toolkit: g++
I’m trying to incorporate the standalone generated quantities gqs() in a package.
In my src/stan_files I have my model.stan files and a forecasting model, let’s say forecast.stan
I followed the same logic as with the sampling
statement - that is, in one of my R-package functions I call
the named object of the stanmodels list.
out = rstan::gqs(stanmodels$forecast,
draws = as.matrix(object$model_fit),
data = standat,
seed = seed)
This, however, returns an error:
Error in envRefInferField(x, what, getClass(class(x)), selfEnv) :
‘standalone_gqs’ is not a valid field or method name for reference class “Rcpp_model_forecast”
error occurred during calling the sampler; sampling not done
Running the same model by first constructing the DSO via stan_model
works.
That is, doing this works flawlessly:
frcst <- rstan::stan_model(file = "../src/stan_files/forecast.stan")
out <- rstan::gqs(frcst, draws = as.matrix(bekk_fit$model_fit), data = standata)
However, this means that each time I load the package, the frcst object needs to be created first - which is not what I want.
I’d appreciate any workaround (or insight), thanks!