I would like to run the same model on many datasets with the meanfield algorithm.
It works great but most of the time is spend compiling the models to c++ code.
I hoped that by setting the save_model and save_dso parameter in brm() it would detect if the model has already been compiled before and use that to rerun the model on the different data in stan.
But it still seems to compile the model.
Is it possible to save the compiled code and skip model compilation next time you run the exact same model?
Yes, you are right.
thanks.
Do you know where these compiled objects are saved?
I looks like you can’t specify a path in eg. save_dso() (I think DSO is the thing I want?)
Or is the compile code saved into the brms fit object?
If I look in the fit object I see cpp code in the fit$fit@stanmodel@model_cpp slot.
I guess it’s this.
In that case, I should just save and load the fitted object as rdata.
Is it possible to compile the code of a model without actually fitting it on data?
I would just save it and fit it later on different datasets.
So I would imaging something like calling the brm() function without a data argument and something like a fit = FALSE argument.
However the whole Stan package skeleton creation thingy looks complicated at a first glance.
For me, saving a model once as an .rds file and then loading and retraining on new data also seems to work for me and is easy to implement.
Any reason I would want Stan package skeleton creation?