Skip to content

Commit

Permalink
Version 1.1.5: now issues error/warning for low or 0 sig2
Browse files Browse the repository at this point in the history
  • Loading branch information
pwbogaart committed Mar 29, 2017
1 parent a6d1670 commit 66d6ee5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Description: The TRIM model is widely used for estimating growth and decline of
at Statistics Netherlands by Jeroen Pannekoek. See
<https://www.cbs.nl/en-gb/society/nature-and-environment/indices-and-trends--trim-->
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
Expand Down
3 changes: 3 additions & 0 deletions pkg/NEWS
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 2 additions & 0 deletions pkg/R/trim_workhorse.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down

0 comments on commit 66d6ee5

Please sign in to comment.