Generalized Empirical Likelihood estimation
Description
Function to estimate a vector of parameters based on moment conditions using the GEL method as presented by NeweySmith(2004) and Anatolyev(2005).
Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  gel(g, x, tet0 = NULL, gradv = NULL, smooth = FALSE,
type = c("EL","ET","CUE","ETEL","HD","ETHD"),
kernel = c("Truncated", "Bartlett"), bw = bwAndrews,
approx = c("AR(1)", "ARMA(1,1)"), prewhite = 1, ar.method = "ols",
tol_weights = 1e7, tol_lam = 1e9, tol_obj = 1e9, tol_mom = 1e9,
maxiterlam = 100, constraint = FALSE, optfct = c("optim", "optimize",
"nlminb"), optlam = c("nlminb", "optim", "iter"), data,
Lambdacontrol = list(), model = TRUE, X = FALSE, Y = FALSE,
TypeGel = "baseGel", alpha = NULL, eqConst = NULL,
eqConstFullVcov = FALSE, ...)
evalGel(g, x, tet0, gradv = NULL, smooth = FALSE,
type = c("EL", "ET", "CUE", "ETEL", "HD", "ETHD"),
kernel = c("Truncated", "Bartlett"), bw = bwAndrews,
approx = c("AR(1)", "ARMA(1,1)"), prewhite = 1,
ar.method = "ols", tol_weights = 1e7, tol_lam = 1e9, tol_obj = 1e9,
tol_mom = 1e9, maxiterlam = 100, optlam = c("nlminb", "optim",
"iter"), data, Lambdacontrol = list(), model = TRUE, X = FALSE,
Y = FALSE, alpha = NULL, ...)

