Package 'cpd'

Title: Complex Pearson Distributions
Description: Probability mass function, distribution function, quantile function and random generation for the Complex Triparametric Pearson (CTP) and Complex Biparametric Pearson (CBP) distributions developed by Rodriguez-Avi et al (2003) <doi:10.1007/s00362-002-0134-7>, Rodriguez-Avi et al (2004) <doi:10.1007/BF02778271> and Olmo-Jimenez et al (2018) <doi:10.1080/00949655.2018.1482897>. The package also contains maximum-likelihood fitting functions for these models.
Authors: Silverio Vilchez-Lopez [aut, cre], Maria Jose Olmo-Jimenez [aut], Jose Rodriguez-Avi [aut]
Maintainer: Silverio Vilchez-Lopez <[email protected]>
License: GPL (>= 2)
Version: 0.3.2
Built: 2024-09-17 02:55:37 UTC
Source: https://github.com/cran/cpd

Help Index


The Complex Biparametric Pearson (CBP) Distribution

Description

Probability mass function, distribution function, quantile function and random generation for the Complex Biparametric Pearson (CBP) distribution with parameters bb and γ\gamma.

Usage

dcbp(x, b, gamma)

pcbp(q, b, gamma, lower.tail = TRUE)

qcbp(p, b, gamma, lower.tail = TRUE)

rcbp(n, b, gamma)

Arguments

x

vector of (non-negative integer) quantiles.

b

parameter b (real)

gamma

parameter gamma (positive)

q

vector of quantiles.

lower.tail

if TRUE (default), probabilities are P(X<=x)P(X<=x), otherwise, P(X>x)P(X>x).

p

vector of probabilities.

n

number of observations. If length(n) > 1, the length is taken to be the number required.

Details

The CBP distribution with parameters bb and γ\gamma has pmf

f(xb,γ)=CΓ(ib+x)Γ(ib+x)/(Γ(γ+x)x!),x=0,1,2,...f(x|b,\gamma) = C \Gamma(ib+x) \Gamma(-ib+x) / (\Gamma(\gamma+x) x!), x=0,1,2,...

where ii is the imaginary unit, Γ()\Gamma(·) the gamma function and

C=Γ(γib)Γ(γ+ib)/(Γ(γ)Γ(ib)Γ(ib))C = \Gamma(\gamma-ib) \Gamma(\gamma+ib) / (\Gamma(\gamma) \Gamma(ib) \Gamma(-ib))

the normalizing constant.

The CBP is a particular case of the CTP when a=0a=0.

The mean and the variance of the CBP distribution are E(X)=μ=b2/(γ1)E(X)=\mu=b^2/(\gamma-1) and Var(X)=μ(μ+γ1)/(γ2)Var(X)=\mu(\mu+\gamma-1)/(\gamma-2) so γ>2\gamma > 2.

It is always overdispersed.

Value

dcbp gives the pmf, pcbp gives the distribution function, qcbp gives the quantile function and rcbp generates random values.

References

Jose Rodriguez-Avi J, Conde-Sanchez A, Saez-Castillo AJ (2003). “A new class of discrete distributions with complex parameters.” Stat. Pap., 44, 67–88. doi:10.1007/s00362-002-0134-7.

See Also

Probability mass function, distribution function, quantile function and random generation for the CTP distribution: dctp, pctp, qctp and rctp. Functions for maximum-likelihood fitting of the CBP distribution: fitcbp.

Examples

# Examples for the function dcbp
dcbp(3,2,5)
dcbp(c(3,4),2,5)

# Examples for the function pcbp
pcbp(3,2,3)
pcbp(c(3,4),2,3)

# Examples for the function qcbp
qcbp(0.5,2,3)
qcbp(c(.8,.9),2,3)

# Examples for the function rcbp
rcbp(10,1,3)

Pearson's Chi-squared Test for Count Data

Description

