Error using posterior_epred with multivariate model

Hi,

I’ve fit a multivariate model where different parts of the dataset are modeled separately using the subset() function; however when I try to use posterior_epred to get by-subject BLUPs, I get an error

"Error: All rows of 'data' were removed via 'subset'. Please make sure that variables do not contain NAs for observations in which they are supposed to be used. Please also make sure that each subset variable is TRUE for at least one observation.

In the dataset I’m predicting on, I have basically the same setup as in the original dataset I fit the model to, except just one row per subject. The code I’m using is

b_e ← posterior_epred(multivar, newdata = blick_persons_e, scale = “linear”,re_formula = ~(1|SubjectID), resp = “factorResponseblickorderedTRUE”)

Hi,
sorry for not getting to you earlier - did you manage to resolve this in the meantime?

Just to take the obvious possibility first: are you sure that the new data (blick_persons_e) don’t have all rows removed due to the subset clauses you used when fitting the model? If yes, could you share (a subset of) the data and the full model formula to let me reproduce the issue on my computer?

Best of luck with your model!

1 Like

Hi Martin,

Thanks for checking back in - I did manage to fix the problem in the meantime, sorry to not update it here! The situation was that since my model was multivariate, I think it didn’t like the fact that my blick_persons_e dataframe didn’t have any rows where the other variable evaluated to true with subset (if that makes sense…).

Basically what I did was just create a “dummy” row in the blick_persons_e dataframe with NA values for everything except the term evaluated by subset(), which I set such that the other DV had at least one row where subset() was true. Then it worked fine; the dummy row wasn’t even in the output dataframe, so I assume this was just a glitch.

Thanks!
Canaan

1 Like