background image

Package â€˜gmm’

March 15, 2018

Version

1.6-2

Date

2017-09-26

Title

Generalized Method of Moments and Generalized Empirical
Likelihood

Author

Pierre Chausse

<pchausse@uwaterloo.ca>

Maintainer

Pierre Chausse

<pchausse@uwaterloo.ca>

Description

It is a complete suite to estimate models based on moment

conditions. It includes the two step Generalized method of
moments (Hansen 1982; <doi:10.2307/1912775>), the iterated GMM and continuous
updated estimator (Hansen, Eaton and Yaron 1996; <doi:10.2307/1392442>) and several
methods that belong to the Generalized Empirical Likelihood
family of estimators (Smith 1997; <doi:10.1111/j.0013-0133.1997.174.x>,
Kitamura 1997; <doi:10.1214/aos/1069362388>, Newey and Smith 2004; <doi:10.1111/j.1468-
0262.2004.00482.x>,
and Anatolyev 2005 <doi:10.1111/j.1468-0262.2005.00601.x>).

Depends

R (>= 2.10.0), sandwich

Suggests

mvtnorm, car, stabledist, MASS, timeDate, timeSeries

Imports

stats, methods, grDevices, graphics

License

GPL (>= 2)

Repository

CRAN

Repository/R-Forge/Project

gmm

Repository/R-Forge/Revision

119

Repository/R-Forge/DateTimeStamp

2018-03-12 14:25:26

Date/Publication

2018-03-15 22:51:20 UTC

NeedsCompilation

no

R

topics documented:

ATEgel

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2

bread

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5

bwWilhelm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6

1

background image

2

ATEgel

charStable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

8

coef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

9

confint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

10

estfun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

12

Finance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

14

FinRes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

15

fitted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

15

formula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

17

gel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

18

getDat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

23

getLamb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

24

getModel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

25

gmm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

26

Growth

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

34

KTest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

35

marginal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

36

momentEstim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

37

nsw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

38

plot

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

39

print . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

41

residuals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

42

smoothG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

43

specTest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

45

summary

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

46

sysGmm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

48

tsls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

51

vcov . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

52

wage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

54

Index

55

ATEgel

ATE with Generalized Empirical Likelihood estimation

Description

Function to estimate the average treatment effect with the sample being balanced by GEL.

Usage

ATEgel(g, balm, w=NULL, y=NULL, treat=NULL, tet0=NULL,momType=c("bal","balSample","ATT"),

popMom = NULL, family=c("linear","logit", "probit"),

type = c("EL", "ET", "CUE", "ETEL", "HD", "ETHD"),

tol_lam = 1e-9, tol_obj = 1e-9, tol_mom = 1e-9, maxiterlam = 100,

optfct = c("optim", "nlminb"),

optlam = c("nlminb", "optim", "iter", "Wu"), data=NULL,

Lambdacontrol = list(),

model = TRUE, X = FALSE, Y = FALSE, ...)

checkConv(obj, tolConv=1e-4, verbose=TRUE)

background image

ATEgel

3

Arguments

g

A formula as

y~z

, where codey is the response and

z

the treatment indicator. If

there is more than one treatment, more indicators can be added or

z

can be set

as a factor. It can also be of the form

g(theta, y, z)

for non-linear models. It

is however, not implemented yet.

obj

Object of class

"ategel"

produced y

ATEgel

balm

A formula for the moments to be balanced between the treated and control
groups (see details)

y

The response variable when

g

is a function. Not implemented yet

treat

The treatment indicator when

g

is a function. Not implemented yet

w

A formula to add covariates to the main regression. When

NULL

, the default

value, the main regression only include treatment indicators.

tet0

A

3

×

1

vector of starting values. If not provided, they are obtained using an

OLS regression

momType

How the moments of the covariates should be balanced. By default, it is simply
balanced without restriction. Alternatively, moments can be set equal to the
sample moments of the whole sample, or to the sample moments of the treated
group. The later will produce the average treatment effect of the treated (ATT)

popMom

A vector of population moments to use for balancing. It can be used of those
moments are available from a census, for example. When available, it greatly
improves efficiency.

family

By default, the outcome is linearly related to the treatment indicators. If the
outcome is binary, it is possible to use the estimating equations of either the
logit or probit model.

type

"EL" for empirical likelihood, "ET" for exponential tilting, "CUE" for continu-
ous updated estimator, "ETEL" for exponentially tilted empirical likelihood of
Schennach(2007), "HD" for Hellinger Distance of Kitamura-Otsu-Evdokimov
(2013), and "ETHD" for the exponentially tilted Hellinger distance of Antoine-
Dovonon (2015).

tol_lam

Tolerance for

λ

between two iterations. The algorithm stops when

k

λ

i

−

λ

i

−

1

k

reaches

tol_lamb

(see

getLamb

)

maxiterlam

The algorithm to compute

λ

stops if there is no convergence after "maxiterlam"

iterations (see

getLamb

).

tol_obj

Tolerance for the gradiant of the objective function to compute

λ

(see

getLamb

).

optfct

Algorithm used for the parameter estimates

tol_mom

It is the tolerance for the moment condition

P

n
t

=1

p

t

g

