KIGEOM {gamlss.countKinf} | R Documentation |
K-inflated Geometric distributions for fitting a GAMLSS model
Description
The function KIGEOM
defines the K-inflated Geometric distribution,
a two parameter distribution, for a gamlss.family
object to be used in GAMLSS fitting using the function gamlss()
. The functions dKIGEOM
, pKIGEOM
, qKIGEOM
and rKIGEOM
define the density, distribution function, quantile function and random generation for the K-inflated Geometric,
KIGEOM()
, distribution.
Usage
KIGEOM(mu.link = "log", sigma.link = "logit", kinf="K")
dKIGEOM(x, mu = 1, sigma = 0.1, kinf=0, log = FALSE)
pKIGEOM(q, mu = 1, sigma = 0.1, kinf=0, lower.tail = TRUE, log.p = FALSE)
qKIGEOM(p, mu = 1, sigma = 0.1, kinf=0, lower.tail = TRUE, log.p = FALSE)
rKIGEOM(n, mu = 1, sigma = 0.1, kinf=0)
Arguments
mu.link |
Defines the |
sigma.link |
Defines the |
x |
vector of (non-negative integer) quantiles |
mu |
vector of positive means |
sigma |
vector of inflated point probability |
p |
vector of probabilities |
q |
vector of quantiles |
n |
number of random values to return |
kinf |
defines inflated point in generating K-inflated distribution |
log , log.p |
logical; if TRUE, probabilities p are given as log(p) |
lower.tail |
logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x] |
Details
The definition for the K-inflated Geometric distribution.
Value
The functions KIGEOM
return a gamlss.family
object which can be used to fit K-inflated Geometric distribution in the gamlss()
function.
Author(s)
Saeed Mohammadpour <s.mohammadpour1111@gamlil.com>, Mikis Stasinopoulos <d.stasinopoulos@londonmet.ac.uk>
References
Rigby, R. A. and Stasinopoulos D. M. (2005). Generalized additive models for location, scale and shape,(with discussion),Appl. Statist.,54, part 3, pp 507-554.
Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use the GAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (see also http://www.gamlss.org/).
Stasinopoulos D. M. Rigby R.A. (2007) Generalized additive models for location scale and shape (GAMLSS) in R.Journal of Statistical Software, Vol. 23, Issue 7, Dec 2007, http://www.jstatsoft.org/v23/i07.
Rigby, R. A. and Stasinopoulos D. M. (2010) The gamlss.family distributions, (distributed with this package or seehttp://www.gamlss.org/)
Stasinopoulos D. M., Rigby R.A., Heller G., Voudouris V., and De Bastiani F., (2017)Flexible Regression and Smoothing: Using GAMLSS in R, Chapman and Hall/CRC.
Najafabadi, A. T. P. and MohammadPour, S. (2017). A k-Inflated Negative Binomial Mixture Regression Model: Application to Rate-Making Systems. Asia-Pacific Journal of Risk and Insurance, 12.
See Also
Examples
#--------------------------------------------------------------------------------
# gives information about the default links for the Geometric distribution
KIGEOM()
#--------------------------------------------------------------------------------
# generate zero inflated Geometric distribution
gen.Kinf(family=GEOM, kinf=0)
# generate random sample from zero inflated Geometric distribution
x<-rinf0GEOM(1000,mu=1, sigma=.2)
# fit the zero inflated Geometric distribution using gamlss
data<-data.frame(x=x)
## Not run:
gamlss(x~1, family=inf0GEOM, data=data)
histDist(x, family=inf0GEOM)
## End(Not run)
#--------------------------------------------------------------------------------
# generated one inflated Geometric distribution
gen.Kinf(family=GEOM, kinf=1)
# generate random sample from one inflated Geometric distribution
x<-rinf1GEOM(1000,mu=1, sigma=.2)
# fit the one inflated Geometric distribution using gamlss
data<-data.frame(x=x)
## Not run:
gamlss(x~1, family=inf1GEOM, data=data)
histDist(x, family=inf1GEOM)
## End(Not run)
#--------------------------------------------------------------------------------
mu=1; sigma=.2;
par(mgp=c(2,1,0),mar=c(4,4,4,1)+0.1)
#plot the pdf using plot
plot(function(x) dinf1GEOM(x, mu=mu, sigma=sigma), from=0, to=20, n=20+1,
type="h",xlab="x",ylab="f(x)",cex.lab=1.5)
#--------------------------------------------------------------------------------
#plot the cdf using plot
cdf <- stepfun(0:19, c(0,pinf1GEOM(0:19, mu=mu, sigma=sigma)), f = 0)
plot(cdf, xlab="x", ylab="F(x)", verticals=FALSE,cex.points=.8, pch=16, main="",cex.lab=1.5)
#--------------------------------------------------------------------------------
#plot the qdf using plot
invcdf <- stepfun(seq(0.01,.99,length=19),qinf1GEOM(seq(0.1,.99,length=20),mu, sigma), f = 0)
plot(invcdf, ylab=expression(x[p]==F^{-1}(p)), do.points=FALSE,verticals=TRUE,
cex.points=.8, pch=16, main="",cex.lab=1.5, xlab="p")
#--------------------------------------------------------------------------------
# generate random sample
Ni <- rinf1GEOM(1000, mu=mu, sigma=sigma)
hist(Ni,breaks=seq(min(Ni)-0.5,max(Ni)+0.5,by=1),col="lightgray", main="",cex.lab=2)
barplot(table(Ni))
#--------------------------------------------------------------------------------