'no matches bug' for posterior_predict

I encountered a “no matches bug” error while trying to do a posterior_predict for a new data frame. It worked for one HB model, but not another. (Both models ran with no error.)

What might be the reason for this? Thanks in advance.

  • pasky

Weird labels for the grouping factor. Try to choose label names that do not have spaces or special characters besides the underscore.

That may not be it, Ben. Here’s the code generating the error:


#(lDO and lWTEMP, “l” reminds me these are logged values)

xdata1 <- data.frame(
PH = c(7,8),lPC = c(-1,0),lTP = c(-3,-2),lTN=c(-5,-3)
,NR = c(3,6),season = ‘summer’,Sbin = ‘1’
#,lWTEMP = c(2.2,2.7)
,lDO = 2

xdata2 <- data.frame(
PH = c(7,8),lPC = c(-1,0),lTP = c(-3,-2),lTN=c(-5,-3)
,NR = c(3,6),season = ‘summer’,Sbin = ‘1’
,lWTEMP = c(2.2,2.7)
#,lDO = 2

y_rep <- posterior_predict(hb1,xdata1)

y_rep <- posterior_predict(hb2,xdata2)

Follow up question:
For the first y_rep, 2 columns were generated. What do these columns represent and, as a corollary, how does the line ‘apply(y_rep, 1, diff)’ generate the predictions/simulations I’m looking for?

Thanks so much.

posterior_predict yields a matrix that is simulations by observations. Here, xdata* has two observations, so you get two columns in y_rep. Then apply(y_rep, 1, diff) is a complicated way to do y_rep[,2] - y_rep[,1].

Thanks, Ben. Any thoughts on why posterior_predict is generating that error for hb2?

Probably the poly thing, which is somewhat unnecessary given that you are wisely specifying QR = TRUE. Just created the squared and cubed terms manually before putting them into your model.

Okay. I’ll give it a try and see if that works. But note that hb1 also has the polynomial form. I’ll let you know if squaring and cubing does the trick. (Parenthetically, I should also note that the poly function creates orthogonal polynomials, thereby minimizing correlation among the poly coefficients.) Thanks for the help.

Right. The QR = TRUE argument does the same thing but for all of the predictors including the interactive terms.

Ahh, right. I just ran another model, to include both Water Temperature and Dissolved Oxygen. Posterior_Predict worked fine, even with the poly form. Model results look GREAT!! But…1 Divergent Transition, even with adapt_delta = 0.9999. Would the estimates still be unreliable with just 1 DT?

I would still try to get rid of it, but when you do, it likely won’t make a noticeable difference.