I’ve got a model with the following general formula, where there are both smooth, linear, and a group-level term (which reflects repeat observations of y, a test result, among individual patients).
brm( y ~ s( long , lat ) + c + d + ( 1 | group) )
I would like to predict this to a long / lat grid, but I’m not sure of two steps:
what do I put in for group in the prediction grid
in the fitted() call how should I specify how group effects are handled? Looking at the re_formula and allow_new_levels terms, but not sure what’s correct.
My goal is simply predict variation in y over long/lat, but having accounted for group level effects.
When I’ve tried to do this prediction just putting NA for the group term in the grid, I get this error:
Error in names(dat) <- object$term :
‘names’ attribute [3] must be the same length as the vector [2]
I worry about repeated testing of individuals biasing the spatial prediction, so how would I do it if I did not want to ignore the group level effects?
In newdata set group to a value not present in the original data and then specify allow_new_levels = TRUE to account for the uncertainty in the group-level effect.