vcov-methods: ~~ Methods for Function 'vcov' in Package 'stats' ~~

Description Usage Arguments Details Methods Examples

Description

Computes the covariance matrix of the coefficient estimated by GMM or GEL.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## S4 method for signature 'gmmfit'
vcov(object, sandwich=NULL, df.adj=FALSE,
breadOnly=FALSE, modelVcov=NULL)

## S4 method for signature 'sgmmfit'
vcov(object, sandwich=NULL, df.adj=FALSE,
breadOnly=FALSE, modelVcov=NULL)

## S4 method for signature 'tsls'
vcov(object, sandwich=TRUE, df.adj=FALSE)

## S4 method for signature 'gelfit'
vcov(object, withImpProb=FALSE, tol=1e-10)

Arguments

object

An object of class "gmmfit"

sandwich

Should we compute the sandwich covariance matrix. This is only necessary if the weighting matrix is not the optimal one, or if we think it is a bad estimate of it. If NULL, it will be set to "TRUE" for One-Step GMM, which includes just-identified GMM like IV, and "FALSE" otherwise.

df.adj

Should we adjust for degrees of freedom. If TRUE the covariance matrix is multiplied by n/(n-k), where n is the sample size and k is the number of coefficients. For heteroscedastic robust covariance matrix, adjusting is equivalent to computing HC1 while not adjusting is HC0.

breadOnly

If TRUE, the covariance matrix is set to the bread (see details below).

modelVcov

Should be one of "iid", "MDS" or "HAC". It is meant to change the way the variance of the moments is computed. If it is set to a different specification included in the model, sandwich is set to TRUE.

withImpProb

Should we compute the moments with the implied probabilities

tol

Any diagonal less than "tol" is set to tol

Details

If sandwich=FALSE, then it returns (G'V^{-1}G)^{-1}/n, where G and V are respectively the matrix of average derivatives and the covariance matrix of the moment conditions. If it is TRUE, it returns (G'WG)^{-1}G'WVWG(G'WG)^{-1}/n, where W is the weighting matrix used to obtain the vector of estimates.

If breadOnly=TRUE, it returns (G'WG)^{-1}/n, where the value of W depends on the type of GMM. For two-step GMM, it is the first step weighting matrix, for one-step GMM, it is either the identity matrix or the fixed weighting matrix that was provided when modelFit was called, for iterative GMM, it is the weighting matrix used in the last step. For CUE, the result is identical to sandwich=FALSE and beadOnly=FALSE, because the weighting and coefficient estimates are obtained simultaneously, which makes W identical to V.

breadOnly=TRUE should therefore be used with caution because it will produce valid standard errors only if the weighting matrix converges to the the inverse of the covariance matrix of the moment conditions.

For "tsls" objects, sandwich is TRUE by default. If we assume that the error term is iid, then setting it to FALSE to result in the usual σ^2(\hat{X}'\hat{X})^{-1} covariance matrix. If FALSE, it returns a robust covariance matrix determined by the value of vcov in the gmmModels.

Methods

signature(object = "gmmfit")

For any model estimated by any GMM methods.

signature(object = "gelfit")

For any model estimated by any GMM methods.

signature(object = "sgmmfit")

For any system of equations estimated by any GMM methods.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
data(simData)
theta <- c(beta0=1,beta1=2)
model1 <- gmmModel(y~x1, ~z1+z2, data=simData)

## optimal matrix
res <- modelFit(model1)
vcov(res)

## not the optimal matrix
res <- modelFit(model1, weights=diag(3))
vcov(res, TRUE)

## Model with heteroscedasticity
## MDS is for models with no autocorrelation.
## No restrictions are imposed on the structure of the
## variance of the moment conditions
model2 <- gmmModel(y~x1, ~z1+z2, data=simData, vcov="MDS")
res <- tsls(model2)

## HC0 type of robust variance
vcov(res, sandwich=TRUE)
## HC1 type of robust variance
vcov(res, sandwich=TRUE, df.adj=TRUE)

## Fixed and True Weights matrix
## Consider the moment of a normal distribution:
## Using the first three non centered moments

g <- function(theta, x)
{
mu <- theta[1]
sig2 <- theta[2]
m1 <- x-mu
m2 <- x^2-mu^2-sig2
m3 <- x^3-mu^3-3*mu*sig2
cbind(m1,m2,m3)
}

dg <- function(theta, x)
{
mu <- theta[1]
sig2 <- theta[2]
G <- matrix(c(-1,-2*mu,-3*mu^2-3*sig2, 0, -1, -3*mu),3,2)
}

x <- simData$x3

model <- gmmModel(g, x, c(mu=.1, sig2=1.5), vcov="iid")
res1 <- modelFit(model)
summary(res1)
## Same results (that's because the moment vcov is centered by default)
W <- solve(var(cbind(x,x^2,x^3)))
res2 <- modelFit(model, weights=W)
res2
## If is therefore more efficient in this case to do the following:
## the option breadOnly of summary() is passed to vcov()
summary(res2, breadOnly=TRUE)

gmm4 documentation built on Dec. 6, 2019, 3:01 a.m.