chisq.test2 performs Pearson chi-squared goodness-of-fit test for count data

Usage

chisq.test2(obs, p.esp, npar = NULL, grouping = FALSE)

Arguments

obs

a numeric vector with the counts

p.esp

a numeric vector with the expected probabilities of the same length of obs. They must sum 1.

npar

an integer specifying the number of parameters of the model. By default npar is NULL, so the degrees of freedom of the chi-squared statistics are the number of classes minus 1.

grouping

a logical indicating whether to group in classes with expected frequency greater than or equal to 5. By default grouping is FALSE.

Value

A list with class "htest" containing the following components:

  • statistic: the value of the chi-squared test statistic.

  • df: the degrees of freedom of the approximate chi-squared distribution.

  • p.value: the p-value for the test.

  • observed: the observed counts.

  • observed.grouped: the observed counts grouped in classes with expected frequency greather or equal to 5.

  • expected: the expected counts under the null hypothesis.

  • expected.grouped: the expected counts under the null hypothesis grouped in classes with expected frequency greather or equal to 5.

  • residuals: the Pearson residuals computed as (observed - expected) / sqrt(expected).

Examples

set.seed(123)
x <- rctp(500, -1.5, 1, 2)
table(x)
obs <- c(172, 264, 57, 6, 0, 1)
fit <- fitctp(x)
p.esp <- c(dctp(0:(length(obs)-1),fit$coefficients[1],fit$coefficients[2],
           fit$coefficients[3])[1:(length(obs)-1)],1-sum(dctp(0:(length(obs)-1),
           fit$coefficients[1],fit$coefficients[2],fit$coefficients[3])[1:(length(obs)-1)]))
chisq.test2(obs, p.esp)
chisq.test2(obs, p.esp, grouping = TRUE)
chisq.test2(obs, npar= 3, p.esp)

The Complex Triparametric Pearson (CTP) Distribution

Description

Probability mass function, distribution function, quantile function and random generation for the Complex Triparametric Pearson (CTP) distribution with parameters aa, bb and γ\gamma.

Usage

dctp(x, a, b, gamma)

pctp(q, a, b, gamma, lower.tail = TRUE)

qctp(p, a, b, gamma, lower.tail = TRUE)

rctp(n, a, b, gamma)

Arguments

x

vector of (non-negative integer) quantiles.

a

parameter a (real)

b

parameter b (real)

gamma

parameter γ\gamma (positive)

q

vector of quantiles.

lower.tail

if TRUE (default), probabilities are P(X<=x)P(X<=x), otherwise, P(X>x)P(X>x).

p

vector of probabilities.

n

number of observations. If length(n) > 1, the length is taken to be the number required.

Details

The CTP distribution with parameters aa, bb and γ\gamma has pmf

f(xa,b,γ)=CΓ(a+ib+x)Γ(aib+x)/(Γ(γ+x)x!),x=0,1,2,...f(x|a,b,\gamma) = C \Gamma(a+ib+x) \Gamma(a-ib+x) / (\Gamma(\gamma+x) x!), x=0,1,2,...

where ii is the imaginary unit, Γ()\Gamma(·) the gamma function and

C=Γ(γaib)Γ(γa+ib)/(Γ(γ2a)Γ(a+ib)Γ(aib))C = \Gamma(\gamma-a-ib) \Gamma(\gamma-a+ib) / (\Gamma(\gamma-2a) \Gamma(a+ib) \Gamma(a-ib))

the normalizing constant.

If a=0a=0 the CTP is a Complex Biparametric Pearson (CBP) distribution, so the pmf of the CBP distribution is obtained. If b=0b=0 the CTP is an Extended Biparametric Waring (EBW) distribution, so the pmf of the EBW distribution is obtained.

The mean and the variance of the CTP distribution are E(X)=μ=(a2+b2)/(γ2a1)E(X)=\mu=(a^2+b^2)/(\gamma-2a-1) and Var(X)=μ(μ+γ1)/(γ2a2)Var(X)=\mu(\mu+\gamma-1)/(\gamma-2a-2) so γ>2a+2\gamma > 2a + 2.

