mitchelloharawild / distributional

Vectorised distributions for R
https://pkg.mitchelloharawild.com/distributional
GNU General Public License v3.0
97 stars 15 forks source link

Actuar package (>=v2.0) required for tests #65

Closed apeterson91 closed 3 years ago

apeterson91 commented 3 years ago

The actuar package is required for a successful completion of all tests. I think it should be moved from the Suggests to Imports for your package's DESCRIPTION file. Further, not all versions of actuar will satisfy the tests as functions like qgumbel() are not available in v1.2.0 of the actuar package.

See reprex of testing suit in fresh clone of current distributaional repo below.

devtools::test(pkg = "~/Documents/Rpackages/distributional/")
#> ℹ Loading distributional
#> ℹ Testing distributional
#> v |  OK F W S | Context
#> ⠏ |   0       | apply                                                           v |  13       | apply
#> ⠏ |   0       | dist-bernoulli                                                  v |  10       | dist-bernoulli
#> ⠏ |   0       | dist-beta                                                       v |  10       | dist-beta
#> ⠏ |   0       | dist-burr                                                       x |   1 1     | dist-burr
#> --------------------------------------------------------------------------------
#> Error (test-dist-burr.R:7:3): Burr distribution
#> Error: The `actuar` package must be installed to use this functionality. It can be installed with install.packages("actuar")
#> Backtrace:
#>   1. testthat::expect_equal(quantile(dist, 0.1), 0.378192136090135) test-dist-burr.R:7:2
#>   5. distributional::quantile.distribution(dist, 0.1)
#>   6. distributional::dist_apply(x, quantile, p = p, ...) /Users/adam/Documents/Rpackages/distributional/R/distribution.R:91:2
#>  10. distributional::quantile.dist_burr(dots[[1L]][[1L]], p = dots[[2L]][[1L]])
#>  11. distributional::require_package("actuar") /Users/adam/Documents/Rpackages/distributional/R/dist_burr.R:58:2
#> --------------------------------------------------------------------------------
#> ⠏ |   0       | dist-cauchy                                                     v |  10       | dist-cauchy
#> ⠏ |   0       | dist-chisq                                                      v |  10       | dist-chisq
#> ⠏ |   0       | dist-degenerate                                                 v |  15       | dist-degenerate
#> ⠏ |   0       | dist-exponential                                                v |  10       | dist-exponential
#> ⠏ |   0       | dist-f                                                          v |  12       | dist-f
#> ⠏ |   0       | dist-gamma                                                      v |  10       | dist-gamma
#> ⠏ |   0       | dist-geometric                                                  v |  10       | dist-geometric
#> ⠏ |   0       | dist-gumbel                                                     x |   1 1     | dist-gumbel
#> --------------------------------------------------------------------------------
#> Error (test-dist-gumbel.R:7:3): Gumbel distribution
#> Error: The `actuar` package must be installed to use this functionality. It can be installed with install.packages("actuar")
#> Backtrace:
#>   1. testthat::expect_equal(quantile(dist, 0.1), -0.668064890495911) test-dist-gumbel.R:7:2
#>   5. distributional::quantile.distribution(dist, 0.1)
#>   6. distributional::dist_apply(x, quantile, p = p, ...) /Users/adam/Documents/Rpackages/distributional/R/distribution.R:91:2
#>  10. distributional::quantile.dist_gumbel(dots[[1L]][[1L]], p = dots[[2L]][[1L]])
#>  11. distributional::require_package("actuar") /Users/adam/Documents/Rpackages/distributional/R/dist_gumbel.R:103:2
#> --------------------------------------------------------------------------------
#> ⠏ |   0       | dist-hypergeometric                                             v |  10       | dist-hypergeometric
#> ⠏ |   0       | dist-inverse-exponential                                        x |   1 1     | dist-inverse-exponential
#> --------------------------------------------------------------------------------
#> Error (test-dist-inverse-exponential.R:7:3): Inverse Exponential distribution
#> Error: The `actuar` package must be installed to use this functionality. It can be installed with install.packages("actuar")
#> Backtrace:
#>   1. testthat::expect_equal(quantile(dist, 0.1), 0.0868588963806504) test-dist-inverse-exponential.R:7:2
#>   5. distributional::quantile.distribution(dist, 0.1)
#>   6. distributional::dist_apply(x, quantile, p = p, ...) /Users/adam/Documents/Rpackages/distributional/R/distribution.R:91:2
#>  10. distributional::quantile.dist_inverse_exponential(...)
#>  11. distributional::require_package("actuar") /Users/adam/Documents/Rpackages/distributional/R/dist_inverse_exponential.R:49:2
#> --------------------------------------------------------------------------------
#> ⠏ |   0       | dist-inverse-gamma                                              x |   1 1     | dist-inverse-gamma
#> --------------------------------------------------------------------------------
#> Error (test-dist-inverse-gamma.R:7:3): Inverse Gamma distribution
#> Error: The `actuar` package must be installed to use this functionality. It can be installed with install.packages("actuar")
#> Backtrace:
#>   1. testthat::expect_equal(quantile(dist, 0.1), 0.0939439883852355) test-dist-inverse-gamma.R:7:2
#>   5. distributional::quantile.distribution(dist, 0.1)
#>   6. distributional::dist_apply(x, quantile, p = p, ...) /Users/adam/Documents/Rpackages/distributional/R/distribution.R:91:2
#>  10. distributional::quantile.dist_inverse_gamma(...)
#>  11. distributional::require_package("actuar") /Users/adam/Documents/Rpackages/distributional/R/dist_inverse_gamma.R:54:2
#> --------------------------------------------------------------------------------
#> ⠏ |   0       | dist-inverse-gaussian                                           x |   1 1     | dist-inverse-gaussian
#> --------------------------------------------------------------------------------
#> Error (test-dist-inverse-gaussian.R:7:3): Inverse Gaussian distribution
#> Error: The `actuar` package must be installed to use this functionality. It can be installed with install.packages("actuar")
#> Backtrace:
#>   1. testthat::expect_equal(quantile(dist, 0.1), 0.0711412412200721) test-dist-inverse-gaussian.R:7:2
#>   5. distributional::quantile.distribution(dist, 0.1)
#>   6. distributional::dist_apply(x, quantile, p = p, ...) /Users/adam/Documents/Rpackages/distributional/R/distribution.R:91:2
#>  10. distributional::quantile.dist_inverse_gaussian(...)
#>  11. distributional::require_package("actuar") /Users/adam/Documents/Rpackages/distributional/R/dist_inverse_gaussian.R:54:2
#> --------------------------------------------------------------------------------
#> ⠏ |   0       | dist-logarithmic                                                x |   1 1     | dist-logarithmic
#> --------------------------------------------------------------------------------
#> Error (test-dist-logarithmic.R:7:3): Logarithmic distribution
#> Error: The `actuar` package must be installed to use this functionality. It can be installed with install.packages("actuar")
#> Backtrace:
#>   1. testthat::expect_equal(quantile(dist, 0.5), 1) test-dist-logarithmic.R:7:2
#>   5. distributional::quantile.distribution(dist, 0.5)
#>   6. distributional::dist_apply(x, quantile, p = p, ...) /Users/adam/Documents/Rpackages/distributional/R/distribution.R:91:2
#>  10. distributional::quantile.dist_logarithmic(dots[[1L]][[1L]], p = dots[[2L]][[1L]])
#>  11. distributional::require_package("actuar") /Users/adam/Documents/Rpackages/distributional/R/dist_logarithmic.R:49:2
#> --------------------------------------------------------------------------------
#> ⠏ |   0       | dist-logistic                                                   v |  10       | dist-logistic
#> ⠏ |   0       | dist-multinomial                                                v |   4       | dist-multinomial
#> ⠏ |   0       | dist-multivariate-normal                                        v |   9       | dist-multivariate-normal
#> ⠏ |   0       | dist-negative-binomial                                          v |  10       | dist-negative-binomial
#> ⠏ |   0       | dist-normal                                                     v |  19       | dist-normal
#> ⠏ |   0       | dist-pareto                                                     x |   1 1     | dist-pareto
#> --------------------------------------------------------------------------------
#> Error (test-dist-pareto.R:7:3): Pareto distribution
#> Error: The `actuar` package must be installed to use this functionality. It can be installed with install.packages("actuar")
#> Backtrace:
#>   1. testthat::expect_equal(quantile(dist, 0.1), 0.0105917512032914) test-dist-pareto.R:7:2
#>   5. distributional::quantile.distribution(dist, 0.1)
#>   6. distributional::dist_apply(x, quantile, p = p, ...) /Users/adam/Documents/Rpackages/distributional/R/distribution.R:91:2
#>  10. distributional::quantile.dist_pareto(dots[[1L]][[1L]], p = dots[[2L]][[1L]])
#>  11. distributional::require_package("actuar") /Users/adam/Documents/Rpackages/distributional/R/dist_pareto.R:54:2
#> --------------------------------------------------------------------------------
#> ⠏ |   0       | dist-percentile                                                 v |   6       | dist-percentile
#> ⠏ |   0       | dist-poisson-inverse-gaussian                                   x |   1 1     | dist-poisson-inverse-gaussian
#> --------------------------------------------------------------------------------
#> Error (test-dist-poisson-inverse-gaussian.R:7:3): Poisson Inverse Gaussian distribution
#> Error: The `actuar` package must be installed to use this functionality. It can be installed with install.packages("actuar")
#> Backtrace:
#>   1. testthat::expect_equal(quantile(dist, 0.1), 0) test-dist-poisson-inverse-gaussian.R:7:2
#>   5. distributional::quantile.distribution(dist, 0.1)
#>   6. distributional::dist_apply(x, quantile, p = p, ...) /Users/adam/Documents/Rpackages/distributional/R/distribution.R:91:2
#>  10. distributional::quantile.dist_poisson_inverse_gaussian(...)
#>  11. distributional::require_package("actuar") /Users/adam/Documents/Rpackages/distributional/R/dist_poisson_inverse_gaussian.R:54:2
#> --------------------------------------------------------------------------------
#> ⠏ |   0       | dist-sample                                                     v |   7       | dist-sample
#> ⠏ |   0       | dist-student-t                                                  v |  40       | dist-student-t
#> ⠏ |   0       | dist-studentised-range                                          v |   6       | dist-studentised-range
#> ⠏ |   0       | dist-uniform                                                    v |  10       | dist-uniform
#> ⠏ |   0       | dist-weibull                                                    v |  10       | dist-weibull
#> ⠏ |   0       | distribution                                                    v |   9       | distribution

