Coder Social home page Coder Social logo

gamlss-dev / gamlss.dist Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 3.0 2.21 MB

gamlss.dist: Distributions for Generalized Additive Models for Location Scale and Shape

Home Page: https://CRAN.R-project.org/package=gamlss.dist

R 70.14% HTML 24.39% CSS 0.04% TeX 2.87% C 2.56%

gamlss.dist's People

Contributors

mstasinopoulos avatar zeileis avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

gamlss.dist's Issues

GB2 distribution with strange quantiles for extreme parameter values

I fitted a GB2 distribution to my income data and then got puzzled when examining the parameter estimates. I observed that for parameters similar to c(809.6687, 116.4727, 0.0342, 0.0278), the quantile values returned by qGB2 are somewhat strange. For instance, the 10% Percentile is still 0 which does not make sense to me, in particular when having a look at the associated density function. Also, using the random number generator rGB2 many 0 values are drawn from the distribution.

I compared the results to the ones by the GB2 R package. Here, the quantile values look more reasonable to me for the very same set of GB2 parameters. For standard GB2 parameters, the two packages return identical results but not for some extreme parameter values. Why is that and might this be a potential bug in the gamlss.dist package?

Here, my example code:

##### GB2 Distribution #####

rm(list = ls())

set.seed(79)

library(GB2)
library(gamlss.dist)

params = c(809.6687, 116.4727, 0.0342, 0.0278)
# params = c(1, 1, 1, 0.5)
mu = params[1]
sigma = params[2]
nu = params[3]
tau = params[4]

GB2::qgb2(c(0.1, 0.5, 0.9), shape1 = sigma, scale = mu, shape2 = nu, shape3 = tau)
gamlss.dist::qGB2(c(0.1, 0.5, 0.9), mu = mu, sigma = sigma, nu = nu, tau = tau)

GB2::pgb2(c(10, 100, 1000, 10000), shape1 = sigma, scale = mu, shape2 = nu, shape3 = tau)
gamlss.dist::pGB2(c(10, 100, 1000, 10000), mu = mu, sigma = sigma, nu = nu, tau = tau)

GB2::dgb2(c(10, 100, 1000, 10000), shape1 = sigma, scale = mu, shape2 = nu, shape3 = tau)
gamlss.dist::dGB2(c(10, 100, 1000, 10000), mu = mu, sigma = sigma, nu = nu, tau = tau)


r1 = GB2::rgb2(100000, shape1 = sigma, scale = mu, shape2 = nu, shape3 = tau)
summary(r1)
sum(r1 == 0)
r2 = gamlss.dist::rGB2(100000, mu = mu, sigma = sigma, nu = nu, tau = tau)
summary(r2)
sum(r2 == 0)

pBCCG doesn't handle missing values well

I've found an issue with the BCCG distribution functions. They don't gracefully handle missing values due to the use of any(q < 0), which will return NA if any of its inputs are missing. Here's a reprex, and a comparison to the behaviour of pnorm, which behaves as expected:

# quantiles
q1 = c(0,1)
q2 = c(0,1,NA_real_)

# Expected output: 2 numbers
gamlss.dist::pBCCG(q1, mu = 1, sigma = 1, nu = 0)
#> [1] 0.0 0.5
pnorm(q1, 1, 0.5)
#> [1] 0.02275013 0.50000000

# Expected output: 2 numbers and a missing value. pnorm does this,
# but pBCCG returns an error
gamlss.dist::pBCCG(q2, mu = 1, sigma = 1, nu = 0)
#> Error in if (any(q < 0)) stop(paste("q must be positive", "\n", "")): missing value where TRUE/FALSE needed
pnorm(q2, mean = 1, sd = 0.5)
#> [1] 0.02275013 0.50000000         NA

Created on 2023-09-14 with reprex v2.0.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.