Learn R Programming

GB2 (version 1.0)

MLfitGB2: Fitting the GB2 by the Method of Maximum Likelihood Estimation

Description

Performs maximum likelihood estimation through the general-purpose optimisation function optim from package stats.

Usage

main.emp(z, w=1)
mlfit.gb2(z, w=1)

Arguments

z
a numeric vector; in general, the income values.
w
a numeric vector of the same length as z; the sampling weights. If not available, the function should be called only with its first argument (the weights are set to 1).

Value

  • A list containing three different objects. The first is a data frame with the values of the fitted parameters for the full log-likelihood and the profile log-likelihood, the values of the two likelihoods, the values of the estimated indicators under the GB2 and the values of the empirical estimates of the indicators. The second and third objects are, respectively, the fit using the full log-likelihood and the fit using the profile log-likelihhod.

Details

The function makes a call to ml.gb2 and profml.gb2. Estimates of the GB2 parameters are calculated . Also the primary Laeken indicators of the fitted parameters and the empirical estimates of the indicators (see package laeken) are calculated.

See Also

optim , ml.gb2, profml.gb2

Examples

Run this code
# An example of using the function mlfit.gb2
# See also the examples of ml.gb2 and mlprof.gb2

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]

# ML fit
m1 <- mlfit.gb2(inc,w)

# Results
m1[[1]]
# The fit using the full log-likelihood
m1[[2]]
# The fit using the profile log-likelihood
m1[[3]]

# ML fit, when no weights are avalable 
m2 <- mlfit.gb2(inc)
# Results
m2[[1]]

Run the code above in your browser using DataLab