diff --git a/pkg/DESCRIPTION b/pkg/DESCRIPTION index e39d244..dc1854f 100644 --- a/pkg/DESCRIPTION +++ b/pkg/DESCRIPTION @@ -12,7 +12,7 @@ Description: The TRIM model is widely used for estimating growth and decline of at Statistics Netherlands by Jeroen Pannekoek. See for more information about TRIM. -Version: 1.1.4 +Version: 1.1.5 Imports: methods, utils, stats, graphics, grDevices URL: https://github.com/markvanderloo/rtrim BugReports: https://github.com/markvanderloo/rtrim/issues diff --git a/pkg/NEWS b/pkg/NEWS index dbea401..1260781 100644 --- a/pkg/NEWS +++ b/pkg/NEWS @@ -1,3 +1,6 @@ +version 1.1.5 +- Now generates an error when the computed overdispersion is 0, and a warning when overdispersion < 1 (thanks to Oscar Ramírez for proving a data set where this happened) + version 1.1.4 - Fixed a bug caused by auto-removal of empty factorial sites (thanks to Tomás Murray) diff --git a/pkg/R/trim_workhorse.R b/pkg/R/trim_workhorse.R index 6d19dda..3242dee 100644 --- a/pkg/R/trim_workhorse.R +++ b/pkg/R/trim_workhorse.R @@ -732,6 +732,8 @@ trim_workhorse <- function(count, site.id, year, month=NULL, covars=data.frame() } else { df <- sum(nobs) - length(alpha) - length(beta) # degrees of freedom sig2 <<- if (df>0) sum(r^2, na.rm=TRUE) / df else 1.0 + if (sig2 < 1e-7) stop("Overdispersion apparently 0; consider setting overdisp=FALSE") + if (sig2 < 1) warning(sprintf("Overdispersion %.1f <1; consider setting overdisp=FALSE", sig2), call.=FALSE) } if (!is.finite(sig2)) stop("Overdispersion problem") }