Learn R Programming

GB2 (version 1.0)

MLfullGB2: Maximum Likelihood Estimation of the GB2 Based on the Full Log-likelihood

Description

Two methods of optimization are considered: BFGS and L-BFGS-B (see optim documentation for more details). Initial values of the parameters to be optimized over ($a$, $b$, $p$ and $q$) are given from the Fisk distribution, which is a GB2 distribution with $p = q = 1$. If $m$ and $v$ denote, respectively, the mean and variance of $log(z)$, then $\hat{a} = \pi/\sqrt{3*v}$ and $\hat{b} = \exp(m)$. The function to be maximized by optim returns the negative of the full log-likelihood and the gradient is equal to the negative of the scores, respectively for the case of a sample of persons and a sample of households.

Usage

fisk(z, w=1)
fiskh(z, w=1, hs)
ml.gb2(z, w=1, method=1) 
mlh.gb2(z, w=1, hs, method=1)

Arguments

z
vector of data values.
w
corresponding weights.
hs
vector of household sizes.
method
the method to be used for optim. By default, the used method is BFGS. If method =2, methods BFGS and L-BFGS-B are used.

Value

  • A list with 1 or 2 arguments: opt1 output of BFGS fit and opt2 output of L-BFGS fit. Further values are given by the values of optim.

Details

Function fisk first calculates the mean and variance of $log(z)$ and returns the initial values of a and p under the Fisk distribution. Function fiskh first calculates the mean and variance of $log(z)$, assuming a sample of households, and returns the initial values of a and p under the Fisk distribution. Function ml.gb2 performs maximum likelihood estimation through the general-purpose optimization function optim from package stats, based on the full log-likelihood calculated in a sample of persons. Function mlh.gb2 performs maximum likelihood estimation through the general-purpose optimization function optim from package stats, based on the full log-likelihood calculated in a sample of households.

References

Graf, M. and Nedyalkova, D. (2010) The Generalized Beta Distribution of the Second Kind as an Income Distribution: Properties, Likelihood and Estimation. working paper, SFSO.

See Also

optim for the general-purpose optimization

Examples

Run this code
library(laeken)
data(eusilc)

# Income
inc <- as.vector(eusilc$eqIncome)

# Weights
w <- eusilc$rb050

# Data set
d <- data.frame(inc, w)
d <- d[!is.na(d$inc),]
   
# Truncate at 0
inc <- d$inc[d$inc > 0]
w   <- d$w[d$inc > 0]

# Fit using the full log-likelihood
fitf <- ml.gb2(inc, w)$opt1

# Fitted GB2 parameters
af <- fitf$par[1]
bf <- fitf$par[2]
pf <- fitf$par[3]
qf <- fitf$par[4]

# Likelihood
flik <- fitf$value

# If we want to compare the indicators
# GB2 indicators
indicf <- round(main.gb2(0.6,af,bf,pf,qf), digits=3)
# Empirical indicators
indice <- round(main.emp(inc,w), digits=3)
# Plots
plotsML.gb2(inc,af,bf,pf,qf,w)

Run the code above in your browser using DataLab