An Error When Generating Out of Sample Prediction with Beta Regression

Please also provide the following information in addition to your question:

  • Operating System: mac OS 10.14.5
  • brms Version: ‘2.9.0’

Here is my code:

off = brm(Ratio ~  PassAtt + PassYards + 
               PassRat + RushAvg +  Receptions + RecYds +  FPTS +Position+

               (1|PlayerId), data = train, cores = 4, family = 'beta',

             prior = set_prior(horseshoe(df = 3, par_ratio = 0.5),class = 'b'),

             algorithm = 'meanfield’)

predict(off, test)

And then I got such an error:

Error: Levels '3625', '3628', '4474', '5863', '6304', '6515', '7377', '7997’,…

I know that this is because the test data frame has new group-levels of (1 | PlayerId). Is there any way of predicting with new levels in beta regression?

Is it possible for you to provide a sample of the data and your test data? I would think you would need to cast the new levels as factors continuing from where the previous levels ended.

Or before your split your data into train/test, you cast all the levels then.

Thanks for the reply. The point is that I can use lme4 with the same formula. The train and test data are very big so I will first try to add levels to the train and test data on my machine.

The predict/fitted functions have an option allow_new_levels that deals with this issue.