Closed AdamMS closed 2 years ago
The predict()
function is supposed to work for new datasets. If you want to calculate the fitted values, you will need to do the calculation by extracting the X and Z design matrices from the fitted object, and multiplying with the posterior means of beta and b.
I finally figured out how go get fitted values from predict(). The solution was suggested to me by the competing risks vignette, but it was not obvious.
Thank you in advance!
Context:
Problem:
Predictions from predict() do not match predictions that I hand-calculate as: y^{pred} = X\beta + Zb, where I am using the mean posterior estimates for b. I know that predict() is drawing from MCMC samples, but I think this approach should be okay for my purpose (finding mean posterior residuals). Am I missing something? While I wonder whether predict() is correctly calculating predicted values, I have reached my limit in R coding as I try to trace the difference in methods. I should note that the problem with my actual data/model is more extreme than in the attached MWE.
Other Issue:
Am I using the correct technique to fit the model given the missing responses?
Again, thank you for your response.
MWE (R script saved as .txt): MWE_predict.txt