I am new to stan, so I’d really appreciate any help. I use R 3.4.1 with rstan (2.14.1).
I have a fitted stan object in R, fitted via rstan::stan. How do I make prediction on new data?
Options so far:
- Include new data in call to ‘stan’ function, like stan reference 2.16.0 page 160. However this requires new data to be available at training time, which is not the case for me. I do not wish to retrain the model when new-data-for-prediction comes since model training takes a while
- Extract posterior parameter samples into R and do prediction in R with new-data-for-prediction. However this requires me to duplicate the model structure in R
- Muck around with the “algorithm = 'Fixed_parameter” function in rstan::stan. Doesn’t do what I want, it probably is not meant for this use case?
The user experience I am after is:
- Fit model in R, eg: fit <- stan(…)
- Make posterior predictions using new data and the posterior parameter samples in fit, eg: new_data_pred_samples <- predict(fit, newdata)
- then I can get prediction point estimates and bounds from these new_data_pred_samples