(

θ

(

x

t

) = 0

, where

p

t

=

1

n

(

< g

t

, Î» >

)

is the implied probability. It adds a penalty if the solution

diverges from its goal.

optlam

Algorithm used to solve for the lagrange multiplier in

getLamb

The algorithm

Wu is only for

type="EL"

.

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

optim

,

nlminb

or

constrOptim

background image

4

ATEgel

model, X, Y

logicals. If

TRUE

the corresponding components of the fit (the model frame, the

model matrix, the response) are returned if g is a formula.

verbose

If TRUE, a summary of the convergence is printed

tolConv

The tolerance for comparing moments between groups

...

More options to give to

optim

or

nlminb

.

Details

We want to estimate the model

Y

t

=

θ

1

+

θ

2

treat

+

t

, where

θ

2

is the treatment effect. GEL is

used to balance the sample based on the argument

x

above.

For example, if we want the sample mean of

x1

and

x2

to be balanced between the treated and

control, we set

x

to

~x1+x2

. If we want the sample mean of

x1

,

x2

,

x1*x2

,

x1^2

and

x2^2

, we set

x

to

~x1*x2 + I(x1^2) + I(x2^2)

.

Value

’gel’ returns an object of â€™class’ â€™"ategel"’

The functions â€™summary’ is used to obtain and print a summary of the results.

The object of class "ategel" is a list containing the same elements contained in objects of class

gel

.

References

Lee, Seojeong (2016), Asymptotic refinements of misspecified-robust bootstrap for GEL estimators,

Journal of Econometrics

,

192

, 86–104.

Schennach, Susanne, M. (2007), Point Estimation with Exponentially Tilted Empirical Likelihood.

Econometrica

,

35

, 634-672.

Wu, C. (2005), Algorithms and R codes for the pseudo empirical likelihood method in survey
sampling.

Survey Methodology

,

31

(2), page 239.

Chausse, P. (2010), Computing Generalized Method of Moments and Generalized Empirical Like-
lihood with R.

Journal of Statistical Software

,

34

(11), 1–35. URL

http://www.jstatsoft.org/

v34/i11/

.

Chausse, P and Luta, G. (2017) Estimating the Average Treatment Effect in Quasi-Experimental
Studies using the Generalized Empirical Likelihood, Work in progress.

Examples

data(nsw)

# Scale income

nsw$re78 <- nsw$re78/1000

nsw$re75 <- nsw$re75/1000

res <- ATEgel(re78~treat, ~age+ed+black+hisp+married+nodeg+re75,

data=nsw,type="ET")

summary(res)

chk <- checkConv(res)

res2 <- ATEgel(re78~treat, ~age+ed+black+hisp+married+nodeg+re75,

data=nsw,type="ET", momType="balSample")

background image

bread

5

summary(res2)

chk2 <- checkConv(res2)

bread

Bread for sandwiches

Description

Computes the bread of the sandwich covariance matrix

Usage

## S3 method for class 'gmm'

bread(x, ...)

## S3 method for class 'gel'

bread(x, ...)

## S3 method for class 'tsls'

bread(x, ...)

Arguments

x

A fitted model of class

gmm

or

gel

.

...

Other arguments when

bread

is applied to another class object

Details

When the weighting matrix is not the optimal one, the covariance matrix of the estimated coeffi-
cients is:

(

G

0

W G

)

−

1

G

0

W V W G

(

G

0

W G

)

−

1

, where

G

=

d

¯

g/dθ

,

W

is the matrix of weights, and

V

is the covariance matrix of the moment function. Therefore, the bread is

(

G

0

W G

)

−

1

, which is

the second derivative of the objective function.

The method if not yet available for

gel

objects.

Value

A

k

×

k

matrix (see details).

References

Zeileis A (2006), Object-oriented Computation of Sandwich Estimators.

Journal of Statistical Soft-

ware

,

16

(9), 1–16. URL

http://www.jstatsoft.org/v16/i09/

.

background image

6

bwWilhelm

Examples

# See \code{\link{gmm}} for more details on this example.

# With the identity matrix

# bread is the inverse of (G'G)

n <- 1000

x <- rnorm(n, mean = 4, sd = 2)

g <- function(tet, x)

{

m1 <- (tet[1] - x)

m2 <- (tet[2]^2 - (x - tet[1])^2)

m3 <- x^3 - tet[1]*(tet[1]^2 + 3*tet[2]^2)

f <- cbind(m1, m2, m3)

return(f)

}

Dg <- function(tet, x)

{

jacobian <- matrix(c( 1, 2*(-tet[1]+mean(x)), -3*tet[1]^2-3*tet[2]^2,0, 2*tet[2],

-6*tet[1]*tet[2]), nrow=3,ncol=2)

return(jacobian)

}

res <- gmm(g, x, c(0, 0), grad = Dg,weightsMatrix=diag(3))

G <- Dg(res$coef, x)

bread(res)

solve(crossprod(G))

bwWilhelm

Wilhelm (2015) bandwidth selection

Description

It computes the optimal bandwidth for the HAC estimation of the covariance matrix of the moment
conditions. The bandwidth was shown by Wilhelm (2005) to be the one that minimizes the MSE of
the GMM estimator.

Usage

bwWilhelm(x, order.by = NULL, kernel = c("Quadratic Spectral",

"Bartlett", "Parzen", "Tukey-Hanning"), approx = c("AR(1)", "ARMA(1,1)"),

weights = NULL, prewhite = 1, ar.method = "ols", data = list())

Arguments

x

An object of class

gmm

.

order.by

Either a vector â€™z’ or a formula with a single explanatory variable like â€™~ z’. The
observations in the model are ordered by the size of â€™z’. If set to â€™NULL’ (the
default) the observations are assumed to be ordered (e.g., a time series).

background image

bwWilhelm

7

kernel

type of kernel used to compute the covariance matrix of the vector of sample
moment conditions (see

kernHAC

for more details)

approx

A character specifying the approximation method if the bandwidth has to be
chosen by

bwAndrews

.

weights

numeric. A vector of weights used for weighting the estimated coefficients of
the approximation model (as specified by â€™approx’). By default all weights are
1 except that for the intercept term (if there is more than one variable)

prewhite

logical or integer. Should the estimating functions be prewhitened? If

TRUE

or

greater than 0 a VAR model of order

as.integer(prewhite)

is fitted via

ar

with method

"ols"

and

demean = FALSE

.

ar.method

character. The

method

argument passed to

ar

for prewhitening.

data

an optional data frame containing the variables in the â€™order.by’ model.

Value

The function â€™bwWilhelm’ returns the optimal bandwidth.

Note

The function was written by Daniel Wilhelm and is based on

bwAndrews

.

References

Wilhelm, D. (2015), Optimal Bandwidth Selection for Robust Generalized Method of Moments
Estimation.

Econometric Theory

,

31

, 1054–1077

Zeileis A (2006), Object-oriented Computation of Sandwich Estimators.

Journal of Statistical Soft-

ware

,

16

(9), 1–16. URL

http://www.jstatsoft.org/v16/i09/

.

Examples

data(Finance)

f1 <- Finance[1:300, "rm"]

f2 <- Finance[1:300, "hml"]

f3 <- Finance[1:300, "smb"]

y <- Finance[1:300,"WMK"]

## Silly example just to make it over-identified

###############################################

res <- gmm(y ~ f1, ~ f1 + f2 + f3)

summary(res)

## Set the bandwidth using the second step estimate

################################################

bw <- bwWilhelm(res)

res2 <- update(res, bw=bw)

summary(res2)

## Set the bandwidth using the first-step estimate as for bwAndrews

background image

8

charStable

###################################################################

res3 <- gmm(y ~ f1, ~ f1 + f2 + f3, bw=bwWilhelm)

summary(res3)

charStable

The characteristic function of a stable distribution

Description

It computes the theoretical characteristic function of a stable distribution for two different parametriza-
tions. It is used in the vignette to illustrate the estimation of the parameters using GMM.

Usage

charStable(theta, tau, pm = 0)

Arguments

theta

Vector of parameters of the stable distribution. See details.

tau

A vector of numbers at which the function is evaluated.

pm

The type of parametization. It takes the values 0 or 1.

Details

The function returns the vector

Ψ(

θ, Ï„, pm

)

defined as

E

(

e

ixτ

, where

Ï„

is a vector of real numbers,

i

is the imaginary number,

x

is a stable random variable with parameters

θ

=

(

α, Î², Î³, Î´

)

and

pm

is the

type of parametrization. The vector of parameters are the characteristic exponent, the skewness, the
scale and the location parameters, respectively. The restrictions on the parameters are:

α

∈

(0

,

2]

,

β

∈

[

−

1

,

1]

and

γ >

0

. For mode details see Nolan(2009).

Value

It returns a vector of complex numbers with the dimension equals to

length(tau)

.

References

Nolan J. P. (2009), Stable Disttributions.

Math/Stat Department, American University

. URL

http:

//academic2.american.edu/~jpnolan/stable/stable.html

.

background image

coef

9

Examples

# GMM is like GLS for linear models without endogeneity problems

pm <- 0

theta <- c(1.5,.5,1,0)

tau <- seq(-3, 3, length.out = 20)

char_fct <- charStable(theta, tau, pm)

coef

Coefficients of GEL or GMM

Description

It extracts the coefficients from

gel

or

gmm

objects.

Usage

## S3 method for class 'gmm'

coef(object, ...)

## S3 method for class 'gel'

coef(object, lambda = FALSE, ...)

Arguments

object

An object of class

gel

or

gmm

returned by the function

gel

or

gmm

lambda

If set to TRUE, the lagrange multipliers are extracted instead of the vector of
coefficients

...

Other arguments when

coef

is applied to an other class object

Value

Vector of coefficients

Examples

#################

n = 500

phi<-c(.2,.7)

thet <- 0

sd <- .2

x <- matrix(arima.sim(n=n,list(order=c(2,0,1),ar=phi,ma=thet,sd=sd)),ncol=1)

y <- x[7:n]

ym1 <- x[6:(n-1)]

ym2 <- x[5:(n-2)]

background image

10

confint

H <- cbind(x[4:(n-3)], x[3:(n-4)], x[2:(n-5)], x[1:(n-6)])

g <- y ~ ym1 + ym2

x <- H

t0 <- c(0,.5,.5)

res <- gel(g, x, t0)

coef(res)

coef(res, lambda = TRUE)

###################

res <- gmm(g, x)

coef(res)

confint

Confidence intervals for GMM or GEL

Description

It produces confidence intervals for the coefficients from

gel

or

gmm

estimation.

Usage

## S3 method for class 'gel'

confint(object, parm, level = 0.95, lambda = FALSE,

type = c("Wald", "invLR", "invLM", "invJ"),

fact = 3, corr = NULL, ...)

## S3 method for class 'gmm'

confint(object, parm, level = 0.95, ...)

## S3 method for class 'ategel'

confint(object, parm, level = 0.95, lambda = FALSE,

type = c("Wald", "invLR", "invLM", "invJ"), fact = 3,

corr = NULL, robToMiss=TRUE, ...)

## S3 method for class 'confint'

print(x, digits = 5, ...)

Arguments

object

An object of class

gel

or

gmm

returned by the function

gel

or

gmm

parm

A specification of which parameters are to be given confidence intervals, either
a vector of numbers or a vector of names. If missing, all parameters are consid-
ered.

level

The confidence level

lambda

If set to TRUE, the confidence intervals for the Lagrange multipliers are pro-
duced.

type

’Wald’ is the usual symetric confidence interval. The thee others are based on
the inversion of the LR, LM, and J tests.

background image

confint

11

fact

This parameter control the span of search for the inversion of the test. By default
we search within plus or minus 3 times the standard error of the coefficient
estimate.

corr

This numeric scalar is meant to apply a correction to the critical value, such as
a Bartlett correction. This value depends on the model (See Owen; 2001)

x

An object of class

confint

produced by

confint.gel

and

confint.gmm

digits

The number of digits to be printed

robToMiss

If

TRUE

, the confidence interval is based on the standard errors that are robust to

misspecification

...

Other arguments when

confint

is applied to another classe object

Value

It returns a matrix with the first column being the lower bound and the second the upper bound.

References

Hansen, L.P. (1982), Large Sample Properties of Generalized Method of Moments Estimators.

Econometrica

,

50

, 1029-1054, Hansen, L.P. and Heaton, J. and Yaron, A.(1996), Finit-Sample

Properties of Some Alternative GMM Estimators.

Journal of Business and Economic Statistics

,

14

262-280. Owen, A.B. (2001), Empirical Likelihood.

Monographs on Statistics and Applied

Probability 92, Chapman and Hall/CRC

Examples

#################

n = 500

phi<-c(.2,.7)

thet <- 0

sd <- .2

x <- matrix(arima.sim(n = n, list(order = c(2,0,1), ar = phi, ma = thet, sd = sd)), ncol = 1)

y <- x[7:n]

ym1 <- x[6:(n-1)]

ym2 <- x[5:(n-2)]

H <- cbind(x[4:(n-3)], x[3:(n-4)], x[2:(n-5)], x[1:(n-6)])

g <- y ~ ym1 + ym2

x <- H

t0 <- c(0,.5,.5)

resGel <- gel(g, x, t0)

confint(resGel)

confint(resGel, level = 0.90)

confint(resGel, lambda = TRUE)

########################

resGmm <- gmm(g, x)

background image

12

estfun

confint(resGmm)

confint(resGmm, level = 0.90)

## Confidence interval with inversion of the LR, LM or J test.

##############################################################

set.seed(112233)

x <- rt(40, 3)

y <- x+rt(40,3)

# Simple interval on the mean

res <- gel(x~1, ~1, method="Brent", lower=-4, upper=4)

confint(res, type = "invLR")

confint(res)

# Using a Bartlett correction

k <- mean((x-mean(x))^4)/sd(x)^4

s <- mean((x-mean(x))^3)/sd(x)^3

a <- k/2-s^2/3

corr <- 1+a/40

confint(res, type = "invLR", corr=corr)

# Interval on the slope

res <- gel(y~x, ~x)

confint(res, "x", type="invLR")

confint(res, "x")

estfun

Extracts the empirical moment function

Description

It extracts the matrix of empirical moments so that it can be used by the

kernHAC

function.

Usage

## S3 method for class 'gmmFct'

estfun(x, y = NULL, theta = NULL, ...)

## S3 method for class 'gmm'

estfun(x, ...)

## S3 method for class 'gel'

estfun(x, ...)

## S3 method for class 'tsls'

estfun(x, ...)

## S3 method for class 'tsls'

model.matrix(object, ...)

Arguments

x

A function of the form

g

(

θ, y

)

or a

n

×

q

matrix with typical element

g

i

(

θ, y

t

)

for

i

= 1

, ...q

and

t

= 1

, ..., n

or an object of class

gmm

. See

gmm

for more details.

For

tsls

it is an object of class

tsls

.

background image

estfun

13

object

An object of class

tsls

.

y

The matrix or vector of data from which the function

g

(

θ, y

)

is computed if

g

is

a function.

theta

Vector of parameters if

g

is a function.

...

Other arguments when

estfun

is applied to another class object

Details

For

estfun.gmmFct

, it returns a

n

×

q

matrix with typical element

g

i

(

θ, y

t

)

for

i

= 1

, ...q

and

t

= 1

, ..., n

. It is only used by

gmm

to obtain the estimates.

For

estfun.gmm

, it returns the matrix of first order conditions of

min

θ

¯

g

0

W

¯

g/

2

, which is a

n

×

k

matrix with the

t

th

row being

g

(

θ, y

t

)

W G

, where

G

is

d

¯

g/dθ

. It allows to compute the sandwich

covariance matrix using

kernHAC

or

vcovHAC

when

W

is not the optimal matrix.

The method if not yet available for

gel

objects.

For tsls, model.matrix and estfun are used by

vcov()

to compute different covariance matrices

using the

sandwich

package. See

vcov.tsls

.

model.matrix

returns the fitted values frin the first

stage regression and

esfun

the residuals.

Value

A

n

×

q

matrix (see details).

References

Zeileis A (2006), Object-oriented Computation of Sandwich Estimators.

Journal of Statistical Soft-

ware

,

16

(9), 1–16. URL

http://www.jstatsoft.org/v16/i09/

.

Examples

n = 500

phi<-c(.2,.7)

thet <- 0

sd <- .2

x <- matrix(arima.sim(n=n,list(order=c(2,0,1),ar=phi,ma=thet,sd=sd)),ncol=1)

y <- x[7:n]

ym1 <- x[6:(n-1)]

ym2 <- x[5:(n-2)]

H <- cbind(x[4:(n-3)], x[3:(n-4)], x[2:(n-5)], x[1:(n-6)])

g <- y ~ ym1 + ym2

x <- H

res <- gmm(g, x,weightsMatrix = diag(5))

gt <- res$gt

G <- res$G

foc <- gt

foc2 <- estfun(res)

background image

14

Finance

foc[1:5,]

foc2[1:5,]

Finance

Returns on selected stocks

Description

Daily returns on selected stocks, the Market portfolio and factors of Fama and French from 1993-
01-05 to 2009-01-30 for CAPM and APT analysis

Usage

data(Finance)

Format

A data frame containing 24 time series. Dates are reported as rownames(). In the following descrip-
tion, company symboles are used.

WMK

Returns of WEIS MARKETS INC

UIS

Returns of UNISYS CP NEW

ORB

Returns of ORBITAL SCIENCES CP

MAT

Returns of Mattel, Inc.

ABAX

Returns of ABAXIS, Inc.

T

Returns of AT&T INC.

EMR

Returns of EMERSON ELEC CO

JCS

Returns of Communications Systems Inc.

VOXX

Returns of Audiovox Corp.

ZOOM

Returns of ZOOM Technologies Inc.

TDW

Returns of TIDEWATER INC

ROG

Returns of Rogers Corporation

GGG

Returns of Graco Inc.

PC

Returns of Panasonic Corporation

GCO

Returns of Genesco Inc.

EBF

Returns of ENNIS, INC

F

Returns of FORD MOTOR CO

FNM

Returns of FANNIE MAE

NHP

Returns of NATIONWIDE HLTH PROP

AA

Returns of ALCOA INC

rf

Risk-free rate of Fama-French

rm

Return of the market portfolio of Fama-French

hml

Factor High-Minus-Low of Fama-French

smb

Factor Small-Minus-Big of Fama-French

background image

FinRes

15

Source

Yahoo Finance and

http://mba.tuck.dartmouth.edu/pages/faculty/ken.french

FinRes

Method to finalize the result of the momentEstim method

Description

It computes the final results that will be needed to create the object of class

gmm

.).

Usage

## S3 method for class 'baseGmm.res'

FinRes(z, object, ...)

Arguments

z

An object of class determined by the method

momentEstim

.

object

An object produced my

getModel

...

Other argument to be passed to other

FinRes

methods.

Value

It returns an object of class

gmm

. See

gmm

for more details.

References

Hansen, L.P. (1982), Large Sample Properties of Generalized Method of Moments Estimators.

Econometrica

,

50

, 1029-1054,

Hansen, L.P. and Heaton, J. and Yaron, A.(1996), Finit-Sample Properties of Some Alternative
GMM Estimators.

Journal of Business and Economic Statistics

,

14

262-280.

fitted

Fitted values of GEL and GMM

Description

Method to extract the fitted values of the model estimated by

gel

or

gmm

.

Usage

## S3 method for class 'gel'

fitted(object, ...)

## S3 method for class 'gmm'

fitted(object, ...)

background image

16

fitted

Arguments

object

An object of class

gel

or

gel

returned by the function

gel

or

gmm

...

Other arguments when

fitted

is applied to an other class object

Value

It returns a matrix of the estimated mean

ˆ

y

in

g=y~x

as it is done by

fitted.lm

.

Examples

# GEL can deal with endogeneity problems

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)

