The function HYPERPO()
defines the
hyper Poisson distribution
a two parameter distribution,
for a gamlss.family
object to be used in GAMLSS
fitting using the function gamlss()
.
HYPERPO(mu.link = "log", sigma.link = "log")
Returns a gamlss.family
object which can be used
to fit a hyper-Poisson distribution
in the gamlss()
function.
The hyper-Poisson distribution with parameters \(\mu\) and \(\sigma\) has a support 0, 1, 2, ... and density given by
\(f(x | \mu, \sigma) = \frac{\mu^x}{_1F_1(1;\mu;\sigma)}\frac{\Gamma(\sigma)}{\Gamma(x+\sigma)}\)
where the function \(_1F_1(a;c;z)\) is defined as
\(_1F_1(a;c;z) = \sum_{r=0}^{\infty}\frac{(a)_r}{(c)_r}\frac{z^r}{r!}\)
and \((a)_r = \frac{\gamma(a+r)}{\gamma(a)}\) for \(a>0\) and \(r\) positive integer.
Note: in this implementation we changed the original parameters \(\lambda\) and \(\gamma\) for \(\mu\) and \(\sigma\) respectively, we did it to implement this distribution within gamlss framework.
Sáez-Castillo, A. J., & Conde-Sánchez, A. (2013). A hyper-Poisson regression model for overdispersed and underdispersed count data. Computational Statistics & Data Analysis, 61, 148-157.
# Example 1
# Generating some random values with
# known mu and sigma
set.seed(1234)
y <- rHYPERPO(n=200, mu=10, sigma=1.5)
# Fitting the model
library(gamlss)
mod1 <- gamlss(y~1, sigma.fo=~1, family=HYPERPO,
control=gamlss.control(n.cyc=500, trace=TRUE))
#> GAMLSS-RS iteration 1: Global Deviance = 1024.801
# Extracting the fitted values for mu and sigma
# using the inverse link function
exp(coef(mod1, what="mu"))
#> (Intercept)
#> 9.66078
exp(coef(mod1, what="sigma"))
#> (Intercept)
#> 1.281153
# Example 2
# Generating random values under some model
# A function to simulate a data set with Y ~ HYPERPO
gendat <- function(n) {
x1 <- runif(n)
x2 <- runif(n)
mu <- exp(1.21 - 3 * x1) # 0.75 approximately
sigma <- exp(1.26 - 2 * x2) # 1.30 approximately
y <- rHYPERPO(n=n, mu=mu, sigma=sigma)
data.frame(y=y, x1=x1, x2=x2)
}
set.seed(1234)
dat <- gendat(n=100)
mod2 <- gamlss(y~x1, sigma.fo=~x2, family=HYPERPO, data=dat,
control=gamlss.control(n.cyc=500, trace=TRUE))
#> GAMLSS-RS iteration 1: Global Deviance = 227.5195
#> GAMLSS-RS iteration 2: Global Deviance = 226.6622
#> GAMLSS-RS iteration 3: Global Deviance = 225.8377
#> GAMLSS-RS iteration 4: Global Deviance = 225.021
#> GAMLSS-RS iteration 5: Global Deviance = 224.2109
#> GAMLSS-RS iteration 6: Global Deviance = 223.4426
#> GAMLSS-RS iteration 7: Global Deviance = 222.7289
#> GAMLSS-RS iteration 8: Global Deviance = 222.0889
#> GAMLSS-RS iteration 9: Global Deviance = 221.5224
#> GAMLSS-RS iteration 10: Global Deviance = 221.0354
#> GAMLSS-RS iteration 11: Global Deviance = 220.629
#> GAMLSS-RS iteration 12: Global Deviance = 220.293
#> GAMLSS-RS iteration 13: Global Deviance = 220.0312
#> GAMLSS-RS iteration 14: Global Deviance = 219.8322
#> GAMLSS-RS iteration 15: Global Deviance = 219.6854
#> GAMLSS-RS iteration 16: Global Deviance = 219.5778
#> GAMLSS-RS iteration 17: Global Deviance = 219.5003
#> GAMLSS-RS iteration 18: Global Deviance = 219.447
#> GAMLSS-RS iteration 19: Global Deviance = 219.409
#> GAMLSS-RS iteration 20: Global Deviance = 219.3824
#> GAMLSS-RS iteration 21: Global Deviance = 219.3638
#> GAMLSS-RS iteration 22: Global Deviance = 219.3511
#> GAMLSS-RS iteration 23: Global Deviance = 219.3423
#> GAMLSS-RS iteration 24: Global Deviance = 219.3364
#> GAMLSS-RS iteration 25: Global Deviance = 219.3324
#> GAMLSS-RS iteration 26: Global Deviance = 219.3296
#> GAMLSS-RS iteration 27: Global Deviance = 219.3276
#> GAMLSS-RS iteration 28: Global Deviance = 219.3263
#> GAMLSS-RS iteration 29: Global Deviance = 219.3255
summary(mod2)
#> Warning: summary: vcov has failed, option qr is used instead
#> ******************************************************************
#> Family: c("HYPERPO", "Hyper-Poisson")
#>
#> Call: gamlss(formula = y ~ x1, sigma.formula = ~x2, family = HYPERPO,
#> data = dat, control = gamlss.control(n.cyc = 500, trace = TRUE))
#>
#> Fitting method: RS()
#>
#> ------------------------------------------------------------------
#> Mu link function: log
#> Mu Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 0.8193 0.1822 4.497 1.90e-05 ***
#> x1 -3.0455 0.5279 -5.769 9.32e-08 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> ------------------------------------------------------------------
#> Sigma link function: log
#> Sigma Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 0.8514 0.3645 2.336 0.021532 *
#> x2 -2.5333 0.6995 -3.622 0.000466 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> ------------------------------------------------------------------
#> No. of observations in the fit: 100
#> Degrees of Freedom for the fit: 4
#> Residual Deg. of Freedom: 96
#> at cycle: 29
#>
#> Global Deviance: 219.3255
#> AIC: 227.3255
#> SBC: 237.7461
#> ******************************************************************