fhui28 / CBFM

Spatio-temporal joint species distribution modeling using community-level basis functions
13 stars 2 forks source link

Residual plotting issues for hurdle and ztnb fits... #24

Closed chrishaak closed 2 years ago

chrishaak commented 2 years ago

When attempting to plot the residuals for a fitted ztnb model, [i.e., plot(fit_CBFM_ztnb), I get the following error: Error in NBI() : could not find function "NBI" I think you mentioned at one point that this may be related to a gamlss dependency?

Likewise, when plotting a hurdle CBFM object [i.e., plot(fit_CBFM_hurdle)], I intermittently (more often than not) get the following error when it reaches the normal probability plot:

Constructing (approximate) simulation envelopes for normal probability plot... Error in tquantile(tdigest(x, 1000), probs = c(0.025, 0.975)) :   !is_null_xptr(td) is not TRUE

This seems to be specific to the hurdle fit but it may be related to this specific model fit, which has some wonky values for a few species?

Also to be noted - the "$deviance_explained" slot is empty in hurdle cbfm objects....

fhui28 commented 2 years ago

Thanks for finding these Chris!

When attempting to plot the residuals for a fitted ztnb model, [i.e., plot(fit_CBFM_ztnb), I get the following error: Error in NBI() : could not find function "NBI" I think you mentioned at one point that this may be related to a gamlss dependency?

Fixed on github.

Likewise, when plotting a hurdle CBFM object [i.e., plot(fit_CBFM_hurdle)], I intermittently (more often than not) get the following error when it reaches the normal probability plot:

Constructing (approximate) simulation envelopes for normal probability plot... Error in tquantile(tdigest(x, 1000), probs = c(0.025, 0.975)) : !is_null_xptr(td) is not TRUE

Fixed on github. tquantile is meant to be a fast way of constructing quantiles to calculate the simulation envelopes. But it can be occasionally unstable. If it breaks I now fall back to using the base `quantile' function.

Also to be noted - the "$deviance_explained" slot is empty in hurdle cbfm objects....

Pretty much everything is missing from hurdle CBFM objects, because all the hurdle CBFM is just stick the PA and count components together! So by constructions there are no slots for of the usual CBFM objects. Adding things like deviance explained is not high on the to-do list, partly because it is harder to define what you mean by a null hurdle model. I suppose you could mean a double intercept model, but I think this is up for discussion.