y <- x[7:n]

ym1 <- x[6:(n-1)]

ym2 <- x[5:(n-2)]

H <- cbind(x[4:(n-3)], x[3:(n-4)], x[2:(n-5)], x[1:(n-6)])

g <- y ~ ym1 + ym2

x <- H

res <- gel(g, x, c(0,.3,.6))

plot(y, main = "Fitted ARMA with GEL")

lines(fitted(res), col = 2)

# GMM is like GLS for linear models without endogeneity problems

set.seed(345)

n = 200

phi<-c(.2,.7)

thet <- 0

sd <- .2

x <- matrix(arima.sim(n = n, list(order = c(2,0,1), ar = phi, ma = thet, sd = sd)), ncol = 1)

y <- 10 + 5*rnorm(n) + x

res <- gmm(y ~ x, x)

plot(x, y, main = "Fitted model with GMM")

lines(x, fitted(res), col = 2)

legend("topright", c("Y","Yhat"), col = 1:2, lty = c(1,1))

background image

formula

17

formula

Formula method for gel and gmm objects

Description

Method to extract the formula from

gel

or

gmm

objects.

Usage

## S3 method for class 'gel'

formula(x, ...)

## S3 method for class 'gmm'

formula(x, ...)

Arguments

x

An object of class

gel

or

gmm

returned by the function

gel

or

gmm

...

Other arguments to pass to other methods

Examples

## GEL ##

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)

y <- x[7:n]

ym1 <- x[6:(n-1)]

ym2 <- x[5:(n-2)]

H <- cbind(x[4:(n-3)], x[3:(n-4)], x[2:(n-5)], x[1:(n-6)])

g <- y ~ ym1 + ym2

x <- H

res <- gel(g, x, c(0,.3,.6))

formula(res)

# GMM is like GLS for linear models without endogeneity problems

set.seed(345)

n = 200

phi<-c(.2,.7)

thet <- 0

sd <- .2

x <- matrix(arima.sim(n = n, list(order = c(2,0,1), ar = phi, ma = thet, sd = sd)), ncol = 1)

y <- 10 + 5*rnorm(n) + x

background image

18

gel

res <- gmm(y ~ x, x)

formula(res)

gel

Generalized Empirical Likelihood estimation

Description

Function to estimate a vector of parameters based on moment conditions using the GEL method as
presented by Newey-Smith(2004) and Anatolyev(2005).

Usage

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 = 1e-7, tol_lam = 1e-9, tol_obj = 1e-9, tol_mom = 1e-9,

maxiterlam = 100, constraint = FALSE, optfct = c("optim", "optimize",

"nlminb"), optlam = c("nlminb", "optim", "iter", "Wu"), data,

Lambdacontrol = list(), model = TRUE, X = FALSE, Y = FALSE,

TypeGel = "baseGel", alpha = NULL, eqConst = NULL,

eqConstFullVcov = FALSE, onlyCoefficients=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 = 1e-7, tol_lam = 1e-9, tol_obj = 1e-9,

tol_mom = 1e-9, maxiterlam = 100, optlam = c("nlminb", "optim",

"iter", "Wu"), 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

×

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

×

1

vector of starting values. If the dimension of

θ

is one, see the argument

"optfct". In the linear case, if tet0=NULL, the 2-step 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

×

N h

matrix of instruments (see details below).

background image

gel

19

gradv

A function of the form

G

(

θ, x

)

which returns a

q

×

k

matrix of derivatives of

¯

g

(

θ

)

with respect to

θ

. By default, the numerical algorithm

numericDeriv

is used.

It is of course strongly suggested to provide this function when it is possible.
This gradiant is used compute the asymptotic covariance matrix of

ˆ

θ

. If "g" is a

formula, the gradiant is not required (see the details below).

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 continu-
ous updated estimator, "ETEL" for exponentially tilted empirical likelihood of
Schennach(2007), "HD" for Hellinger Distance of Kitamura-Otsu-Evdokimov
(2013), and "ETHD" for the exponentially tilted Hellinger distance of Antoine-
Dovonon (2015).

kernel

type of kernel used to compute the covariance matrix of the vector of sample
moment conditions (see

kernHAC

for more details) and to smooth the moment

conditions if "smooth" is set to TRUE. Only two types of kernel are available.
The truncated implies a Bartlett kernel for the HAC matrix and the Bartlett im-
plies a Parzen kernel (see Smith 2004).

bw

The method to compute the bandwidth parameter. By default it is

bwAndrews

which is proposed by Andrews (1991). The alternative is

bwNeweyWest

of

Newey-West(1994).

prewhite

logical or integer. Should the estimating functions be prewhitened? If

TRUE

or

greater than 0 a VAR model of order

as.integer(prewhite)

is fitted via

ar

with method

"ols"

and

demean = FALSE

.

ar.method

character. The

method

argument passed to

ar

for prewhitening.

approx

a character specifying the approximation method if the bandwidth has to be
chosen by

bwAndrews

.

tol_weights

numeric. Weights that exceed

tol

are used for computing the covariance matrix,

all other weights are treated as 0.

tol_lam

Tolerance for

λ

between two iterations. The algorithm stops when

k

λ

i

−

λ

i

−

1

k

reaches

tol_lamb

(see

getLamb

)

maxiterlam

The algorithm to compute

λ

stops if there is no convergence after "maxiterlam"

iterations (see

getLamb

).

tol_obj

Tolerance for the gradiant of the objective function to compute

λ

(see

getLamb

).

optfct

Only when the dimension of

θ

is 1, you can choose between the algorithm

optim

or

optimize

In that case, the former is unreliable. If

optimize

is chosen, "t0"

must be

1

×

2

which represents the interval in which the algorithm seeks the

solution.It is also possible to choose the

nlminb

algorithm. In that case, borns

for the coefficients can be set by the options

upper=

and

lower=

.

constraint

If set to TRUE, the constraint optimization algorithm is used. See

constrOptim

to learn how it works. In particular, if you choose to use it, you need to provide
"ui" and "ci" in order to impose the constraint

uiθ

−

ci

≥

0

.

tol_mom

It is the tolerance for the moment condition

P

n
t

=1

p

t

g

(

θ

(

x

t

) = 0

, where

p

t

=

1

n

(

< g

t

, Î» >

)

is the implied probability. It adds a penalty if the solution

diverges from its goal.

optlam

Algorithm used to solve for the lagrange multiplier in

getLamb

The algorithm

Wu is only for

type="EL"

.

background image

20

gel

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

optim

,

nlminb

or

constrOptim

model, X, Y

logicals. If

TRUE

the corresponding components of the fit (the model frame, the

model matrix, the response) are returned if g is a formula.

TypeGel

The name of the class object created by the method

getModel

. It allows devel-

opers to extand the package and create other GEL methods.

alpha

Regularization coefficient for discrete CGEL estimation (experimental). By set-
ting alpha to any value, the model is estimated by CGEL of type specified by
the option

type

. See Chausse (2011)

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

gmm

for an example.

eqConstFullVcov

If FALSE, the constrained coefficients are assumed to be fixed and only the co-
variance of the unconstrained coefficients is computed. If TRUE, the covariance
matrix of the full set of coefficients is computed.

onlyCoefficients

If

TRUE

, only the vector of coefficients and Lagrange multipliers are returned

...

More options to give to

optim

,

optimize

or

constrOptim

.

Details

If we want to estimate a model like

Y

t

=

θ

1

+

X

2

t

θ

2

+

...

+

X

k

θ

k

+

t

using the moment conditions

Cov

(

t

H

t

) = 0

, where

H

t

is a vector of

N h

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

N y

×

1

vector which would imply that

k

=

N h

×

N y

.

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

P

n
t

=1

g

(

θ, x

t

)

is replaced by:

P

n
t

=1

g

k

(

θ, x

t

)

,

where

g

k

(

θ, x

t

) =

P

r
i

=

−

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

ˆ

θ

= arg min

arg max

λ

1

n

P

n
t

=1

Ï

(

< g

(

θ, x

t

)

, Î» >

)

−

Ï

(0)

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:

background image

gel

21

coefficients

k

×

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

×

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

getLamb

)

conv_mes

Convergence message for "lambda" (see

getLamb

)

conv_par

Convergence code for "coefficients" (see

optim

,

optimize

or

constrOptim

)

terms

the

terms

object used when g is a formula.

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

,

983-1002.

Andrews DWK (1991), Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Esti-
mation.

Econometrica

,

59

, 817–858.

Kitamura, Yuichi (1997), Empirical Likelihood Methods With Weakly Dependent Processes.

The

Annals of Statistics

,

25

, 2084-2102.

Kitamura, Y. and Otsu, T. and Evdokimov, K. (2013), Robustness, Infinitesimal Neighborhoods and
Moment Restrictions.

Econometrica

,

81

, 1185-1201.

Newey, W.K. and Smith, R.J. (2004), Higher Order Properties of GMM and Generalized Empirical
Likelihood Estimators.

Econometrica

,

72

, 219-255.

Smith, R.J. (2004), GEL Criteria for Moment Condition Models.

Working paper, CEMMAP

.

Newey WK & West KD (1987), A Simple, Positive Semi-Definite, Heteroskedasticity and Auto-
correlation Consistent Covariance Matrix.

Econometrica

,

55

, 703–708.

Newey WK & West KD (1994), Automatic Lag Selection in Covariance Matrix Estimation.

Review

of Economic Studies

,

61

, 631-653.

Schennach, Susanne, M. (2007), Point Estimation with Exponentially Tilted Empirical Likelihood.

Econometrica

,

35

, 634-672.

Wu, C. (2005), Algorithms and R codes for the pseudo empirical likelihood method in survey
sampling.

Survey Methodology

,

31

(2), page 239.

Zeileis A (2006), Object-oriented Computation of Sandwich Estimators.

Journal of Statistical Soft-

ware

,

16

(9), 1–16. URL

http://www.jstatsoft.org/v16/i09/

.

background image

22

gel

Chausse (2010), Computing Generalized Method of Moments and Generalized Empirical Likeli-
hood 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

