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

vcov-methodsR Documentation

~~ Methods for Function vcov in Package stats ~~

Description

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

Usage

## 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,
                        robToMiss=FALSE)

## S4 method for signature 'momentModel'
vcov(object, theta)

## S4 method for signature 'sysModel'
vcov(object, theta)

Arguments

object

A fitted model or a model, For fitted models, it computes the covariance matrix of the estimators. For models, it computes the covariance matrix of the moment conditions, in which case, the coefficient vector must be provided.

theta

Coefficient vector to compute the covariance matrix of the moment conditions.

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

robToMiss

Should we compute a covariance matrix that is robust to misspecification?

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 gmmFit 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 \sigma^2(\hat{X}'\hat{X})^{-1} covariance matrix. If FALSE, it returns a robust covariance matrix determined by the value of vcov in the momentModel.

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

data(simData)
theta <- c(beta0=1,beta1=2)
model1 <- momentModel(y~x1, ~z1+z2, data=simData)

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

## not the optimal matrix
res <- gmmFit(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 <- momentModel(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 <- momentModel(g, x, c(mu=.1, sig2=1.5), vcov="iid")
res1 <- gmmFit(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 <- gmmFit(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)

momentfit documentation built on Sept. 20, 2023, 3:01 a.m.