Package 'poistweedie'

Title: Poisson-Tweedie Exponential Family Models
Description: Simulation of models Poisson-Tweedie.
Authors: David Pechel Cactcha, Laure Pauline Fotso and Celestin C Kokonendji
Maintainer: David Pechel Cactcha <[email protected]>
License: GPL (>= 2)
Version: 1.0.2
Built: 2024-12-01 08:34:55 UTC
Source: CRAN

Help Index


The individual probabilities of Y when Y follows a Poisson-Tweedie Distributions

Description

Let X be a non-negative random variable following TP(θ,λ)\mathcal{T}_{P}(\theta , \lambda). If a discrete random variable Y is such that the conditional distribution of Y given X is Poisson with mean X, then the EDM generated by the distribution of Y is of the Poisson-Tweedie class. For p>=1p>=1 individual probabilities of YPTP(θ,λ)Y\sim\mathcal{P\mathcal{T}_{P}(\theta ,\lambda )} when Y follows a Poisson-Tweedie Distributions are: Pr(Y=y)=0exxyy!TP(θ,λ)d(x),y=0,1,Pr(Y=y)=\int_{0}^{\infty}\frac{e^{-x}x^{y}}{y!}\mathcal{T}_{P}(\theta , \lambda)d(x), y=0,1,.
For p = 1, it is a Neyman type A distribution; for 1<p<21<p<2 , then Poisson-compound Poisson distribution is obtained; for p = 2,the Poisson-Tweedie model PT2(μ,λ)PT_{2}\left(\mu,\lambda\right) correspond to the negative binomiale law BN(λ,11+μ)BN\left( \lambda,\frac{1}{1+\mu}\right); and, for p = 3, it is the Sichel or Poisson-inverse Gaussian distribution (e.g. Willmot, 1987). Also, when pp\longrightarrow\infty, λ=μ×(1θ0)1+μ\lambda=\frac{\mu\times\left( 1-\theta_{0}\right) }{1+\mu} and the λ=μθ0\lambda=\mu\simeq-\theta_{0} , the Poisson-Tweedie model PTp(μ,λ)PT_{p}\left( \mu,\lambda\right) correspond to the poisson law Py(λ2)P_{y}\left( \lambda^{2}\right).

Usage

dpoistweedie(y, p, mu, lambda, theta0, log)
       densitept1(p, n, mu, lambda, theta0)
       densitept2(p, n, mu, lambda, theta0)
       dpt1(p, n, mu, lambda, theta0)
       dpt1Log(p, n, mu, lambda, theta0)
       dpt2(p, n, mu, lambda, theta0)
       dpt2Log(p, n, mu, lambda, theta0)
       dptp(p, n, mu, lambda, theta0)
       dptpLog(p, n, mu, lambda, theta0)
       gam1.1(y, lambda)
       gam1.2(y, lambda)
       imfx0(x0,p,mu,theta0)
       moyennePT(p,omega,theta0)
       omega(p,mu,theta0)
       testOmegaPT(p,n)

Arguments

y

vector of (non-negative integer) quantiles Y=(y1,y2,...,yn) where  yii=1,2,...,nY=(y1,y2,...,yn) \ where \ \ yi i=1,2,...,n are the integer.

p

is a real index related to a precise model p>=1p>=1.

n

non-negative integer (length of y)

x0

is a real index

mu

the meanμR+\mu\in{R}^{+}, .

omega

is a real index.ωR\omega\in{R}

lambda

the dispersion parameter λR,λ>0\lambda\in{R},\lambda>0.

theta0

the canonical parameter θ0R\theta_{0}\in{R}^{-}.

log

logical; if TRUE, probabilities y are given as log(y).

Details

The Poisson-Tweedie distributions arethe EDMs with a variance of the form VpPT(μ)=μ+μpexp{(2p)Φp(μ)},μ>0V_{p}^{\mathcal{PT}}\left( \mu\right) =\mu+\mu^{p}\exp\left\{ \left(2-p\right) \Phi_{p}\left( \mu\right) \right\} ,\mu>0, where Φp(μ)\Phi_{p}\left( \mu\right) a generally implicit, denotes the inverse of the increansing function ωd{lnIE(ewy)}dw\omega\longrightarrow\frac{d\left\{ \ln IE\left( e^{wy}\right) \right\}}{dw}. omega(p,mu,theta0) is a function whose permit to determine the value of w.