# First, an exemple with the fonction g()

g <- function(tet, x)

{

n <- nrow(x)

u <- (x[7:n] - tet[1] - tet[2]*x[6:(n-1)] - tet[3]*x[5:(n-2)])

f <- cbind(u, u*x[4:(n-3)], u*x[3:(n-4)], u*x[2:(n-5)], u*x[1:(n-6)])

return(f)

}

Dg <- function(tet,x)

{

n <- nrow(x)

xx <- cbind(rep(1, (n-6)), x[6:(n-1)], x[5:(n-2)])

H <- cbind(rep(1, (n-6)), x[4:(n-3)], x[3:(n-4)], x[2:(n-5)], x[1:(n-6)])

f <- -crossprod(H, xx)/(n-6)

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:(n-1)]

ym2 <- x[5:(n-2)]

H <- cbind(x[4:(n-3)], x[3:(n-4)], x[2:(n-5)], x[1:(n-6)])

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)

background image

getDat

23

getDat

Extracting data from a formula

Description

It extract the data from a formula y~z with instrument h and put everything in a matrix. It helps
redefine the function

g

(

θ, x

)

that is required by

gmm

and

gel

.

Usage

getDat(formula, h, data, error=TRUE)

Arguments

formula

A formula that defines the linear model to be estimated (see details).

h

A

n

×

nh

matrix of intruments(see details).

data

A data.frame or a matrix with colnames (Optionnal).

error

If FALSE, the data is generated without giving any error message

Details

The model to be estimated is based on the moment conditions

< h,

(

y

−

zθ

)

>

= 0

. It adds a column

of ones to z and h by default. They are removed if -1 is added to the formula. The error argument
has been added for

sysGmm

with common coefficients because the check is only valid for equation

by equation identification.

Value

x: A

n

×

l

matrix, where

l

=

ncol

(

y

) +

ncol

(

z

) +

ncol

(

h

) + 2

if "intercept" is TRUE and

ncol

(

y

) +

ncol

(

z

) +

xcol

(

h

)

if "intercept" is FALSE.

nh: dimension of h

k: dimension of z

ny: dimension of y

Examples

n = 500

phi<-c(.2, .7)

thet <- 0.2

sd <- .2

x <- matrix(arima.sim(n = n, list(order = c(2, 0, 1), ar = phi, ma = thet, sd = sd)), ncol = 1)

y <- x[7:n]

ym1 <- x[6:(n-1)]

ym2 <- x[5:(n-2)]

H <- cbind(x[4:(n-3)], x[3:(n-4)], x[2:(n-5)], x[1:(n-6)])

background image

24

getLamb

x <- getDat(y ~ ym1 + ym2, H)

getLamb

Solving for the Lagrange multipliers of Generalized Empirical Likeli-
hood (GEL)

Description

It computes the vector of Lagrange multipliers, which maximizes the GEL objective function, using
an iterative Newton method.

Usage

getLamb(gt, l0, type = c("EL","ET","CUE", "ETEL", "HD","ETHD"),

tol_lam = 1e-7, maxiterlam = 100,

tol_obj = 1e-7, k = 1, method = c("nlminb", "optim", "iter", "Wu"),

control = list())

Arguments

gt

A

n

×

q

matrix with typical element

g

i

(

θ, x

t

)

l0

Vector of starting values for lambda

type

"EL" for empirical likelihood, "ET" for exponential tilting, "CUE" for continu-
ous updated estimator, and "HD" for Hellinger Distance. See details for "ETEL"
and "ETHD".

tol_lam

Tolerance for

λ

between two iterations. The algorithm stops when

k

λ

i

−

λ

i

−

1

k

reaches

tol_lam

maxiterlam

The algorithm stops if there is no convergence after "maxiterlam" iterations.

tol_obj

Tolerance for the gradiant of the objective function. The algorithm returns a
non-convergence message if

max(

|

gradiant

|

)

does not reach

tol_obj

. It helps

the

gel

algorithm to select the right space to look for

θ

k

It represents the ratio k1/k2, where

k

1 =

R

∞

−∞

k

(

s

)

ds

and

k

2 =

R

∞

−∞

k

(

s

)

2

ds

.

See Smith(2004).

method

The iterative procedure uses a Newton method for solving the FOC. It i however
recommended to use

optim

or

nlminb

. If type is set to "EL" and method to

"optim",

constrOptim

is called to prevent

log

(1

−

gt

0

λ

)

from producing NA.

The gradient and hessian is provided to

nlminb

which speed up the convergence.

The latter is therefore the default value. "Wu" is for "EL" only. It uses the
algorithm of Wu (2005).

control

Controls to send to

optim

,

nlminb

or

constrOptim

background image

getModel

25

Details

It solves the problem

max

λ

1

n

P

n
t

=1

Ï

(

gt

0

λ

)

. For the type "ETEL", it is only used by

gel

In

that case

λ

is obtained by maximizing

1

n

P

n
t

=1

Ï

(

gt

0

λ

)

, using

Ï

(

v

) =

−

exp

v

(so ET) and

θ

by

minimizing the same equation but with

Ï

(

v

)

−

log (1

−

v

)

. To avoid NA’s,

constrOptim

is used

with the restriction

λ

0

g

t

<

1

. The type "ETHD" is experimental and proposed by Antoine-Dovonon

(2015). The paper is not yet available.

Value

lambda: A

q

×

1

vector of Lagrange multipliers which solve the system of equations given above.

conv

: Details on the type of convergence.

References

Newey, W.K. and Smith, R.J. (2004), Higher Order Properties of GMM and Generalized Empirical
Likelihood Estimators.

Econometrica

,

72

, 219-255.

Smith, R.J. (2004), GEL Criteria for Moment Condition Models.

Working paper, CEMMAP

.

Wu, C. (2005), Algorithms and R codes for the pseudo empirical likelihood method in survey
sampling.

Survey Methodology

,

31

(2), page 239.

Examples

g <- function(tet,x)

{

n <- nrow(x)

u <- (x[7:n] - tet[1] - tet[2]*x[6:(n-1)] - tet[3]*x[5:(n-2)])

f <- cbind(u, u*x[4:(n-3)], u*x[3:(n-4)], u*x[2:(n-5)], u*x[1:(n-6)])

return(f)

}

n = 500

phi<-c(.2, .7)

thet <- 0.2

sd <- .2

x <- matrix(arima.sim(n = n, list(order = c(2, 0, 1), ar = phi, ma = thet, sd = sd)), ncol = 1)

gt <- g(c(0,phi),x)

getLamb(gt, type = "EL",method="optim")

getModel

Method for setting the properties of a model

Description

It collects what is needed by the method

momentEstim

(see details).

background image

26

gmm

Usage

## S3 method for class 'baseGmm'

getModel(object, ...)

## S3 method for class 'sysGmm'

getModel(object, ...)

## S3 method for class 'baseGel'

getModel(object, ...)

## S3 method for class 'constGel'

getModel(object, ...)

## S3 method for class 'constGel'

getModel(object, ...)

## S3 method for class 'tsls'

getModel(object, ...)

## S3 method for class 'ateGel'

getModel(object, ...)

Arguments

object

An object of class

baseGmm

...

Other arguments when

getModel

is applied to another class object

Value

It returns an object of the right class which determines how the method

momentEstim

will treat it.

For example, if

g

is a formula and

type

is set to "cue", it creates an object of class

baseGmm.cue.formula

.

It this case,

momentEstim

, applied to this object, computes the continuously updated GMM of a lin-

ear model. It allows more flexibility this way. For example, it could be easy to add a GMM method
which is robust in presence of weak identification simply by creating a new class of model and the
associated

momentEstime

method.

gmm

Generalized method of moment estimation

Description

Function to estimate a vector of parameters based on moment conditions using the GMM method
of Hansen(82).

Usage

gmm(g,x,t0=NULL,gradv=NULL, type=c("twoStep","cue","iterative"),

wmatrix = c("optimal","ident"), vcov=c("HAC","MDS","iid","TrueFixed"),

kernel=c("Quadratic Spectral","Truncated", "Bartlett", "Parzen", "Tukey-Hanning"),

crit=10e-7,bw = bwAndrews, prewhite = 1, ar.method = "ols", approx="AR(1)",

tol = 1e-7, itermax=100,optfct=c("optim","optimize","nlminb", "constrOptim"),

model=TRUE, X=FALSE, Y=FALSE, TypeGmm = "baseGmm", centeredVcov = TRUE,

background image

gmm

27

weightsMatrix = NULL, traceIter = FALSE, data, eqConst = NULL,

eqConstFullVcov = FALSE, mustar = NULL, onlyCoefficients=FALSE, ...)

evalGmm(g, x, t0, tetw=NULL, gradv=NULL, wmatrix = c("optimal","ident"),

vcov=c("HAC","iid","TrueFixed"), kernel=c("Quadratic Spectral","Truncated",

"Bartlett", "Parzen", "Tukey-Hanning"),crit=10e-7,bw = bwAndrews,

prewhite = FALSE, ar.method = "ols", approx="AR(1)",tol = 1e-7,

model=TRUE, X=FALSE, Y=FALSE, centeredVcov = TRUE, weightsMatrix = NULL,

data, mustar = NULL)

gmmWithConst(obj, which, value)

Arguments

g

A function of the form

g

(

θ, x

)

and which returns a

n

×

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

x

The matrix or vector of data from which the function

g

(

θ, x

)

is computed. If

"g" is a formula, it is an

n

×

N h

matrix of instruments or a formula (see details

below).

t0

A

k

×

1

vector of starting values. It is required only when "g" is a function

because only then a numerical algorithm is used to minimize the objective func-
tion. If the dimension of

θ

is one, see the argument "optfct".

tetw

A

k

×

1

vector to compute the weighting matrix.

gradv

A function of the form

G

(

θ, x

)

which returns a

q

×

k

matrix of derivatives of

¯

g

(

θ

)

with respect to

θ

. By default, the numerical algorithm

numericDeriv

is used.

It is of course strongly suggested to provide this function when it is possible.
This gradient is used to compute the asymptotic covariance matrix of

ˆ

θ

and to

obtain the analytical gradient of the objective function if the method is set to
"CG" or "BFGS" in

optim

and if "type" is not set to "cue". If "g" is a formula,

the gradiant is not required (see the details below).

type

The GMM method: "twostep" is the two step GMM proposed by Hansen(1982)
and the "cue" and "iterative" are respectively the continuous updated and the
iterative GMM proposed by Hansen, Eaton et Yaron (1996)

wmatrix

Which weighting matrix should be used in the objective function. By default, it
is the inverse of the covariance matrix of

g

(

θ, x

)

. The other choice is the identity

matrix which is usually used to obtain a first step estimate of

θ

vcov

Assumption on the properties of the random vector x. By default, x is a weakly
dependant process. The "iid" option will avoid using the HAC matrix which will
accelerate the estimation if one is ready to make that assumption. The option
"TrueFixed" is used only when the matrix of weights is provided and it is the
optimal one.

kernel

type of kernel used to compute the covariance matrix of the vector of sample
moment conditions (see

kernHAC

for more details)

crit

The stopping rule for the iterative GMM. It can be reduce to increase the preci-
sion.

background image

28

gmm

bw

The method to compute the bandwidth parameter in the HAC weighting matrix.
The default is

link{bwAndrews}

(as proposed in Andrews (1991)), which mini-

mizes the MSE of the weighting matrix. Alternatives are

link{bwWilhelm}

(as

proposed in Wilhelm (2015)), which minimizes the mean-square error (MSE) of
the resulting GMM estimator, and

link{bwNeweyWest}

(as proposed in Newey-

West(1994)).

prewhite