It is underdispersed if a<(μ+1)/2a < - (\mu + 1) / 2, equidispersed if a=(μ+1)/2a = - (\mu + 1) / 2 or overdispersed if a>(μ+1)/2a > - (\mu + 1) / 2. In particular, if a>=0a >= 0 the CTP is always overdispersed.

Value

dctp gives the pmf, pctp gives the distribution function, qctp gives the quantile function and rctp generates random values.

If a=0a = 0 the probability mass function, distribution function, quantile function and random generation function for the CBP distribution arise. If b=0b = 0 the probability mass function, distribution function, quantile function and random generation function for the EBW distribution arise.

References

Jose Rodriguez-Avi J, Conde-Sanchez A, Saez-Castillo AJ (2003). “A new class of discrete distributions with complex parameters.” Stat. Pap., 44, 67–88. doi:10.1007/s00362-002-0134-7.

Rodriguez-Avi J, Conde-Sanchez A, Saez-Castillo AJ, Olmo-Jimenez MJ (2004). “A triparametric discrete distribution with complex parameters.” Stat. Pap., 45, 81-95. doi:10.1007/BF02778271.

Olmo-Jimenez MJ, Rodriguez-Avi J, Cueva-Lopez V (2018). “A review of the CTP distribution: a comparison with other over- and underdispersed count data models.” Journal of Statistical Computation and Simulation, 88(14), 2684-2706. doi:10.1080/00949655.2018.1482897.

Cueva-Lopez V, Olmo-Jimenez MJ, Rodriguez-Avi J (2021). “An Over and Underdispersed Biparametric Extension of the Waring Distribution.” Mathematics, 9(170), 1-15. doi:10.3390/math9020170.

See Also

Functions for maximum-likelihood fitting of the CTP, CBP and EBW distributions: fitctp, fitcbp and fitebw.

Examples

# Examples for the function dctp
dctp(3,1,2,5)
dctp(c(3,4),1,2,5)

# Examples for the function pctp
pctp(3,1,2,3)
pctp(c(3,4),1,2,3)

# Examples for the function qctp
qctp(0.5,1,2,3)
qctp(c(.8,.9),1,2,3)

# Examples for the function rctp
rctp(10,1,1,3)

The Extended Biparametric Waring (EBW) Distribution

Description

Probability mass function, distribution function, quantile function and random generation for the Extended Biparametric Waring (EBW) distribution with parameters α\alpha and γ\gamma (or ρ\rho).

Usage

debw(x, alpha, gamma, rho)

pebw(q, alpha, gamma, rho, lower.tail = TRUE)

qebw(p, alpha, gamma, rho, lower.tail = TRUE)

rebw(n, alpha, gamma, rho, lower.tail = TRUE)

Arguments

x

vector of (non-negative integer) quantiles.

alpha

parameter alpha (real)

gamma

parameter γ\gamma (positive)

rho

parameter rho (positive)

q

vector of quantiles.

lower.tail

if TRUE (default), probabilities are P(X<=x)P(X<=x), otherwise, P(X>x)P(X>x).

p

vector of probabilities.

n

number of observations. If length(n) > 1, the length is taken to be the number required.

Details

The EBW distribution with parameters α\alpha and γ\gamma has pmf

f(xa,α,γ)=CΓ(α+x)2/(Γ(γ+x)x!),x=0,1,2,...f(x|a,\alpha,\gamma) = C \Gamma(\alpha+x)^2 / (\Gamma(\gamma+x) x!), x=0,1,2,...

where Γ()\Gamma(·) is the gamma function and