Value

density (dpoistweedie),for the given Poisson-Tweedie distribution with parameters

Author(s)

Cactha David Pechel, Laure Pauline Fotso and Celestin C Kokonendji Maintainer: Cactha David Pechel ( <[email protected]>)

References

Dunn, Peter K and Smyth, Gordon K (To appear). Series evaluation of Tweedie exponential dispersion model densities Statistics and Computing.

Dunn, Peter K and Smyth, Gordon K (2001). Tweedie family densities: methods of evaluation. Proceedings of the 16th International Workshop on Statistical Modelling, Odense, Denmark, 2–6 July

Hougaard, P., Lee, M-L.T. and Whitmore, G.A. (1997). Analysis of overdispersed count data by mixtures of Poisson variables and Poisson processes, Biometrics 53, 1225–1238

Jorgensen, B. (1987). Exponential dispersion models. Journal of the Royal Statistical Society, B, 49, 127–162.

Kokonendji, C.C., Demeetrio, C.G.B. and Dossou-Gbete, S. (2004). Some discrete exponential dispersion models: Poisson-Tweedie and Hinde-Demetrio classes. SORT: Statistics and Operations Research Transactions 28 (2), 201–214.

See Also

ppoistweedie

Examples

## dpoistweedie(y, power, mu,lambda,theta0,log = FALSE)
## Plot dpois() and dpoistweedie() with  log=FALSE
layout(matrix(1 :1, 1, 1))
layout.show(2) 
power <- exp(10) 
mu <-10
lambda <- 10
theta0<--10
lambda1<-100
y <- 0:200
## plot  dpoistweedie function with log = FALSE
d1<-dpoistweedie(y,power,mu,lambda,theta0,log = FALSE)
d2<-dpois(y,lambda1,log=FALSE)
erreure<-d1-d2
plot (y,d1,col='blue', type='h',xlab="y 
   avec  y=0:200,  power=exp(30),mu=10, lambda=10,
   theta0=-10,  lambda1=100", ylab="densite P(100)",
   main = "dpoistweedie(*,col='blue' log=FALSE)
   et dpois(*,col='red' log=FALSE)")
lines(y,d2,type ="p",col='red',lwd=2)
sum(abs(erreure))



## Plot dnbinom() and dpoistweedie()
layout(matrix(1 :1, 1, 1))
layout.show(2) 
power<-2 
mu<-10
lambda <- 1
theta0<-0
prob<-1-(mu/(1+mu))
y <- seq(0,50, by =3)
## plot a dpoistweedie function with log=FALSE
d1<-dpoistweedie(y,power,mu,lambda,theta0,log=FALSE)
d2<-dnbinom(y,lambda,prob, log=FALSE)
erreure<-d1-d2
plot (y,d1,col='blue', type='h',xlab="y 
   avec  y=seq(0,50,by=3),  power=2,mu=10, 
   lambda=1, thetao=0", ylab="densite NB(1,1/11)"
   ,main = "dnpoistweedie(*,col='blue' log=FALSE)
   et dnbinom(*,col='red' log=FALSE)")
lines(y,d2,type ="p",col='red',lwd=2)
abs(erreure)

Poisson-Tweedie (Some discrete exponential dispersion models)

Description

Density, Log of density, variance for the Poisson-Tweedie family of distributions

Usage

poistweedie(x, n, p, mu, lambda, theta0, lower.tail = TRUE, log.p = FALSE, 
    fonction = "PROBABILITE")
poisson(x, n, p, lambda1, lower.tail = TRUE, log.p = FALSE, 
    fonction = "PROBABILITE")
nbinomiale(x, n, p, lambda1, p1, lower.tail = TRUE, log.p = FALSE, 
    fonction = "PROBABILITE")

Arguments

x

vector of (non-negative integer) quantiles.

p

is a real index related to a precise model.

p1

is a real index related to a precise model.

n

non-negative integer

mu

the mean.

lambda

the dispersion parameter.

lambda1

the dispersion parameter.

theta0

the canonical parameter.

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].

fonction

is a string

Details

Density, Log of density, variance for the Poisson-Tweedie family of distributions

Author(s)

Cactha David Pechel, Laure Pauline Fotso and Celestin C Kokonendji Maintainer: Cactha David Pechel ( <[email protected]>)

See Also

dpoistweedie, ppoistweedie

Examples

## poistweedie(x, n, p, mu, lambda, theta0, lower.tail = TRUE, 
##             log.p = FALSE, fonction = "PROBABILITE")
x <- 0:200
p <- 1.5
mu <-10     
lambda <- 10
theta0<--10
d1<-poistweedie(x, n, p, mu, lambda, theta0, lower.tail = TRUE,
log.p = FALSE, fonction = "PROBABILITE")

Distribution function for the Poisson-Tweedie family

Description

Distribution function, for the Poisson-Tweedie family of distributions

Usage

ppoistweedie(q, p, mu, lambda, theta0, lower.tail, log.p)

Arguments

q

vector of quantiles.

p

is a real index related to a precise model.

mu

the mean.

lambda

the dispersion parameter.

theta0

the canonical parameter.

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 Poisson-Tweedie family of distributions belong to the class of exponential dispersion models (EDMs), famous for their role in generalized linear models.

Value

probability (ppoistweedie), for the given Poisson-Tweedie distribution with parameters

Author(s)

Cactha David Pechel, Laure Pauline Fotso and Celestin C Kokonendji Maintainer: Cactha David Pechel ( <[email protected]>)

See Also

qpoistweedie

Examples

## function ppoistweedie(q, power, mu,lambda,theta0,
## lower.tail = TRUE, log.p = FALSE)
## Plot ppois() et ppoistweedie() avec log.p=FALSE
layout(matrix(1 :1, 1, 1))
layout.show(1)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
power<-exp(30) 
mu<-5
lambda <- 5
theta0<--5
prob<-1-(mu/(1+mu))
lambda1<-lambda^2
q <- 0:100
## function ppoistweedie function with log=FALSE
d1<-ppoistweedie(q,power,mu,lambda,theta0,lower.tail=TRUE,log.p=FALSE)
d2<-ppois(q,lambda1,lower.tail=TRUE,log.p=FALSE)
erreure<- d1-d2
plot (q,d1,col='blue', type='h',xlab="q    
 avec  q=0:100,  power=exp(30),mu=5, lambda=5, 
 theta0=-5, lambda1=25", ylab="fonction de 
 repartition P(25)",main = "ppoistweedie(*,col='blue' log=FALSE)
 et ppois(*,col='red' log=FALSE)")
lines(q,d2,type ="p",col='red',lwd=2)
sum(abs(erreure))

Quantile function for the Poisson-Tweedie family of distributions

Description

Quantile function for the Poisson-Tweedie family of distributions

Usage

qpoistweedie(p1, p, mu, lambda, theta0, lower.tail, log.p)

Arguments

p1

vector of probabilities.

p

is a real index related to a precise model.

mu

the mean.

lambda

the dispersion parameter.

theta0

the canonical parameter.

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 Poisson-Tweedie family of distributions belong to the class of exponential dispersion models (EDMs), famous for their role in generalized linear models. T

Value

quantile (qpoistweedie) for the given Poisson-Tweedie distribution with parameters

Author(s)

Cactha David Pechel, Laure Pauline Fotso and Celestin C Kokonendji Maintainer: Cactha David Pechel ( <[email protected]>)

See Also

poistweedie

Examples

## function qpoistweedie(p, power, mu,lambda,theta0,
## lower.tail = TRUE, log.p = FALSE)
## Plot qpois() and qpoistweedie() with log.p=FALSE
layout(matrix(1 :1, 1, 1))
layout.show(1) 
power<-exp(30) 
mu<-10
lambda <- 10
theta0<--10
prob<-1-(mu/(1+mu))
lambda1<-100
p <- runif(50)
p
## plot of qpoistweedie function with log=FALSE
d1<-ppoistweedie(p,power,mu,lambda,theta0,lower.tail=TRUE,log.p=FALSE)
d2<-ppois(p,lambda1,lower.tail=TRUE,log.p=FALSE)
erreure<- d1-d2
plot (p,d1,col='blue', type='h',xlab="p 
   avec  p=runif(50),  power=exp(30),mu=10, lambda=10, 
   theta0=-10, lambda1=100, lower.tail=TRUE", 
   ylab="quantile function P(100)",main = 
   "qpoistweedie(*,col='blue' log.p=FALSE)
   et qpois(*,col='red' log.p=FALSE)")
lines(p,d2,type ="p",col='red',lwd=2)
sum(abs(erreure))

Random generation for the Poisson-Tweedie family of distributions

Description

Random generation for the Poisson-Tweedie family of distributions

Usage

rpoistweedie(n, p, mu, lambda, theta0)

Arguments

n

number of random values to return.

p

vector of probabilities.

mu

the mean.

lambda

the dispersion parameter.

theta0

the canonical parameter.

Details

The Poisson-Tweedie family of distributions belong to the class of exponential dispersion models (EDMs), famous for their role in generalized linear models.

Value

random sample (rpoistweedie) for the given Poisson-Tweedie distribution with parameters

Author(s)

Cactha David Pechel, Laure Pauline Fotso and Celestin C Kokonendji Maintainer: Cactha David Pechel ( <[email protected]>)

See Also

varpt

Examples

## --------------- function rpoistweedie()---------------- ##
layout(matrix(2 :1, 2,1))
layout.show(2) 
power<-exp(30) 
mu<-10
lambda <- 10
theta0<--10
prob<-1-(mu/(1+mu))
lambda1<-100
n<-10
set.seed(123)
x1<-rpoistweedie(n,power,mu,lambda,theta0)
set.seed(123)
x2<-rpois(n,lambda1)
hist(x1, xlim = c(min(x1),max(x1)), probability = FALSE,
  col ='blue',xlab="modalit\'{e}s: x1",ylab="effectifs ",
  nclass = max(x1) - min(x1),main="Histogramme de x1 
 (lambda=100, n=10)")
hist(x2, xlim = c(min(x2),max(x2)), probability = FALSE, 
  col ='blue',xlab="modalit\'{e}s: x2 ",ylab="effectifs ",
  nclass = max(x2) - min(x2),main="Histogramme de x2 
  (lambda1=100, n=10)")
sum(x2-x1)

variance for the Poisson-Tweedie family of distributions

Description

Variance for the Poisson-Tweedie family of distributions

Usage

varpt(mu, p,  theta0)

Arguments

p

is a real index related to a precise model.

mu

the mean.

theta0

the canonical parameter.

Details

variance for the Poisson-Tweedie family of distributions

Author(s)

Cactha David Pechel, Laure Pauline Fotso and Celestin C Kokonendji Maintainer: Cactha David Pechel ( <[email protected]>)

See Also

dpoistweedie, ppoistweedie

Examples

## plot of variance
layout(matrix(1:1,1,1))
layout.show(1)
mu <- seq(0.001,6,l=100)
var <-varpt(mu,p=5000,theta0=-150)
plot(mu, var, type = "l", col = "green", lwd=1,main="variance(p,mu,theta0=-150)")
grid(nx=1,ny=1, lty=1,lwd=2)
lines(mu,varpt(mu,p=1,theta0=-150), type = "l", col = "blue", lwd=1)
lines(mu,varpt(mu,p=2,theta0=-150), type = "l", col = "black", lwd=1)
lines(mu,varpt(mu,p=1.5,theta0=-150), type = "l", col = "yellow", lwd=1)
lines(mu,varpt(mu,p=2.5,theta0=-150), type = "l", col = "cyan", lwd=1)
lines(mu,varpt(mu,p=3,theta0=-150), type = "l", col = "magenta", lwd=1)
segments(4,2.5,4.5,2.5,col="blue" )
  text(5,2.5,"p=1",cex=0.8)
segments(4,2,4.5,2,col="yellow" )
  text(5,2,"1.5",cex=0.8)
segments(4,1.5,4.5,1.5,col= "black")
  text(5, 1.5,"p=2",cex=0.8)
segments(4,1,4.5,1,col="cyan" )
  text(5, 1,"p=2.5" ,cex=0.8)
segments(4,0.5,4.5,0.5,col="magenta" )
  text(5, 0.5,"p=3" ,cex=0.8) 
segments(4,0,4.5,0,col= "green" )
  text(5, 0,"p=5000",cex=0.8)