logical or integer. Should the estimating functions be prewhitened? If

TRUE

or

greater than 0 a VAR model of order

as.integer(prewhite)

is fitted via

ar

with method

"ols"

and

demean = FALSE

.

ar.method

character. The

method

argument passed to

ar

for prewhitening.

approx

A character specifying the approximation method if the bandwidth has to be
chosen by

bwAndrews

.

tol

Weights that exceed

tol

are used for computing the covariance matrix, all other

weights are treated as 0.

itermax

The maximum number of iterations for the iterative GMM. It is unlikely that the
algorithm does not converge but we keep it as a safety.

optfct

Only when the dimension of

θ

is 1, you can choose between the algorithm

optim

or

optimize

In that case, the former is unreliable. If

optimize

is chosen,

"t0" must be

1

×

2

which represents the interval in which the algorithm seeks

the solution. It is also possible to choose the

nlminb

algorithm. In that case,

boundaries for the coefficients can be set by the options

upper=

and

lower=

.

The

constrOptim

is only available for nonlinear models for now. The standard

errors may have to be corrected if the estimtes reach the boundary set by ui and
ci.

model, X, Y

logical. If

TRUE

the corresponding components of the fit (the model frame, the

model matrix, the response) are returned if g is a formula.

TypeGmm

The name of the class object created by the method

getModel

. It allows devel-

opers to extend the package and create other GMM methods.

centeredVcov

Should the moment function be centered when computing its covariance matrix.
Doing so may improve inference.

weightsMatrix

It allows users to provide

gmm

with a fixed weighting matrix. This matrix must

be

q

×

q

, symmetric and strictly positive definite. When provided, the

type

option becomes irrelevant.

traceIter

Tracing information for GMM of type "iter"

data

A data.frame or a matrix with column names (Optional).

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 below for an example.

which, value

The equality constraint is of the form which=value. "which" can be a vector of
type characters with the names of the coefficients being constrained, or a vector
of type numeric with the position of the coefficient in the whole vector.

obj

Object of class "gmm"

background image

gmm

29

eqConstFullVcov

If FALSE, the constrained coefficients are assumed to be fixed and only the co-
variance of the unconstrained coefficients is computed. If TRUE, the covariance
matrix of the full set of coefficients is computed.

mustar

If not null, it must be a vector with the number of elements being equal to the
number of moment conditions. In that case, the vector is subtracted from the
sample moment vector before minimizing the objective function. It is useful to
do a bootstrap procedure.

onlyCoefficients

If set to

TRUE

, the function only returns the coefficient estimates. It may be of

interest when the standard errors are not needed

...

More options to give to

optim

.

Details

If we want to estimate a model like

Y

t

=

θ

1

+

X

2

t

θ

2

+

· Â· Â·

+

X

k

θ

k

+

t

using the moment conditions

Cov

(

t

H

t

) = 0

, where

H

t

is a vector of

N h

instruments, than we can define "g" like we do for

lm

.

We would have

g

=

y

˜

x

2 +

x

3 +

· Â· Â·

+

xk

and the argument "x" above would become the matrix H

of instruments. As for

lm

,

Y

t

can be a

N y

×

1

vector which would imply that

k

=

N h

×

N y

. 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

gmm

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. It is also possible to express "x" as a formula. For example, if the instruments are

{

1

, z

1

, z

2

, z

3

}

, we can set "x" to

˜

z

1 +

z

2 +

z

3

. By default, a column of ones is added. To remove

it, set "x" to

˜

z

1 +

z

2 +

z

3

−

1

.

The following explains the last example bellow. Thanks to Dieter Rozenich, a student from the
Vienna University of Economics and Business Administration. He suggested that it would help to
understand the implementation of the Jacobian.

For the two parameters of a normal distribution

(

µ, Ïƒ

)

we have the following three moment condi-

tions:

m

1

=

µ

−

x

i

m

2

=

σ

2

−

(

x

i

−

µ

)

2

m

3

=

x

3

i

−

µ

(

µ

2

+ 3

σ

2

)

m

1

, m

2

can be directly obtained by the definition of

(

µ, Ïƒ

)

. The third moment condition comes

from the third derivative of the moment generating function (MGF)

M

X

(

t

) =

exp

µt

+

σ

2

t

2

2

evaluated at

(

t

= 0)

.

Note that we have more equations (3) than unknown parameters (2).

The Jacobian of these two conditions is (it should be an array but I can’t make it work):

1

0

−

2

µ

+ 2

x

2

σ

background image

30

gmm

−

3

µ

2

−

3

σ

2

−

6

µσ

gmmWithConst()

re-estimates an unrestricted model by adding an equality constraint.

evalGmm()

creates an object of class â€™"gmm"’ for a given parameter vector. If no vector "tetw" is provided and
the weighting matrix needs to be computed, "t0" is used.,

Value

’gmm’ returns an object of â€™class’ â€™"gmm"’

The functions â€™summary’ is used to obtain and print a summary of the results. It also compute the
J-test of overidentying restriction

The object of class "gmm" is a list containing at least:

coefficients

k

×

1

vector of coefficients

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.

vcov

the covariance matrix of the coefficients

objective

the value of the objective function

k

var

(¯

g

)

−

1

/

2

¯

g

k

2

terms

the

terms

object used when g is a formula.

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.

algoInfo

Information produced by either

optim

or

nlminb

related to the convergence if

"g" is a function. It is printed by the

summary.gmm

method.

References

Zeileis A (2006), Object-oriented Computation of Sandwich Estimators.

Journal of Statistical Soft-

ware

,

16

(9), 1–16. URL

http://www.jstatsoft.org/v16/i09/

.

Pierre 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/

.

Andrews DWK (1991), Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Esti-
mation.

Econometrica

,

59

, 817–858.

Newey WK & West KD (1987), A Simple, Positive Semi-Definite, Heteroskedasticity and Auto-
correlation Consistent Covariance Matrix.

Econometrica

,

55

, 703–708.

Newey WK & West KD (1994), Automatic Lag Selection in Covariance Matrix Estimation.

Review

of Economic Studies

,

61

, 631-653.

Hansen, L.P. (1982), Large Sample Properties of Generalized Method of Moments Estimators.

Econometrica

,

50

, 1029-1054,

Hansen, L.P. and Heaton, J. and Yaron, A.(1996), Finite-Sample Properties of Some Alternative
GMM Estimators.

Journal of Business and Economic Statistics

,

14

262-280.

background image

gmm

31

Examples

## CAPM test with GMM

data(Finance)

r <- Finance[1:300, 1:10]

rm <- Finance[1:300, "rm"]

rf <- Finance[1:300, "rf"]

z <- as.matrix(r-rf)

t <- nrow(z)

zm <- rm-rf

h <- matrix(zm, t, 1)

res <- gmm(z ~ zm, x = h)

summary(res)

## linear tests can be performed using linearHypothesis from the car package

## The CAPM can be tested as follows:

library(car)

linearHypothesis(res,cbind(diag(10),matrix(0,10,10)),rep(0,10))

# The CAPM of Black

g <- function(theta, x) {

e <- x[,2:11] - theta[1] - (x[,1] - theta[1]) %*% matrix(theta[2:11], 1, 10)

gmat <- cbind(e, e*c(x[,1]))

return(gmat) }

x <- as.matrix(cbind(rm, r))

res_black <- gmm(g, x = x, t0 = rep(0, 11))

summary(res_black)$coefficients

## APT test with Fama-French factors and GMM

f1 <- zm

f2 <- Finance[1:300, "hml"]

f3 <- Finance[1:300, "smb"]

h <- cbind(f1, f2, f3)

res2 <- gmm(z ~ f1 + f2 + f3, x = h)

coef(res2)

summary(res2)$coefficients

## Same result with x defined as a formula:

res2 <- gmm(z ~ f1 + f2 + f3, ~ f1 + f2 + f3)

coef(res2)

## The following example has been provided by Dieter Rozenich (see details).

# It generates normal random numbers and uses the GMM to estimate

# mean and sd.

#-------------------------------------------------------------------------------

background image

32

gmm

# Random numbers of a normal distribution

# First we generate normally distributed random numbers and compute the two parameters:

n <- 1000

x <- rnorm(n, mean = 4, sd = 2)

# Implementing the 3 moment conditions

g <- function(tet, x)

{

m1 <- (tet[1] - x)

m2 <- (tet[2]^2 - (x - tet[1])^2)

m3 <- x^3 - tet[1]*(tet[1]^2 + 3*tet[2]^2)

f <- cbind(m1, m2, m3)

return(f)

}

# Implementing the jacobian

Dg <- function(tet, x)

{

jacobian <- matrix(c( 1, 2*(-tet[1]+mean(x)), -3*tet[1]^2-3*tet[2]^2,0, 2*tet[2],

-6*tet[1]*tet[2]), nrow=3,ncol=2)

return(jacobian)

}

# Now we want to estimate the two parameters using the GMM.

gmm(g, x, c(0, 0), grad = Dg)

# Two-stage-least-squares (2SLS), or IV with iid errors.

# The model is:

# Y(t) = b[0] + b[1]C(t) + b[2]Y(t-1) + e(t)

# e(t) is an MA(1)

# The instruments are Z(t)={1 C(t) y(t-2) y(t-3) y(t-4)}

getdat <- function(n) {

e <- arima.sim(n,model=list(ma=.9))

C <- runif(n,0,5)

Y <- rep(0,n)

Y[1] = 1 + 2*C[1] + e[1]

for (i in 2:n){

Y[i] = 1 + 2*C[i] + 0.9*Y[i-1] + e[i]

}

Yt <- Y[5:n]

X <- cbind(1,C[5:n],Y[4:(n-1)])

Z <- cbind(1,C[5:n],Y[3:(n-2)],Y[2:(n-3)],Y[1:(n-4)])

return(list(Y=Yt,X=X,Z=Z))

}

d <- getdat(5000)

res4 <- gmm(d$Y~d$X-1,~d$Z-1,vcov="iid")

res4

### Examples with equality constraint

######################################

# Random numbers of a normal distribution

## Not run:

background image

gmm

33

# The following works but produces warning message because the dimension of coef is 1

# Brent should be used

# without named vector

# Method Brent is used because the problem is now one-dimensional

gmm(g, x, c(4, 0), grad = Dg, eqConst=1, method="Brent", lower=-10,upper=10)

# with named vector

gmm(g, x, c(mu=4, sig=2), grad = Dg, eqConst="sig", method="Brent", lower=-10,upper=10)

## End(Not run)

gmm(g, x, c(4, 0), grad = Dg, eqConst=1,method="Brent",lower=0,upper=6)

gmm(g, x, c(mu=4, sig=2), grad = Dg, eqConst="sig",method="Brent",lower=0,upper=6)

# Example with formula

# first coef = 0 and second coef = 1

# Only available for one dimensional yt

z <- z[,1]

res2 <- gmm(z ~ f1 + f2 + f3, ~ f1 + f2 + f3, eqConst = matrix(c(1,2,0,1),2,2))

res2

# CUE with starting t0 requires eqConst to be a vector

res3 <- gmm(z ~ f1 + f2 + f3, ~ f1 + f2 + f3, t0=c(0,1,.5,.5), type="cue", eqConst = c(1,2))

res3

### Examples with equality constraints, where the constrained coefficients is used to compute

### the covariance matrix.

### Useful when some coefficients have been estimated before, they are just identified in GMM

### and don't need to be re-estimated.

### To use with caution because the covariance won't be valid if the coefficients do not solve

### the GMM FOC.

######################################

res4 <- gmm(z ~ f1 + f2 + f3, ~ f1 + f2 + f3, t0=c(0,1,.5,.5), eqConst = c(1,2),

eqConstFullVcov=TRUE)

