Fwd: brms hurdle model with normal distribution instead of lognormal?

298 views
Skip to first unread message

Jessica Zamborain Mason

unread,
Apr 10, 2018, 11:56:40 PM4/10/18
to brms-...@googlegroups.com



Hello brms-users, 

First of all thank you Paul for the brms package!




In summary, I waned to know if there is a hurdle_normal or hurdle_gaussian function, or a function that asumes that the distribution of the non-zero values  in a hurdle model follow a normal distribution.

I have biomass data which I have partitioned by family group. When I do this, some of my family biomass data has zeros (i.e., no individuals of that family recorded at that site). The non-zero biomass values follow a normal distribution (when log-transformed); yet I wanted to account for the zeroes. 

If I fit the hurdle_lognormal function, the model fit doesn't resemble my observed data (ie., all my residuals are positive scattered around 2.5; the fitted values are underestimated) (example attached). 


At the beginging I thought tis was because I was log transforming the data  (log(Biomass)+1)...but if i fit the hurdle_lognormal to my raw data the same thing happens (but with more magnitude).

I really want to know if there is a why of fitting a hurdle model with the brms package (ie.e., bayesian) where the distribution of the non-zero values is normal. I am quite new in this and not sure if this is a "stupid" question. However, I have tried finding an answer to it and not found it and that is why I have decided to contact you.

 I would greatly appreciate if you could point me out a way to proceed. 

Sorry for the matters and thank you
Best regards,

Jessica
-- 

hurdle check.tiff

Paul Buerkner

unread,
Apr 11, 2018, 1:18:47 AM4/11/18
to Jessica Zamborain Mason, brms-users
First of all, the pp_check you attached doesn't look that bad. Maybe hurdle_gamma fits somewhat better.

If you want to fit a hurdle_normal model, you have to use the new custom_family feature of brms (only available in the current dev version from github). See https://github.com/paul-buerkner/brms/blob/master/vignettes/brms_customfamilies.Rmd for a case study.

--
You received this message because you are subscribed to the Google Groups "brms-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+unsubscribe@googlegroups.com.
To post to this group, send email to brms-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brms-users/CAOmULnv3MR%3DfgCzjRXZ8vhXKma%2BESfj-5HErBn9-poyu%3DjF75g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Jessica Zamborain Mason

unread,
Apr 11, 2018, 2:24:01 AM4/11/18
to Paul Buerkner, brms-users
Hello Paul, 
Thank you for your response. 
I have the same problem with the hurdle gamma. The pp_check doesn't look really bad but my fitted values still underestimate my observed values (and this shows my residuals scattered around a positive value, instead of around 0).
I have tried to use the custom_family function and it gives me an error
hurdle_gaussian=custom_family("hurdle_gaussian", dpars=c("mu","sigma", "hu"),
                        links=c("identity", "log", "logit"),
                        lb=c(NA,NA,0),
                        type="real")


--

´¯`·.¸¸.·´¯`·.¸><((((º>·´¯`·.¸¸.·´¯`·.¸><((((º>¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸><((((º>                                   <º((((><¸.·´¯`·.¸¸¸.·´¯`·.¸

·´¯`·.><((((º>¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·><((((º>.¸¸.·´¯`·.¸¸.·´¯`·.¸><((((º>

Jessica Zamborain Mason
PhD Candidate (Fisheries Biology and Management)
ARC Centre of Excellence of Coral Reef Studies
James Cook University, AUSTRALIA.

Paul Buerkner

unread,
Apr 11, 2018, 2:26:51 AM4/11/18
to Jessica Zamborain Mason, brms-users
the vignette contains all the information you need but it is certainly an advanced feature. in particular you will need to write the related custom Stan functions yourself. in the future please always write what the error message is. 

To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+...@googlegroups.com.

Jessica Zamborain Mason

unread,
Apr 11, 2018, 2:26:58 AM4/11/18
to Paul Buerkner, brms-users
Sorry for the previous message.

 Following on:

Hello Paul, 
Thank you for your response. 
I have the same problem with the hurdle gamma. The pp_check doesn't look really bad but my fitted values still underestimate my observed values (and this shows my residuals scattered around a positive value, instead of around 0).

I have tried to use the custom_family function and it gives me an error
hurdle_gaussian=custom_family("hurdle_gaussian", dpars=c("mu","sigma", "hu"),
                        links=c("identity", "log", "logit"),
                        lb=c(NA,NA,0),
                        type="real")

"Error in custom_family("hurdle_gaussian", dpars = c("mu", "sigma", "hu"),  : 
  could not find function "custom_family" 

Do I need another package for this? I have been looking on the web and I can only fis your documentation
Srry for the matters and thank you!
Best regards,
Jessica

Paul Buerkner

unread,
Apr 11, 2018, 2:33:51 AM4/11/18
to Jessica Zamborain Mason, brms-users
you need the dev version of brms from GitHub not the cran version.

To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+...@googlegroups.com.




--


Jessica Zamborain Mason

unread,
Apr 11, 2018, 2:39:19 AM4/11/18
to Paul Buerkner, brms-users
Thank you very much! 
I will give it a try!
Best regards,
Jessica

To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+unsubscribe@googlegroups.com.




--




Reply all
Reply to author
Forward
0 new messages