C=Γ(γα2/(Γ(α)2Γ(γ2a))C = \Gamma(\gamma-\alpha^2 / (\Gamma(\alpha)^2 \Gamma(\gamma-2a))

the normalizing constant.

There is an alternative parametrization in terms of α\alpha and ρ=γ2α>0\rho=\gamma-2\alpha>0 when α>0\alpha>0. So, introduce only α\alpha and γ\gamma or α\alpha and ρ\rho, depending on the parametrization you wish to use.

The mean and the variance of the EBW distribution are E(X)=μ=α2/(γ2α1)E(X)=\mu=\alpha^2/(\gamma-2\alpha-1) and Var(X)=μ(μ+γ1)/(γ2α2)Var(X)=\mu(\mu+\gamma-1)/(\gamma-2\alpha-2) so γ>2a+2\gamma > 2a + 2.

It is underdispersed if α<(μ+1)/2\alpha < - (\mu + 1) / 2, equidispersed if α=(μ+1)/2\alpha = - (\mu + 1) / 2 or overdispersed if α>(μ+1)/2\alpha > - (\mu + 1) / 2. In particular, if α>=0.5\alpha >= -0.5 the EBW is overdispersed, whereas if α<1\alpha < -1 the EBW is underdispersed. In the case 1<α<=0.5-1 < \alpha <= -0.5, the EBW may be under-, equi- or overdispersed depending on the value of γ\gamma.

Value

debw gives the pmf, pebw gives the distribution function, qebw gives the quantile function and rebw generates random values.

If α>0\alpha > 0 the probability mass function, distribution function, quantile function and random generation function for the UGW(α,α,ρ)(\alpha,\alpha,\rho) distribution arise.

If α<0\alpha < 0 the probability mass function, distribution function, quantile function and random generation function for the CTP(α,0,γ)(\alpha,0,\gamma) distribution arise.

References

Jose Rodriguez-Avi J, Conde-Sanchez A, Saez-Castillo AJ (2003). “A new class of discrete distributions with complex parameters.” Stat. Pap., 44, 67–88. doi:10.1007/s00362-002-0134-7.

Rodriguez-Avi J, Conde-Sanchez A, Saez-Castillo AJ, Olmo-Jimenez MJ (2004). “A triparametric discrete distribution with complex parameters.” Stat. Pap., 45, 81-95. doi:10.1007/BF02778271.

Olmo-Jimenez MJ, Rodriguez-Avi J, Cueva-Lopez V (2018). “A review of the CTP distribution: a comparison with other over- and underdispersed count data models.” Journal of Statistical Computation and Simulation, 88(14), 2684-2706. doi:10.1080/00949655.2018.1482897.

See Also

Functions for maximum-likelihood fitting of the CTP and CBP distributions: fitctp and fitcbp.

Examples

# Examples for the function dctp
debw(3,1,rho=5)
debw(c(3,4),2,rho=5)

# Examples for the function pebw
pebw(3,2,rho=5)
pebw(c(3,4),2,rho=5)

# Examples for the function qebw
qebw(0.5,-2.1,gamma=0.1)
qebw(c(.8,.9),-2.1,gamma=0.1)
qebw(0.5,2,rho=5)
qebw(c(.8,.9),2,rho=5)

# Examples for the function rebw
rebw(10,2,rho=5)
rebw(10,-2.1,gamma=5)

Maximum-likelihood fitting of the CBP distribution

Description

Maximum-likelihood fitting of the Complex Biparametric Pearson (CBP) distribution with parameters bb and γ\gamma. Generic methods are print, summary, coef, logLik, AIC, BIC and plot.

Usage

fitcbp(x, bstart = NULL, gammastart = NULL, method = "L-BFGS-B", control = list(), ...)

Arguments

x

A numeric vector of length at least one containing only finite values.

bstart

A starting value for the parameter bb; by default NULL.

gammastart

A starting value for the parameter γ>0\gamma>0; by default NULL.

method

The method to be used in fitting the model. See 'Details'.

control

A list of parameters for controlling the fitting process.

...

Additional parameters.

Details

If the starting values of the parameters bb and γ\gamma are omitted (default option), they are computing by the method of moments (if possible; otherwise they must be entered).

The default method is "L-BFGS-B" (see details in optim function), but non-linear minimization (nlm) or those included in the optim function ("Nelder-Mead", "BFGS", "CG" and "SANN") may be used.

Standard error (SE) estimates for bb and γ\gamma are provided by the default method; otherwise, SE for γ0\gamma_0 where γ=exp(γ0)\gamma=exp{(\gamma_0}) is computed.

Value

An object of class 'fitCBP' is a list containing the following components:

  • n, the number of observations,

  • initialValues, a vector with the starting values used,

  • coefficients, the parameter ML estimates of the CTP distribution,

  • se, a vector of the standard error estimates,

  • hessian, a symmetric matrix giving an estimate of the Hessian at the solution found in the optimization of the log-likelihood function,

  • cov, an estimate of the covariance matrix of the model coefficients,

  • corr, an estimate of the correlation matrix of the model estimates,

  • loglik, the maximized log-likelihood,

  • aic, Akaike Information Criterion, minus twice the maximized log-likelihood plus twice the number of parameters,

  • bic, Bayesian Information Criterion, minus twice the maximized log-likelihood plus twice the number of parameters,

  • code, a code that indicates successful convergence of the fitter function used (see nlm and optim helps),

  • converged, logical value that indicates if the optimization algorithms succesfull,

  • method, the name of the fitter function used.

Generic functions:

  • print: The print of a 'fitCBP' object shows the ML parameter estimates and their standard errors in parenthesis.

  • summary: The summary provides the ML parameter estimates, their standard errors and the statistic and p-value of the Wald test to check if the parameters are significant. This summary also shows the loglikelihood, AIC and BIC values, as well as the results for the chi-squared goodness-of-fit test and the Kolmogorov-Smirnov test for discrete variables. Finally, the correlation matrix between parameter estimates appears.

  • coef: It extracts the fitted coefficients from a 'fitCBP' object.

  • logLik: It extracts the estimated log-likelihood from a 'fitCBP' object.

  • AIC: It extracts the value of the Akaike Information Criterion from a 'fitCBP' object.

  • BIC: It extracts the value of the Bayesian Information Criterion from a 'fitCBP' object.

  • plot: It shows the plot of a 'fitCBP' object. Observed and theoretical probabilities, empirical and theoretical cumulative distribution functions or empirical cumulative probabilities against theoretical cumulative probabilities are the three plot types.

References

Jose Rodriguez-Avi J, Conde-Sanchez A, Saez-Castillo AJ (2003). “A new class of discrete distributions with complex parameters.” Stat. Pap., 44, 67–88. doi:10.1007/s00362-002-0134-7.

See Also

Plot of observed and theoretical frequencies for a CBP fit: plot.fitCBP

Maximum-likelihood fitting for the CTP distribution: fitctp.

Maximum-likelihood fitting for the EBW distribution: fitebw.

Examples

set.seed(123)
x <- rcbp(500, 1.75, 3.5)
fitcbp(x)
summary(fitcbp(x, bstart = 1.1, gammastart = 3))

Maximum-likelihood fitting of the CTP distribution

Description

Maximum-likelihood fitting of the Complex Triparametric Pearson (CTP) distribution with parameters aa, bb and γ\gamma. Generic methods are print, summary, coef, logLik, AIC, BIC and plot.

Usage

fitctp(x, astart = NULL, bstart = NULL, gammastart = NULL, 
          method = "L-BFGS-B", control = list(), ...)

Arguments

x

A numeric vector of length at least one containing only finite values.

astart

A starting value for the parameter a>0a>0; by default NULL.

bstart

A starting value for the parameter bb; by default NULL.

gammastart

A starting value for the parameter γ>max(0,2a)\gamma>max(0,2a); by default NULL.

method

The method to be used in fitting the model. See 'Details'.

control

A list of parameters for controlling the fitting process.

...

Additional parameters.

Details

If the starting values of the parameters aa, bb and γ\gamma are omitted (default option), they are computing by the method of moments (if possible; otherwise they must be entered).

The default method is "L-BFGS-B" (see details in optim function), but non-linear minimization (nlm) or those included in the optim function ("Nelder-Mead", "BFGS", "CG" and "SANN") may be used.

Standard error (SE) estimates for aa, bb and γ\gamma are provided by the default method; otherwise, SE for γ0\gamma_0 where γ=exp(γ0)\gamma=exp(\gamma_0) is computed.

Value

An object of class 'fitCTP' is a list containing the following components:

  • n, the number of observations,

  • initialValues, a vector with the starting values used,

  • coefficients, the parameter ML estimates of the CTP distribution,

  • se, a vector of the standard error estimates,

  • hessian, a symmetric matrix giving an estimate of the Hessian at the solution found in the optimization of the log-likelihood function,

  • cov, an estimate of the covariance matrix of the model coefficients,

  • corr, an estimate of the correlation matrix of the model estimates,

  • loglik, the maximized log-likelihood,

  • aic, Akaike Information Criterion, minus twice the maximized log-likelihood plus twice the number of parameters,

  • bic, Bayesian Information Criterion, minus twice the maximized log-likelihood plus twice the number of parameters,

  • code, a code that indicates successful convergence of the fitter function used (see nlm and optim helps),

  • converged, logical value that indicates if the optimization algorithms succesfull,

  • method, the name of the fitter function used.

Generic functions:

  • print: The print of a 'fitCTP' object shows the ML parameter estimates and their standard errors in parenthesis.

  • summary: The summary provides the ML parameter estimates, their standard errors and the statistic and p-value of the Wald test to check if the parameters are significant. This summary also shows the loglikelihood, AIC and BIC values, as well as the results for the chi-squared goodness-of-fit test and the Kolmogorov-Smirnov test for discrete variables. Finally, the correlation matrix between parameter estimates appears.

  • coef: It extracts the fitted coefficients from a 'fitCTP' object.

  • logLik: It extracts the estimated log-likelihood from a 'fitCTP' object.

  • AIC: It extracts the value of the Akaike Information Criterion from a 'fitCTP' object.

  • BIC: It extracts the value of the Bayesian Information Criterion from a 'fitCTP' object.

  • plot: It shows the plot of a 'fitCTP' object. Observed and theoretical probabilities, empirical and theoretical cumulative distribution functions or empirical cumulative probabilities against theoretical cumulative probabilities are the three plot types.

References

Rodriguez-Avi J, Conde-Sanchez A, Saez-Castillo AJ, Olmo-Jimenez MJ (2004). “A triparametric discrete distribution with complex parameters.” Stat. Pap., 45, 81-95. doi:10.1007/BF02778271.

Olmo-Jimenez MJ, Rodriguez-Avi J, Cueva-Lopez V (2018). “A review of the CTP distribution: a comparison with other over- and underdispersed count data models.” Journal of Statistical Computation and Simulation, 88(14), 2684-2706. doi:10.1080/00949655.2018.1482897.

See Also

Plot of observed and theoretical frequencies for a CTP fit: plot.fitCTP

Maximum-likelihood fitting for the CBP distribution: fitcbp.

Maximum-likelihood fitting for the EBW distribution: fitebw.

Examples

set.seed(123)
x <- rctp(500, -0.5, 1, 2)
fitctp(x)
summary(fitctp(x, astart = 1, bstart = 1.1, gammastart = 3))

Maximum-likelihood fitting of the EBW distribution

Description

Maximum-likelihood fitting of the Extended Biparametric Waring (EBW) distribution with parameters α\alpha, ρ\rho and γ\gamma. Generic methods are print, summary, coef, logLik, AIC, BIC and plot. The method to be used in fitting the model is "L-BFGS-B" which allows constraints for each variable (see details in optim funtion).

Usage

fitebw(x, alphastart = NULL, rhostart = NULL, gammastart = NULL, 
          method = "L-BFGS-B", control = list(),...)

Arguments

x

A numeric vector of length at least one containing only finite values.

alphastart

A starting value for the parameter α\alpha; by default NULL.

rhostart

A starting value for the parameter ρ>0\rho>0; by default NULL.

gammastart

A starting value for the parameter γ>max(0,2α)\gamma>max(0,2\alpha); by default NULL.

method

The method to be used in fitting the model. The default method is "L-BFGS-B" (optim).

control

A list of parameters for controlling the fitting process.

...

Additional parameters.

Details

If the starting value for α\alpha is positive, the parameterization (α,ρ)(\alpha,\rho) is used; otherwise, the parameterization (α,γ)(\alpha,\gamma) is used.

If the starting values of the parameters α\alpha, γ\gamma or ρ\rho are omitted (default option), they are computing by the method of moments (if possible; otherwise they must be entered).

The default method is "L-BFGS-B" (see details in optim function), but non-linear minimization (nlm) or those included in the optim function ("Nelder-Mead", "BFGS", "CG" and "SANN") may be used.

Standard error (SE) estimates for α\alpha, γ\gamma or ρ\rho are provided by the default method; otherwise, SE for α0\alpha_0 and γ0\gamma_0 where α=exp(α0)\alpha=-exp(\alpha_0) and γ=exp(γ0)\gamma=exp(\gamma_0) (or for α0\alpha_0 and ρ0\rho_0 where α=exp(α0)\alpha=exp(\alpha_0) and ρ=exp(ρ0)\rho=exp(\rho_0)) are computed.

Value

An object of class 'fitEBW' is a list containing the following components:

  • n, the number of observations,

  • initialValues, a vector with the starting values used,

  • coefficients, the parameter ML estimates of the CTP distribution,

  • se, a vector of the standard error estimates,

  • hessian, a symmetric matrix giving an estimate of the Hessian at the solution found in the optimization of the log-likelihood function,

  • cov, an estimate of the covariance matrix of the model coefficients,

  • corr, an estimate of the correlation matrix of the model estimates,

  • loglik, the maximized log-likelihood,

  • aic, Akaike Information Criterion, minus twice the maximized log-likelihood plus twice the number of parameters,

  • bic, Bayesian Information Criterion, minus twice the maximized log-likelihood plus twice the number of parameters,

  • code, a code that indicates successful convergence of the fitter function used (see nlm and optim helps),

  • converged, logical value that indicates if the optimization algorithms succesfull.

  • method, the name of the fitter function used.

Generic functions:

  • print: The print of a 'fitEBW' object shows the ML parameter estimates and their standard errors in parenthesis.

  • summary: The summary provides the ML parameter estimates, their standard errors and the statistic and p-value of the Wald test to check if the parameters are significant. This summary also shows the loglikelihood, AIC and BIC values, as well as the results for the chi-squared goodness-of-fit test and the Kolmogorov-Smirnov test for discrete variables. Finally, the correlation matrix between parameter estimates appears.

  • coef: It extracts the fitted coefficients from a 'fitEBW' object.

  • logLik: It extracts the estimated log-likelihood from a 'fitEBW' object.

  • AIC: It extracts the value of the Akaike Information Criterion from a 'fitEBW' object.

  • BIC: It extracts the value of the Bayesian Information Criterion from a 'fitEBW' object.

  • plot: It shows the plot of a 'fitEBW' object. Observed and theoretical probabilities, empirical and theoretical cumulative distribution functions or empirical cumulative probabilities against theoretical cumulative probabilities are the three plot types.

References

Cueva-Lopez V, Olmo-Jimenez MJ, Rodriguez-Avi J (2021). “An Over and Underdispersed Biparametric Extension of the Waring Distribution.” Mathematics, 9(170), 1-15. doi:10.3390/math9020170.

See Also

Plot of observed and theoretical frequencies for a EBW fit: plot.fitEBW

Maximum-likelihood fitting for the CTP distribution: fitctp.

Maximum-likelihood fitting for the CBP distribution: fitcbp.

Examples

set.seed(123)
x <- rebw(500, 2, rho = 5)
fitebw(x)
summary(fitebw(x, alphastart = 1, rhostart = 5))

Plot of observed and theoretical frequencies for a CBP fit

Description

Plot of observed and theoretical frequencies for a CBP fit

Usage

## S3 method for class 'fitCBP'
plot(x, plty = "FREQ", maxValue = NULL, ...)

Arguments

x

An object of class 'fitCBP'

plty

Plot type to be shown. Default is "FREQ" which shows the observed and theoretical frequencies for each value of the variable; "CDF" and "PP" are also available for plotting the empirical and theoretical cumulative distribution functions or the theoretical cumulative probabilities against the empirical cumulative probabilities, respectively.

maxValue

maxValue you want to appear in the plot

...

Additional parameters.

Examples

set.seed(123)
x <- rcbp(500, 1.75, 3.5)
fit <- fitcbp(x)
plot(fit)
plot(fit, plty = "CDF")
plot(fit, plty = "PP")

Plot of observed and theoretical frequencies for a CTP fit

Description

Plot of observed and theoretical frequencies for a CTP fit

Usage

## S3 method for class 'fitCTP'
plot(x, plty = "FREQ", maxValue = NULL, ...)

Arguments

x

An object of class 'fitCTP'

plty

Plot type to be shown. Default is "FREQ" which shows the observed and theoretical frequencies for each value of the variable; "CDF" and "PP" are also available for plotting the empirical and theoretical cumulative distribution functions or the theoretical cumulative probabilities against the empirical cumulative probabilities, respectively.

maxValue

maxValue you want to appear in the plot

...

Additional parameters.

Examples

set.seed(123)
x <- rctp(500, -0.5, 1, 2)
fit <- fitctp(x)
plot(fit)
plot(fit, plty = "CDF")
plot(fit, plty = "PP")

Plot of observed and theoretical frequencies for a EBW fit

Description

Plot of observed and theoretical frequencies for a EBW fit

Usage

## S3 method for class 'fitEBW'
plot(x, plty = "FREQ", maxValue = NULL, ...)

Arguments

x

An object of class 'fitEBW'

plty

Plot type to be shown. Default is "FREQ" which shows the observed and theoretical frequencies for each value of the variable; "CDF" and "PP" are also available for plotting the empirical and theoretical cumulative distribution functions or the theoretical cumulative probabilities against the empirical cumulative probabilities, respectively.

maxValue

maxValue you want to appear in the plot

...

Additional parameters.

Examples

set.seed(123)
x <- rebw(500, -0.25, 1)
fit <- fitebw(x)
plot(fit)
plot(fit, plty = "CDF")
plot(fit, plty = "PP")

Variance decomposition for a EBW fit

Description

One of the main drawbacks of the Univariate Generalized Waring (UGW) distribution with parameters aa, kk and ρ\rho is that the first two parameters are interchangeable, so it is not possible to distinguish the variance components 'liability' and 'proneness' without additional information. To solve this problem, an EBW distribution (where these components are uniquely identifiable) can be used since, given a UGW distribution, there always exists an EBW close to it.

Usage

varcomp(object, ...)

Arguments

object

An object of class 'fitEBW'

...

Additional parameters.

Value

A data frame with the variance components (randomness, liability and proneness) in absolute and relative terms.

Examples

set.seed(123)
x <- rebw(500, 2, rho = 5)
fit <- fitebw(x, alphastart = 1, rhostart = 5)
varcomp(fit)