summary(res4)

### Examples with equality constraint using gmmWithConst

###########################################################

res2 <- gmm(z ~ f1 + f2 + f3, ~ f1 + f2 + f3)

gmmWithConst(res2,c("f2","f3"),c(.5,.5))

gmmWithConst(res2,c(2,3),c(.5,.5))

## Creating an object without estimation for a fixed parameter vector

###################################################################

res2_2 <- evalGmm(z ~ f1 + f2 + f3, ~ f1 + f2 + f3,

t0=res2$coefficients, tetw=res2$coefficients)

summary(res2_2)

background image

34

Growth

Growth

Growth Data

Description

Panel of Macroeconomic data for 125 countries from 1960 to 1985 constructed by Summers and
Heston (1991))

Usage

data(Growth)

Format

A data frame containing 9 vectors.

Country_ID

Country identification number

COM

1 if the country is in a communist regime, 0 otherwise

OPEC

1 if the country is part of the OPEC, 0 otherwise

Year

Year

GDP

Per capita GDP (in thousands) in 1985 U.S. dollars.

LagGDP

GDP of the previous period

SavRate

Saving rate measured as the ratio of real investment to real GDP

LagSavRate

SavRate of the previous period

Country

Country names

Pop

Population in thousands

LagPop

Population of the previous period

Source

http://fhayashi.fc2web.com/datasets.htm

background image

KTest

35

KTest

Compute the K statistics of Kleibergen

Description

The test is proposed by Kleibergen (2005). It is robust to weak identification.

Usage

KTest(obj, theta0 = NULL, alphaK = 0.04, alphaJ = 0.01)

## S3 method for class 'gmmTests'

print(x, digits = 5, ...)

Arguments

obj

Object of class "gmm" returned by

gmm

theta0

The null hypothesis being tested. See details.

alphaK, alphaJ

The size of the J and K tests when combining the two. The overall size is
alphaK+alphaJ.

x

An object of class

gmmTests

returned by

KTest

digits

The number of digits to be printed

...

Other arguments when

print

is applied to another class object

Details

The function produces the J-test and K-statistics which are robust to weak identification. The test is
either

H

0 :

θ

=

theta

0

, in which case theta0 must be provided, or

β

=

β

0

, where

θ

= (

α

0

, Î²

0

)

0

, and

α

is assumed to be identified. In the latter case, theta0 is NULL and obj is a restricted estimation in

which

β

is fixed to

β

0

. See

gmm

and the option "eqConst" for more details.

Value

Tests and p-values

References

Keibergen, F. (2005), Testing Parameters in GMM without assuming that they are identified.

Econo-

metrica

,

73

, 1103-1123,

Examples

library(mvtnorm)

sig <- matrix(c(1,.5,.5,1),2,2)

n <- 400

e <- rmvnorm(n,sigma=sig)

x4 <- rnorm(n)

background image

36

marginal

w <- exp(-x4^2) + e[,1]

y <- 0.1*w + e[,2]

h <- cbind(x4, x4^2, x4^3, x4^6)

g3 <- y~w

res <- gmm(g3,h)

# Testing the whole vector:

KTest(res,theta0=c(0,.1))

# Testing a subset of the vector (See \code{\link{gmm}})

res2 <- gmm(g3, h, eqConst=matrix(c(2,.1),1,2))

res2

KTest(res2)

marginal

Marginal effects Summary

Description

It produces the summary table of marginal effects for GLM estimation with GEL. Only imple-
mented for ATEgel.

Usage

## S3 method for class 'ategel'

marginal(object, ...)

Arguments

object

An object of class

ategel

returned by the function

ATEgel

...

Other arguments for other methods

Value

It returns a matrix with the marginal effects, the standard errors based on the Delta method when
the link is nonlinear, the t-ratios, and the pvalues.

References

Owen, A.B. (2001), Empirical Likelihood.

Monographs on Statistics and Applied Probability 92,

Chapman and Hall/CRC

background image

momentEstim

37

Examples

## We create some artificial data with unbalanced groups and binary outcome

genDat <- function(n)

{

eta=c(-1, .5, -.25, -.1)

Z <- matrix(rnorm(n*4),ncol=4)

b <- c(27.4, 13.7, 13.7, 13.7)

bZ <- c(Z%*%b)

Y1 <- as.numeric(rnorm(n, mean=210+bZ)>220)

Y0 <- as.numeric(rnorm(n, mean=200-.5*bZ)>220)

etaZ <- c(Z%*%eta)

pZ <- exp(etaZ)/(1+exp(etaZ))

T <- rbinom(n, 1, pZ)

Y <- T*Y1+(1-T)*Y0

X1 <- exp(Z[,1]/2)

X2 <- Z[,2]/(1+exp(Z[,1]))

X3 <- (Z[,1]*Z[,3]/25+0.6)^3

X4 <- (Z[,2]+Z[,4]+20)^2

data.frame(Y=Y, cbind(X1,X2,X3,X4), T=T)

}

dat <- genDat(200)

res <- ATEgel(Y~T, ~X1+X2+X3+X4, data=dat, type="ET", family="logit")

summary(res)

marginal(res)

momentEstim

Method for estimating models based on moment conditions

Description

It estimates a model which is caracterized by the method

getModel

(see details).

Usage

## S3 method for class 'baseGmm.twoStep'

momentEstim(object, ...)

## S3 method for class 'baseGmm.twoStep.formula'

momentEstim(object, ...)

## S3 method for class 'sysGmm.twoStep.formula'

momentEstim(object, ...)

## S3 method for class 'tsls.twoStep.formula'

momentEstim(object, ...)

## S3 method for class 'baseGmm.iterative.formula'

momentEstim(object, ...)

## S3 method for class 'baseGmm.iterative'

momentEstim(object, ...)

background image

38

nsw

## S3 method for class 'baseGmm.cue.formula'

momentEstim(object, ...)

## S3 method for class 'baseGmm.cue'

momentEstim(object, ...)

## S3 method for class 'baseGmm.eval'

momentEstim(object, ...)

## S3 method for class 'baseGel.mod'

momentEstim(object, ...)

## S3 method for class 'baseGel.modFormula'

momentEstim(object, ...)

## S3 method for class 'baseGel.eval'

momentEstim(object, ...)

Arguments

object

An object created by the method

getModel

...

Other arguments when

momentEstim

is applied to an other class object

Value

It returns an object of class determined by the argument "TypeGMM" of

gmm

By default, it is of

class

baseGmm.res

. It estimates the model and organize the results that will be finalized by the

method

FinRes

. More methods can be created in order to use other GMM methods not yet included

in the package.

References

Hansen, L.P. (1982), Large Sample Properties of Generalized Method of Moments Estimators.

Econometrica

,

50

, 1029-1054,

Hansen, L.P. and Heaton, J. and Yaron, A.(1996), Finit-Sample Properties of Some Alternative
GMM Estimators.

Journal of Business and Economic Statistics

,

14

262-280.

nsw

Lalonde subsample of the National Supported Work Demonstration
Data (NSW)

Description

This data was collected to evaluate the National Supported Work (NSW) Demonstration project in
Lalonde (1986).

Usage

data(nsw)

background image

plot

39

Format

A data frame containing 9 variables.

treat

Treatment assignment

age

Age

ed

Years of Education

black

1 if Black, 0 otherwise

hisp

1 if Hispanic 0 otherwise

married

1 if married 0 otherwise

nodeg

1 if no college degree 0 otherwise

re75

1975 earnings

re78

1978 earnings

Details

The dataset was obtained from the ATE package (see reference).

Source

"NSW Data Files" from Rajeev Dehejia’s website. URL:

http://users.nber.org/~rdehejia/

data/nswdata2.html

"National Supported Work Evaluation Study, 1975-1979: Public Use Files." from the Interuniversity
Consortium for Political and Social Research. URL:

http://www.icpsr.umich.edu/icpsrweb/

ICPSR/studies/7865

References

Lalonde, R. (1986). "Evaluating the Econometric Evaluations of Training Programs," American
Economic Review, 76(4), 604-620.

Dehejia R. and Wahba S. (1999). "Causal Effects in Non-Experimental Studies: Re-Evaluating the
Evaluation of Training Programs," JASA 94 (448), 1053-1062.

Asad Haris and Gary Chan (2015). ATE: Inference for Average Treatment Effects using Covariate
Balancing. R package version 0.2.0.

https://CRAN.R-project.org/package=ATE

plot

Plot Diagnostics for gel and gmm objects

Description

It is a plot method for

gel

or

gmm

objects.

background image

40

plot

Usage

## S3 method for class 'gel'

plot(x, which = c(1L:4),

main = list("Residuals vs Fitted values", "Normal Q-Q",

"Response variable and fitted values","Implied probabilities"),

panel = if(add.smooth) panel.smooth else points,

ask = prod(par("mfcol")) < length(which) && dev.interactive(), ...,

add.smooth = getOption("add.smooth"))

## S3 method for class 'gmm'

plot(x, which = c(1L:3),

main = list("Residuals vs Fitted values", "Normal Q-Q",

"Response variable and fitted values"),

panel = if(add.smooth) panel.smooth else points,

ask = prod(par("mfcol")) < length(which) && dev.interactive(), ...,

add.smooth = getOption("add.smooth"))

Arguments

x

gel

or

gmm

object, typically result of

gel

or

gmm

.

which

if a subset of the plots is required, specify a subset of the numbers

1:4

for

gel

or

1:3

for

gmm

.

main

Vector of titles for each plot.

panel

panel function. The useful alternative to

points

,

panel.smooth

can be chosen

by

add.smooth = TRUE

.

ask

logical; if

TRUE

, the user is

ask

ed before each plot, see

par

(ask=.)

.

...

other parameters to be passed through to plotting functions.

add.smooth

logical indicating if a smoother should be added to most plots; see also

panel

above.

Details

It is a beta version of a plot method for

gel

objects. It is a modified version of

plot.lm

. For now, it

is available only for linear models expressed as a formula. Any suggestions are welcome regarding
plots or options to include. The first two plots are the same as the ones provided by

plot.lm

, the

third is the dependant variable

y

with its mean

ˆ

y

(the fitted values) and the last plots the implied

probabilities with the empirical density

1

/T

.

Examples

# GEL #

n = 500

phi<-c(.2,.7)

thet <- 0

sd <- .2

background image

print

41

x <- matrix(arima.sim(n = n,list(order = c(2,0,1), ar = phi, ma = thet, sd = sd)), ncol = 1)

y <- x[7:n]

ym1 <- x[6:(n-1)]

ym2 <- x[5:(n-2)]

H <- cbind(x[4:(n-3)], x[3:(n-4)], x[2:(n-5)], x[1:(n-6)])

g <- y ~ ym1 + ym2

x <- H

t0 <- c(0,.5,.5)

res <- gel(g, x, t0)

plot(res, which = 3)

plot(res, which = 4)

# GMM #

res <- gmm(g, x)

plot(res, which = 3)

print

Printing a gmm or gel object

Description

It is a printing method for

gmm

or

gel

objects.

Usage

## S3 method for class 'gmm'

print(x, digits = 5, ...)

## S3 method for class 'gel'

print(x, digits = 5, ...)

## S3 method for class 'sysGmm'

print(x, digits = 5, ...)

Arguments

x

An object of class

gmm

or

gel

returned by the function

gmm

or

gel

digits

The number of digits to be printed

...

Other arguments when print is applied to an other class object

Value

It prints some results from the estimation like the coefficients and the value of the objective function.

background image

42

residuals

Examples

# GMM #

n = 500

phi<-c(.2,.7)

thet <- 0

sd <- .2

x <- matrix(arima.sim(n = n, list(order = c(2,0,1), ar = phi, ma = thet, sd = sd)), ncol = 1)