#> ⠏ |   0       | graphics                                                        ⠋ |   1       | graphics                                                        ⠴ |   6       | graphics                                                        ⠋ |  11       | graphics                                                        ⠸ |  14       | graphics                                                        v |  16       | graphics [1.3 s]
#> ⠏ |   0       | hilo                                                            v |  10       | hilo
#> ⠏ |   0       | inflated                                                        v |  22       | inflated
#> ⠏ |   0       | issues                                                          v |   3       | issues
#> ⠏ |   0       | mixture                                                         v |  20       | mixture
#> ⠏ |   0       | transformations                                                 v |  15       | transformations
#> ⠏ |   0       | truncated                                                       v |  20       | truncated
#> 
#> == Results =====================================================================
#> Duration: 1.7 s
#> 
#> [ FAIL 8 | WARN 0 | SKIP 0 | PASS 374 ]

Created on 2021-09-28 by the reprex package (v2.0.0)

mitchelloharawild commented 3 years ago

Thanks, these tests are now skipped if actuar is not available.

zoj613 commented 2 years ago

@mitchelloharawild I just noticed that the inverse-gaussian distribution uses actuar instead of the more recent and likely more accurate statmod. Would it be possible to "upgrade" to statmod or is there a particular reason actuar is used instead?

References

1) https://arxiv.org/abs/1603.06687 2) https://cran.r-project.org/web/packages/statmod/index.html