The function NPGL() defines the
Poisson-generalised Lindley distribution,
a two parameter distribution,
for a gamlss.family object to be used in GAMLSS
fitting using the function gamlss().
NPGL(mu.link = "log", sigma.link = "log")Returns a gamlss.family object which can be used
to fit a NPGL distribution
in the gamlss() function.
The Poisson-generalised Lindley distribution with parameters \(\mu\) and \(\sigma\) has support \(x = 0, 1, 2, \ldots\) and probability mass function given by
\(f(x \mid \mu, \sigma)=\frac{\mu^2+\frac{\mu^{\sigma}(\mu+1)^{1-\sigma}\Gamma(x+\sigma)}{\Gamma(\sigma)\Gamma(x+1)}}{(\mu+1)^{x+2}}\)
with \(\mu > 0\) and \(\sigma > 0\).
This distribution is useful for modeling over-dispersed count data.
Note: in this implementation we changed the original parameters \(\theta\) and \(\alpha\) for \(\mu\) and \(\sigma\) respectively, we did it to implement this distribution within gamlss framework.
Altun, E. A new two-parameter discrete poisson-generalized Lindley distribution with properties and applications to healthcare data sets. Comput Stat 36, 2841–2861 (2021). https://doi.org/10.1007/s00180-021-01097-0
# Example 1
# Generating some random values with
# known mu and sigma
set.seed(123)
y <- rNPGL(n=100, mu=20, sigma=2)
# Fitting the model
library(gamlss)
mod1 <- gamlss(y~1, family=NPGL,
control=gamlss.control(n.cyc=500, trace=FALSE))
# Extracting the fitted values for mu and sigma
exp(coef(mod1, what="mu"))
#> (Intercept)
#> 17.14864
exp(coef(mod1, what="sigma"))
#> (Intercept)
#> 1.528697
# Example 2
# Generating random values under some model
# A function to simulate a data set with Y ~ NPGL
gendat <- function(n) {
x1 <- runif(n)
x2 <- runif(n)
mu <- exp(1.7 - 2.8 * x1) # Approx 1.35
sigma <- exp(0.73 + 1 * x2) # Approx 3.42
y <- rNPGL(n=n, mu=mu, sigma=sigma)
data.frame(y=y, x1=x1, x2=x2)
}
set.seed(1234)
datos <- gendat(n=200)
mod2 <- gamlss(y~x1, sigma.fo=~x2, family=NPGL, data=datos,
control=gamlss.control(n.cyc=800, trace=FALSE))
summary(mod2)
#> Warning: summary: vcov has failed, option qr is used instead
#> ******************************************************************
#> Family: c("NPGL", "Poisson-generalised Lindley")
#>
#> Call: gamlss(formula = y ~ x1, sigma.formula = ~x2, family = NPGL,
#> data = datos, control = gamlss.control(n.cyc = 800, trace = FALSE))
#>
#> Fitting method: RS()
#>
#> ------------------------------------------------------------------
#> Mu link function: log
#> Mu Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 1.7977 0.1780 10.10 <2e-16 ***
#> x1 -3.3376 0.2565 -13.01 <2e-16 ***
#> ---
#> 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.5040 0.2235 2.255 0.0252 *
#> x2 0.7650 0.3499 2.187 0.0299 *
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> ------------------------------------------------------------------
#> No. of observations in the fit: 200
#> Degrees of Freedom for the fit: 4
#> Residual Deg. of Freedom: 196
#> at cycle: 88
#>
#> Global Deviance: 685.502
#> AIC: 693.502
#> SBC: 706.6952
#> ******************************************************************