y <- x[7:n]

ym1 <- x[6:(n-1)]

ym2 <- x[5:(n-2)]

H <- cbind(x[4:(n-3)], x[3:(n-4)], x[2:(n-5)], x[1:(n-6)])

g <- y ~ ym1 + ym2

x <- H

res <- gmm(g, x)

print(res)

# GEL #

t0 <- c(0,.5,.5)

res <- gel(g,x,t0)

print(res)

residuals

Residuals of GEL or GMM

Description

Method to extract the residuals of the model estimated by

gmm

or

gel

.

Usage

## S3 method for class 'gel'

residuals(object, ...)

## S3 method for class 'gmm'

residuals(object, ...)

Arguments

object

An object of class

gmm

or

gel

returned by the function

gmm

or

gel

...

Other arguments when

residuals

is applied to an other classe object

Value

It returns the matrix of residuals

(

y

−

ˆ

y

)

in

g=y~x

as it is done by

residuals.lm

.

background image

smoothG

43

Examples

# GEL can deal with endogeneity problems

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)

y <- x[7:n]

ym1 <- x[6:(n-1)]

ym2 <- x[5:(n-2)]

H <- cbind(x[4:(n-3)], x[3:(n-4)], x[2:(n-5)], x[1:(n-6)])

g <- y ~ ym1 + ym2

x <- H

res <- gel(g, x, c(0,.3,.6))

e <- residuals(res)

plot(e, type = 'l', main = "Residuals from an ARMA fit using GEL")

# GMM is like GLS for linear models without endogeneity problems

set.seed(345)

n = 200

phi<-c(.2,.7)

thet <- 0

sd <- .2

x <- matrix(arima.sim(n = n, list(order = c(2,0,1), ar = phi, ma = thet, sd = sd)), ncol = 1)

y <- 10 + 5*rnorm(n) + x

res <- gmm(y ~ x, x)

plot(x, residuals(res), main = "Residuals of an estimated model with GMM")

smoothG

Kernel smoothing of a matrix of time series

Description

It applies the required kernel smoothing to the moment function in order for the GEL estimator to
be valid. It is used by the

gel

function.

Usage

smoothG(x, bw = bwAndrews, prewhite = 1, ar.method = "ols", weights = weightsAndrews,

kernel = c("Bartlett", "Parzen", "Truncated", "Tukey-Hanning"),

approx = c("AR(1)", "ARMA(1,1)"), tol = 1e-7)

background image

44

smoothG

Arguments

x

a

n

×

q

matrix of time series, where n is the sample size.

bw

The method to compute the bandwidth parameter. By default, it uses the band-
width proposed by Andrews(1991). As an alternative, we can choose bw=bwNeweyWest
(without "") which is proposed by Newey-West(1996).

prewhite

logical or integer. Should the estimating functions be prewhitened? If

TRUE

or

greater than 0 a VAR model of order

as.integer(prewhite)

is fitted via

ar

with method

"ols"

and

demean = FALSE

.

ar.method

character. The

method

argument passed to

ar

for prewhitening.

weights

The smoothing weights can be computed by

weightsAndrews

of it can be pro-

vided manually. If provided, it has to be a

r

×

1

vector (see details).

approx

a character specifying the approximation method if the bandwidth has to be
chosen by

bwAndrews

.

tol

numeric. Weights that exceed

tol

are used for computing the covariance matrix,

all other weights are treated as 0.

kernel

The choice of kernel

Details

The sample moment conditions

P

n
t

=1

g

(

θ, x

t

)

is replaced by:

P

n
t

=1

g

k

(

θ, x

t

)

, where

g

k

(

θ, x

t

) =

P

r
i

=

−

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.

If the vector of weights is provided, it gives only one side weights. For exemple, if you provide the
vector (1,.5,.25),

k

(

i

)

will become

(

.

25

, .

5

,

1

, .

5

, .

25)

/

(

.

25 +

.

5 + 1 +

.

5 +

.

25) = (

.

1

, .

2

, .

4

, .

2

, .

1)

Value

smoothx: A

q

×

q

matrix containing an estimator of the asymptotic variance of

√

n

¯

x

, where

¯

x

is

q

×

1

vector with typical element

¯

x

i

=

1

n

P

n
j

=1

x

ji

. This function is called by

gel

but can also be

used by itself.

kern_weights

: Vector of weights used for the smoothing.

References

Anatolyev, S. (2005), GMM, GEL, Serial Correlation, and Asymptotic Bias.

Econometrica

,

73

,

983-1002.

Andrews DWK (1991), Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Esti-
mation.

Econometrica

,

59

, 817–858.

Kitamura, Yuichi (1997), Empirical Likelihood Methods With Weakly Dependent Processes.

The

Annals of Statistics

,

25

, 2084-2102.

Zeileis A (2006), Object-oriented Computation of Sandwich Estimators.

Journal of Statistical Soft-

ware

,

16

(9), 1–16. URL

http://www.jstatsoft.org/v16/i09/

.

background image

specTest

45

Examples

g <- function(tet, x)

{

n <- nrow(x)

u <- (x[7:n] - tet[1] - tet[2]*x[6:(n-1)] - tet[3]*x[5:(n-2)])

f <- cbind(u, u*x[4:(n-3)], u*x[3:(n-4)], u*x[2:(n-5)], u*x[1:(n-6)])

return(f)

}

n = 500

phi<-c(.2, .7)

thet <- 0.2

sd <- .2

x <- matrix(arima.sim(n = n, list(order = c(2, 0, 1), ar = phi, ma = thet, sd = sd)), ncol = 1)

gt <- g(c(0, phi), x)

sgt <- smoothG(gt)$smoothx

plot(gt[,1])

lines(sgt[,1])

specTest

Compute tests of specification

Description

Generic function for testing the specification of estimated models. It computes the J-test from

gmm

objects and J-test, LR-test and LM-test from

gel

objects.

Usage

## S3 method for class 'gmm'

specTest(x, ...)

## S3 method for class 'gel'

specTest(x, ...)

## S3 method for class 'specTest'

print(x, digits = 5, ...)

specTest(x, ...)

Arguments

x

A fitted model object.

digits

The number of digits to be printed.

...

Arguments passed to methods.

Value

Tests and p-values

background image

46

summary

References

Hansen, L.P. (1982), Large Sample Properties of Generalized Method of Moments Estimators.

Econometrica

,

50

, 1029-1054,

Smith, R. J. (2004), GEL Criteria for Moment Condition Models.

CeMMAP working papers, Insti-

tute for Fiscal Studies

Examples

#################

n = 500

phi<-c(.2,.7)

thet <- 0

sd <- .2

x <- matrix(arima.sim(n=n,list(order=c(2,0,1),ar=phi,ma=thet,sd=sd)),ncol=1)

y <- x[7:n]

ym1 <- x[6:(n-1)]

ym2 <- x[5:(n-2)]

H <- cbind(x[4:(n-3)], x[3:(n-4)], x[2:(n-5)], x[1:(n-6)])

g <- y ~ ym1 + ym2

x <- H

t0 <- c(0,.5,.5)

res <- gel(g, x, t0)

specTest(res)

###################

res <- gmm(g, x)

specTest(res)

summary

Method for object of class gmm or gel

Description

It presents the results from the

gmm

or

gel

estimation in the same fashion as

summary

does for the

lm

class objects for example. It also compute the tests for overidentifying restrictions.

Usage

## S3 method for class 'gmm'

summary(object, ...)

## S3 method for class 'sysGmm'

summary(object, ...)

## S3 method for class 'gel'

summary(object, ...)

background image

summary

47

## S3 method for class 'ategel'

summary(object, robToMiss = TRUE, ...)

## S3 method for class 'tsls'

summary(object, vcov = NULL, ...)

## S3 method for class 'summary.gmm'

print(x, digits = 5, ...)

## S3 method for class 'summary.sysGmm'

print(x, digits = 5, ...)

## S3 method for class 'summary.gel'

print(x, digits = 5, ...)

## S3 method for class 'summary.tsls'

print(x, digits = 5, ...)

Arguments

object

An object of class

gmm

or

gel

returned by the function

gmm

or

gel

x

An object of class

summary.gmm

or

summary.gel

returned by the function

summary.gmm

summary.gel

digits

The number of digits to be printed

vcov

An alternative covariance matrix computed with

vcov.tsls

robToMiss

If

TRUE

, it computes the robust to misspecification covariance matrix

...

Other arguments when summary is applied to another class object

Value

It returns a list with the parameter estimates and their standard deviations, t-stat and p-values. It
also returns the J-test and p-value for the null hypothesis that

E

