drizopoulos / GLMMadaptive

GLMMs with adaptive Gaussian quadrature
https://drizopoulos.github.io/GLMMadaptive/
60 stars 14 forks source link

Predictions from a lognormal hurdle #2

Closed LAStarcevich closed 6 years ago

LAStarcevich commented 6 years ago

I have developed a lognormal hurdle model (m) and have a fake dataframe (fakeDF) that contains median values for all but one model covariate to obtain marginal effects plots. I am unable to use the effectPlotData(m,fakeDF) call. I get the following error:

Error in match.arg(sub_model) : 'arg' should be one of “main”, “zero_part”

When I use predict(m, fakeDF,type_pred="response",type ="mean_subject"), I get different predictions as compared to exp(fakeDF %*% beta).

Can you provide any guidance? Thanks -- Leigh Ann Starcevich

drizopoulos commented 6 years ago

Thank for reporting. It was a bug in the effectPlotData() function for models with an extra zero part. It should work now.

Regarding the second question, indeed the predict() method with type_pred="response" returns the predictions on the response scale, which in the case it will be (1 - pi) * mu_nz, where pi denotes the probability of an (extra) zero, and mu_nz denotes the mean of the non-zero part.

LAStarcevich commented 6 years ago

Works like a charm -- thanks for the update and background.