Arguments
g 
A function of the form g(θ,x) and which returns a n \times q matrix with typical element g_i(θ,x_t) for i=1,...q and t=1,...,n. This matrix is then used to build the q sample moment conditions. It can also be a formula if the model is linear (see details below). 
tet0 
A k \times 1 vector of starting values. If the dimension of θ is one, see the argument "optfct". In the linear case, if tet0=NULL, the 2step gmm estimator is used as starting value. However, it has to be provided when eqConst is not NULL 
x 
The matrix or vector of data from which the function g(θ,x) is computed. If "g" is a formula, it is an n \times Nh matrix of instruments (see details below). 
gradv 
A function of the form G(θ,x) which returns a q\times k matrix of derivatives of \bar{g}(θ) with respect to θ. By default, the numerical algorithm 
smooth 
If set to TRUE, the moment function is smoothed as proposed by Kitamura(1997) 
type 
"EL" for empirical likelihood, "ET" for exponential tilting, "CUE" for continuous updated estimator, "ETEL" for exponentially tilted empirical likelihood of Schennach(2007), "HD" for Hellinger Distance of KitamuraOtsuEvdokimov (2013), and "ETHD" for the exponentially tilted Hellinger distance of AntoineDovonon (2015). 
kernel 
type of kernel used to compute the covariance matrix of the vector of sample moment conditions (see 
bw 
The method to compute the bandwidth parameter. By default it is 
prewhite 
logical or integer. Should the estimating functions be prewhitened? If 
ar.method 
character. The 
approx 
a character specifying the approximation method if the bandwidth has to be chosen by 
tol_weights 
numeric. Weights that exceed 
tol_lam 
Tolerance for λ between two iterations. The algorithm stops when \λ_i λ_{i1}\ reaches 
maxiterlam 
The algorithm to compute λ stops if there is no convergence after "maxiterlam" iterations (see 
tol_obj 
Tolerance for the gradiant of the objective function to compute λ (see 
optfct 
Only when the dimension of θ is 1, you can choose between the algorithm 
constraint 
If set to TRUE, the constraint optimization algorithm is used. See 
tol_mom 
It is the tolerance for the moment condition ∑_{t=1}^n p_t g(θ(x_t)=0, where p_t=\frac{1}{n}Dρ(<g_t,λ>) is the implied probability. It adds a penalty if the solution diverges from its goal. 
optlam 
The default is "iter" which solves for λ using the Newton iterative method 
data 
A data.frame or a matrix with column names (Optional). 
Lambdacontrol 
Controls for the optimization of the vector of Lagrange multipliers used by either 
model, X, Y 
logicals. If 
TypeGel 
The name of the class object created by the method 
alpha 
Regularization coefficient for discrete CGEL estimation (experimental). By setting alpha to any value, the model is estimated by CGEL of type specified by the option 
eqConst 
Either a named vector (if "g" is a function), a simple vector for the nonlinear case indicating which of the θ_0 is restricted, or a qx2 vector defining equality constraints of the form θ_i=c_i. See 
eqConstFullVcov 
If FALSE, the constrained coefficients are assumed to be fixed and only the covariance of the unconstrained coefficients is computed. If TRUE, the covariance matrix of the full set of coefficients is computed. 
... 
More options to give to 
Details
If we want to estimate a model like Y_t = θ_1 + X_{2t}θ_2 + ... + X_{k}θ_k + ε_t using the moment conditions Cov(ε_tH_t)=0, where H_t is a vector of Nh instruments, than we can define "g" like we do for lm
. We would have g = y~x2+x3+...+xk
and the argument "x" above would become the matrix H of instruments. As for lm
, Y_t can be a Ny \times 1 vector which would imply that k=Nh \times Ny. The intercept is included by default so you do not have to add a column of ones to the matrix H. You do not need to provide the gradiant in that case since in that case it is embedded in gel
. The intercept can be removed by adding 1 to the formula. In that case, the column of ones need to be added manually to H.
If "smooth" is set to TRUE, the sample moment conditions ∑_{t=1}^n g(θ,x_t) is replaced by: ∑_{t=1}^n g^k(θ,x_t), where g^k(θ,x_t)=∑_{i=r}^r k(i) g(θ,x_{t+i}), where r is a truncated parameter that depends on the bandwidth and k(i) are normalized weights so that they sum to 1.
The method solves \hat{θ} = \arg\min ≤ft[\arg\max_λ \frac{1}{n}∑_{t=1}^n ρ(<g(θ,x_t),λ>)  ρ(0) \right]
evalGel
generates the object of class "gel" for a fixed vector of
parameters. There is no estimation for θ, but the optimal
vector of Lagrange multipliers λ is computed. The objective
function is then the profiled likelihood for a given θ. It
can be used to construct a confidence interval by inverting the
likelihood ratio test.
Value
'gel' returns an object of 'class' '"gel"'
The functions 'summary' is used to obtain and print a summary of the results.
The object of class "gel" is a list containing at least the following:
coefficients 
k\times 1 vector of parameters 
residuals 
the residuals, that is response minus fitted values if "g" is a formula. 
fitted.values 
the fitted mean values if "g" is a formula. 
lambda 
q \times 1 vector of Lagrange multipliers. 
vcov_par 
the covariance matrix of "coefficients" 
vcov_lambda 
the covariance matrix of "lambda" 
pt 
The implied probabilities 
objective 
the value of the objective function 
conv_lambda 
Convergence code for "lambda" (see 
conv_mes 
Convergence message for "lambda" (see 
conv_par 
Convergence code for "coefficients" (see 
terms 
the 
call 
the matched call. 
y 
if requested, the response used (if "g" is a formula). 
x 
if requested, the model matrix used if "g" is a formula or the data if "g" is a function. 
model 
if requested (the default), the model frame used if "g" is a formula. 
References
Anatolyev, S. (2005), GMM, GEL, Serial Correlation, and Asymptotic Bias. Econometrica, 73, 9831002.
Andrews DWK (1991), Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Estimation. Econometrica, 59, 817–858.
Kitamura, Yuichi (1997), Empirical Likelihood Methods With Weakly Dependent Processes. The Annals of Statistics, 25, 20842102.
Kitamura, Y. and Otsu, T. and Evdokimov, K. (2013), Robustness, Infinitesimal Neighborhoods and Moment Restrictions. Econometrica, 81, 11851201.
Newey, W.K. and Smith, R.J. (2004), Higher Order Properties of GMM and Generalized Empirical Likelihood Estimators. Econometrica, 72, 219255.
Smith, R.J. (2004), GEL Criteria for Moment Condition Models. Working paper, CEMMAP.
Newey WK & West KD (1987), A Simple, Positive SemiDefinite, Heteroskedasticity and Autocorrelation Consistent Covariance Matrix. Econometrica, 55, 703–708.
Newey WK & West KD (1994), Automatic Lag Selection in Covariance Matrix Estimation. Review of Economic Studies, 61, 631653.
Schennach, Susanne, M. (2007), Point Estimation with Exponentially Tilted Empirical Likelihood. Econometrica, 35, 634672.
Zeileis A (2006), Objectoriented Computation of Sandwich Estimators. Journal of Statistical Software, 16(9), 1–16. URL http://www.jstatsoft.org/v16/i09/.
Chausse (2010), Computing Generalized Method of Moments and Generalized Empirical Likelihood with R. Journal of Statistical Software, 34(11), 1–35. URL http://www.jstatsoft.org/v34/i11/.
Chausse (2011), Generalized Empirical likelihood for a continumm of moment conditions. Working Paper, Department of Economics, University of Waterloo.
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44  # First, an exemple with the fonction g()
g < function(tet, x)
{
n < nrow(x)
u < (x[7:n]  tet[1]  tet[2]*x[6:(n1)]  tet[3]*x[5:(n2)])
f < cbind(u, u*x[4:(n3)], u*x[3:(n4)], u*x[2:(n5)], u*x[1:(n6)])
return(f)
}
Dg < function(tet,x)
{
n < nrow(x)
xx < cbind(rep(1, (n6)), x[6:(n1)], x[5:(n2)])
H < cbind(rep(1, (n6)), x[4:(n3)], x[3:(n4)], x[2:(n5)], x[1:(n6)])
f < crossprod(H, xx)/(n6)
return(f)
}
n = 200
phi<c(.2, .7)
thet < 0.2
sd < .2
set.seed(123)
x < matrix(arima.sim(n = n, list(order = c(2, 0, 1), ar = phi, ma = thet, sd = sd)), ncol = 1)
res < gel(g, x, c(0, .3, .6), grad = Dg)
summary(res)
# The same model but with g as a formula.... much simpler in that case
y < x[7:n]
ym1 < x[6:(n1)]
ym2 < x[5:(n2)]
H < cbind(x[4:(n3)], x[3:(n4)], x[2:(n5)], x[1:(n6)])
g < y ~ ym1 + ym2
x < H
res < gel(g, x, c(0, .3, .6))
summary(res)
# Using evalGel to create the object without estimation
res < evalGel(g, x, res$coefficients)