(

g

(

θ, X

) = 0

References

Hansen, L.P. (1982), Large Sample Properties of Generalized Method of Moments Estimators.

Econometrica

,

50

, 1029-1054,

Hansen, L.P. and Heaton, J. and Yaron, A.(1996), Finit-Sample Properties of Some Alternative
GMM Estimators.

Journal of Business and Economic Statistics

,

14

262-280.

Anatolyev, S. (2005), GMM, GEL, Serial Correlation, and Asymptotic Bias.

Econometrica

,

73

,

983-1002.

Kitamura, Yuichi (1997), Empirical Likelihood Methods With Weakly Dependent Processes.

The

Annals of Statistics

,

25

, 2084-2102.

Newey, W.K. and Smith, R.J. (2004), Higher Order Properties of GMM and Generalized Empirical
Likelihood Estimators.

Econometrica

,

72

, 219-255.

Examples

# GMM #

set.seed(444)

n = 500

background image

48

sysGmm

phi<-c(.2,.7)

thet <- 0

sd <- .2

x <- matrix(arima.sim(n = n, list(order = c(2,0,1), ar = phi, ma = thet, sd = sd)), ncol = 1)

y <- x[7:n]

ym1 <- x[6:(n-1)]

ym2 <- x[5:(n-2)]

ym3 <- x[4:(n-3)]

ym4 <- x[3:(n-4)]

ym5 <- x[2:(n-5)]

ym6 <- x[1:(n-6)]

g <- y ~ ym1 + ym2

x <- ~ym3+ym4+ym5+ym6

res <- gmm(g, x)

summary(res)

# GEL #

t0 <- res$coef

res <- gel(g, x, t0)

summary(res)

# tsls #

res <- tsls(y ~ ym1 + ym2,~ym3+ym4+ym5+ym6)

summary(res)

sysGmm

Generalized method of moment estimation for system of equations

Description

Functions to estimate a system of equations based on GMM.

Usage

sysGmm(g, h, wmatrix = c("optimal","ident"),

vcov=c("MDS", "HAC", "CondHom", "TrueFixed"),

kernel=c("Quadratic Spectral","Truncated", "Bartlett", "Parzen", "Tukey-Hanning"),

crit=10e-7,bw = bwAndrews, prewhite = FALSE, ar.method = "ols", approx="AR(1)",

tol = 1e-7, model=TRUE, X=FALSE, Y=FALSE, centeredVcov = TRUE,

weightsMatrix = NULL, data, crossEquConst = NULL, commonCoef = FALSE)

five(g, h, commonCoef = FALSE, data = NULL)

threeSLS(g, h, commonCoef = FALSE, data = NULL)

sur(g, commonCoef = FALSE, data = NULL)

randEffect(g, data = NULL)

background image

sysGmm

49

Arguments

g

A possibly named list of formulas

h

A formula if the same instruments are used in each equation or a list of formulas.

wmatrix

Which weighting matrix should be used in the objective function. By default, it
is the inverse of the covariance matrix of

g

(

θ, x

)

. The other choice is the identity

matrix.

vcov

Assumption on the properties of the moment vector. By default, it is a martin-
gale difference sequence. "HAC" is for weakly dependent processes and "Cond-
Hom" implies conditional homoscedasticity. The option "TrueFixed" is used
only when the matrix of weights is provided and it is the optimal one.

kernel

type of kernel used to compute the covariance matrix of the vector of sample
moment conditions (see

kernHAC

for more details)

crit

The stopping rule for the iterative GMM. It can be reduce to increase the preci-
sion.

bw

The method to compute the bandwidth parameter. By default it is

bwAndrews

which is proposed by Andrews (1991). The alternative is

bwNeweyWest

of

Newey-West(1994).

prewhite

logical or integer. Should the estimating functions be prewhitened? If

TRUE

or

greater than 0 a VAR model of order

as.integer(prewhite)

is fitted via

ar

with method

"ols"

and

demean = FALSE

.

ar.method

character. The

method

argument passed to

ar

for prewhitening.

approx

A character specifying the approximation method if the bandwidth has to be
chosen by

bwAndrews

.

tol

Weights that exceed

tol

are used for computing the covariance matrix, all other

weights are treated as 0.

model, X, Y

logical. If

TRUE

the corresponding components of the fit (the model frame, the

model matrix, the response) are returned if g is a formula.

centeredVcov

Should the moment function be centered when computing its covariance matrix.
Doing so may improve inference.

weightsMatrix

It allows users to provide

gmm

with a fixed weighting matrix. This matrix must

be

q

×

q

, symmetric and strictly positive definite. When provided, the

type

option becomes irrelevant.

data

A data.frame or a matrix with column names (Optional).

commonCoef

If true, coefficients accross equations are the same

crossEquConst

Only used if the number of regressors are the same in each equation. It is a vector
which indicates which coefficient are constant across equations. The order is 1
for Intercept and 2 to k as it is formulated in the formulas

g

. Setting it to

1:k

is

equivalent to setting commonCoef to TRUE.

Details

This set of functions implement the estimation of system of equations as presented in Hayashi
(2000)

background image

50

sysGmm

Value

’sysGmm’ returns an object of â€™class’ â€™"sysGmm"’

The functions â€™summary’ is used to obtain and print a summary of the results. It also compute the
J-test of overidentying restriction

The object of class "sysGmm" is a list containing at least:

coefficients

list of vectors of coefficients for each equation

residuals

list of the residuals for each equation.

fitted.values

list of the fitted values for each equation.

vcov

the covariance matrix of the stacked coefficients

objective

the value of the objective function

k

var

(¯

g

)

−

1

/

2

¯

g

k

2

terms

The list of

terms

objects for each equation

call

the matched call.

y

If requested, a list of response variables.

x

if requested, a list of the model matrices.

model

if requested (the default), a list of the model frames.

References

Zeileis A (2006), Object-oriented Computation of Sandwich Estimators.

Journal of Statistical Soft-

ware

,

16

(9), 1–16. URL

http://www.jstatsoft.org/v16/i09/

.

Andrews DWK (1991), Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Esti-
mation.

Econometrica

,

59

, 817–858.

Newey WK & West KD (1987), A Simple, Positive Semi-Definite, Heteroskedasticity and Auto-
correlation Consistent Covariance Matrix.

Econometrica

,

55

, 703–708.

Newey WK & West KD (1994), Automatic Lag Selection in Covariance Matrix Estimation.

Review

of Economic Studies

,

61

, 631-653.

Hayashi, F. (2000), Econometrics.

Princeton University Press

.

Examples

data(wage)

eq1 <- LW~S+IQ+EXPR

eq2 <- LW80~S80+IQ+EXPR80

g2 <- list(Wage69=eq1, WAGE80=eq2)

h2 <- list(~S+EXPR+MED+KWW, ~S80+EXPR80+MED+KWW)

res <- sysGmm(g2, h2, data=wage, commonCoef=TRUE)

summary(res)

res2 <- sysGmm(g2, h2, data=wage)

summary(res2)

background image

tsls

51

five(g2, h2, data=wage)

threeSLS(g2, h2[[1]], data=wage)

sur(g2, data=wage)

randEffect(g2, data=wage)

## Cross-Equation restrictions

## All but the intercept are assumed to be the same

res <- sysGmm(g2, h2, data=wage, crossEquConst = 2:4)

summary(res)

tsls

Two stage least squares estimation

Description

Function to estimate a linear model by the two stage least squares method.

Usage

tsls(g,x,data)

Arguments

g

A formula describing the linear regression model (see details below).

x

The matrix of instruments (see details below).

data

A data.frame or a matrix with column names (Optionnal).

Details

The function just calls

gmm

with the option vcov="iid". It just simplifies the the implementation of

2SLS. The users don’t have to worry about all the options offered in

gmm

The model is

Y

i

=

X

i

β

+

u

i

In the first step,

lm

is used to regress

X

i

on the set of instruments

Z

i

. The second step also uses

lm

to regress

Y

i

on the fitted values of the first step.

Value

’tsls’ returns an object of â€™class’ â€™"tsls"’ which inherits from class â€™"gmm"’.

The functions â€™summary’ is used to obtain and print a summary of the results. It also compute the
J-test of overidentying restriction

The object of class "gmm" is a list containing at least:

background image

52

vcov

coefficients

k

×

1

vector of coefficients

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.

vcov

the covariance matrix of the coefficients

objective

the value of the objective function

k

var

(¯

g

)

−

1

/

2

¯

g

k

2

terms

the

terms

object used when g is a formula.

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.

algoInfo

Information produced by either

optim

or

nlminb

related to the convergence if

"g" is a function. It is printed by the

summary.gmm

method.

References

Hansen, L.P. (1982), Large Sample Properties of Generalized Method of Moments Estimators.

Econometrica

,

50

, 1029-1054,

Examples

n <- 1000

e <- arima.sim(n,model=list(ma=.9))

C <- runif(n,0,5)

Y <- rep(0,n)

Y[1] = 1 + 2*C[1] + e[1]

for (i in 2:n){

Y[i] = 1 + 2*C[i] + 0.9*Y[i-1] + e[i]

}

Yt <- Y[5:n]

X <- cbind(C[5:n],Y[4:(n-1)])

Z <- cbind(C[5:n],Y[3:(n-2)],Y[2:(n-3)],Y[1:(n-4)])

res <- tsls(Yt~X,~Z)

res

vcov

Variance-covariance matrix of GMM or GEL

Description

It extracts the matrix of variances and covariances from

gmm

or

gel

objects.

background image

vcov

53

Usage

## S3 method for class 'gmm'

vcov(object, ...)

## S3 method for class 'gel'

vcov(object, lambda = FALSE, ...)

## S3 method for class 'tsls'

vcov(object, type=c("Classical","HC0","HC1","HAC"),

hacProp = list(), ...)

## S3 method for class 'ategel'

vcov(object, lambda = FALSE, robToMiss = TRUE, ...)

Arguments

object

An object of class

gmm

or

gmm

returned by the function

gmm

or

gel

lambda

If set to TRUE, the covariance matrix of the Lagrange multipliers is produced.

type

Type of covariance matrix for the meat

hacProp

A list of arguments to pass to

kernHAC

robToMiss

If

TRUE

, it computes the robust to misspecification covariance matrix

...

Other arguments when

vcov

is applied to another class object

Details

For tsls(), if vcov is set to a different value thand "Classical", a sandwich covariance matrix is
computed.

Value

A matrix of variances and covariances

Examples

# GMM #

n = 500

phi<-c(.2,.7)

thet <- 0

sd <- .2

x <- matrix(arima.sim(n = n,list(order = c(2,0,1), ar = phi, ma = thet, sd = sd)), ncol = 1)

y <- x[7:n]

ym1 <- x[6:(n-1)]

ym2 <- x[5:(n-2)]

H <- cbind(x[4:(n-3)], x[3:(n-4)], x[2:(n-5)], x[1:(n-6)])

g <- y ~ ym1 + ym2

x <- H

res <- gmm(g, x)

vcov(res)

background image

54

wage

## GEL ##

t0 <- c(0,.5,.5)

res <- gel(g, x, t0)

vcov(res)

vcov(res, lambda = TRUE)

wage

Labor Data

Description

Data used to measure return to education by Griliches (1976)

Usage

data(wage)

Format

A data frame containing 20 cross-sectional vectors.

AGE, AGE80

Age in 1969 and 1980 respetively

EXPR, EXPR80

Working experience in 1969 and 1980 respetively

IQ

IQ measure of the individual

KWW

A test score

LW, LW80

Log wage in 1969 and 1980 respectively

MED

Mother education

MRT, MRT80

RNS, RNS80

S, S80

Schooling in 1969 and 1980 respetively

SMSA, SMSA80

TENURE, TENURE80

Tenure in 1969 and 1980 respetively

YEAR

Source

http://fhayashi.fc2web.com/datasets.htm

background image

Index

∗

Topic

datasets

Finance

,

14

Growth

,

34

nsw

,

38

wage

,

54

ar

,

7

,

19

,

28

,

44

,

49

ATEgel

,

2

,

36

bread

,

5

bwAndrews

,

7

,

19

,

49

bwNeweyWest

,

19

,

49

bwWilhelm

,

6

charStable

,

8

checkConv

(

ATEgel

)

,

2

coef

,

9

confint

,

10

constrOptim

,

3

,

19

–

21

,

24

,

25

,

28

estfun

,

12

evalGel

,

20

evalGel

(

gel

)

,

18

evalGmm

(

gmm

)

,

26

Finance

,

14

FinRes

,

15

fitted

,

15

five

(

sysGmm

)

,

48

formula

,

17

gel

,

4

,

9

,

10

,

15

–

17

,

18

,

20

,

23

,

25

,

40

–

42

,

44

,

47

,

53

getDat

,

23

getLamb

,

3

,

19

,

21

,

24

getModel

,

25

gmm

,

9

,

10

,

12

,

15

–

17

,

20

,

23

,

26

,

29

,

35

,

38

,

40

–

42

,

47

,

51

,

53

gmmWithConst

(

gmm

)

,

26

Growth

,

34

kernHAC

,

7

,

12

,

13

,

19

,

27

,

49

,

53

KTest

,

35

lm

,

20

,

29

,

51

marginal

,

36

model.matrix.tsls

(

estfun

)

,

12

momentEstim

,

37

nlminb

,

3

,

4

,

19

,

20

,

24

,

28

,

30

,

52

nsw

,

38

optim

,

3

,

4

,

19

–

21

,

24

,

27

–

30

,

52

optimize

,

19

–

21

,

28

panel.smooth

,

40

par

,

40

plot

,

39

points

,

40

print

,

41

print.confint

(

confint

)

,

10

print.gmmTests

(

KTest

)

,

35

print.specTest

(

specTest

)

,

45

print.summary.gel

(

summary

)

,

46

print.summary.gmm

(

summary

)

,

46

print.summary.sysGmm

(

summary

)

,

46

print.summary.tsls

(

summary

)

,

46

randEffect

(

sysGmm

)

,

48

residuals

,

42

sandwich

,

13

smoothG

,

43

specTest

,

45

summary

,

46

summary.ategel

(

summary

)

,

46

summary.gel

,

47

summary.gel

(

summary

)

,

46

summary.gmm

,

47

summary.gmm

(

summary

)

,

46

summary.sysGmm

(

summary

)

,

46

55

background image

56

INDEX

summary.tsls

(

summary

)

,

46

sur

(

sysGmm

)

,

48

sysGmm

,

23

,

48

terms

,

21

,

30

,

50

,

52

threeSLS

(

sysGmm

)

,

48

tsls

,

12

,

51

vcov

,

52

vcov.tsls

,

13

vcovHAC

,

13

wage

,

54

weightsAndrews

,

44


Document Outline