I have a GAMLSS trained model which I have saved using saveRDS() in .rda format.
For eg, I trained model as:
gamlss_model<- gamlss(res~pb(x)+pb(y), family=BCTo, data = test)
When I load the above model after clearing all env variables, and use predict function for new data:
predict(model_old, newdata = new_data)
I get below error:
Error in eval(Call$data) : object 'test' not found
But this test is old dataset which shouldn't have any significance here. I am not able to understand what's wrong with this. Because of this, I cannot run REST API.
When all my env variables are there after GAMLSS model is trained, then when I use predict immediately, it works! But I want to use predictions for later.
Try
predict(model_old, newdata = new_data, data = NULL)I am not sure whether that will work because I haven't worked with gamlss, but according to the documentation
predict.gamlssreferences the data that was used for fitting for whatever reason. If the NULL solution doesn't work, also loading the test data into the active session should do the trick.