How to avoid recompiling?
My stan()
is recompiling to avoid crashing R session.
To validate my model, I want to replicate various models for many data from known distributions. However rstan::stan()
always recompile my stan file, so it took a very long time. How to avoid recompiling.
Edit for comment-------------
Memorandum for conversion from rstan::stan()
to rstan::sampling()
.
In rstan::stan
, its variable name is model_name
m <- "foo.stan"
rstan::stan( model_name =m, data =...)
On the other hand, in rstan::sampling
its variable name is object
m <- "foo.stan"
m <- stan_model(m)
rstan::sampling( object = m , data = ...)
Please be careful !! The variable name is different !!
Use the function stan_model
to compile, then use the compiled model output in the sampling
function. For example:
m <- stan_model('foo.stan')
fit <- sampling(m, data = ...)
instead of
fit <- stan('foo.stan', data = ...)