Description Usage Arguments Details Methods Examples
Performs hypothesis tests on the coefficients estimated by any GMM fit method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  ## S4 method for signature 'gmmfit,missing'
hypothesisTest(object.u, object.r, R,
rhs=NULL, vcov=NULL, ...)
## S4 method for signature 'sgmmfit,missing'
hypothesisTest(object.u, object.r, R,
rhs=NULL, vcov=NULL, ...)
## S4 method for signature 'gmmfit,gmmfit'
hypothesisTest(object.u, object.r,
type=c("Wald", "LR", "LM"), sameVcov=TRUE, vcov=NULL,
firstStepWeight=FALSE, wObj=NULL, ...)
## S4 method for signature 'sgmmfit,sgmmfit'
hypothesisTest(object.u, object.r,
type=c("Wald", "LR", "LM"), sameVcov=TRUE, vcov=NULL,
firstStepWeight=FALSE, wObj=NULL, ...)
## S4 method for signature 'missing,gmmfit'
hypothesisTest(object.u, object.r, wObj=NULL)
## S4 method for signature 'missing,sgmmfit'
hypothesisTest(object.u, object.r, wObj=NULL)

object.u 
An object of class 
object.r 
An object of class 
R 
If it is an object of class 
rhs 
A vector of right hand sides if 
type 
Should we perform a Wald, LR or LM test? 
sameVcov 
For the LR test, should we use the same estimate of the covariance matrix of the moment conditions? See details below. 
vcov 
For the Wald test, it is possible to provide the method with the covariance matrix of the coefficients. 
wObj 
For the LR test, it is possible to provide the

... 
Other argument to pass to 
firstStepWeight 
Should we use the first step weighting matrix to compute the test (By default, the optimal weighting matrix is recomputed using the final vector of coefficient estimates). See details below. 
The LR test is the difference between the Jtests of the restricted and unrestricted models. It is therefore n\bar{g}_r'W_r\bar{g}_r  n\bar{g}_u'W_u\bar{g}_u, where \bar{g}_r and \bar{g}_u are respectively the restricted and unrestricted sample mean of the moment conditions, and W_r and W_u their respective optimal weigthing matrix. The test is therefore invalid if either of the weighting matrices does not converge to the inverse of the covariance matrix of the moment conditions. The restricted and unrestricted models must therefore be estimated by efficient GMM. This is not required for the Wald test.
Asymptotically, it makes no difference which consistent estimate of W_u or W_r is used. However, it will make a difference in finite samples.
If sameVcov=TRUE
, both W_r and W_u are equal to the
the optimal weighting matrix from the unrestricted model if
firstStepWeight=FALSE
, and they are equal to the first step
weighting matrix (or the last step for iteratice GMM) of the
unrestricted model if it is TRUE
. For CUE, the value of
firstStepWeight
makes no difference since the weighting matrix
and coefficients are computed simultaneously. Having W_r=W_u
prevents the test to be negative in small samples.
If wObj
is provided, both W_r and W_u are equal to
it. Of cource, wObj
must be a consistent estimate of the
optimal weighting matrix for the test to be valid.
signature(object.u = "gmmfit", object.r = "gmmfit")
Used to test a restricted model against an unrestricted one.
signature(object.u = "sgmmfit", object.r = "sgmmfit")
Used to test a restricted model against an unrestricted one (for systems of equations).
signature(object.u = "missing", object.r= "gmmfit")
Used to test a restricted model using the LM test.
signature(object.u = "missing", object.r= "sgmmfit")
Used to test a restricted model using the LM test (for systems of equations).
signature(object.u = "gmmfit", object.r = "missing")
Perform a Wald test using an unrestricted model and a restriction matrix or vector.
signature(object.u = "sgmmfit", object.r = "missing")
Perform a Wald test using an unrestricted model and a restriction matrix or vector in systems of linear equations.
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 58 59 60 61 62 63 64 65 66 67 68 69  data(simData)
## Unrestricted model
model1 < gmmModel(y~x1+x2+x3, ~x2+x3+z1+z2+z3, data=simData, vcov="MDS")
res1 < modelFit(model1)
## Wald test
R < c("x1=0.5","x2=x3")
hypothesisTest(object.u=res1, R=R)
## LR tests
rmodel1 < restModel(model1, R)
res2 < modelFit(rmodel1)
hypothesisTest(object.u=res1, object.r=res2, type="LR")
### LR and Wald should be the same as long as the same weighting
### matrix if used for both GMM fits, for the LR and Wald as well
# Unrestricted model and save the weights
res1 < modelFit(model1)
w < res1@wObj
# estimate models with the same weights
res2 < modelFit(rmodel1, weights=w)
# LR test with the same weights
hypothesisTest(res1, res2, type="LR", wObj=w)
# Wald test with vcov based on the same weights (or the bread)
hypothesisTest(object.u=res1, R=R, breadOnly=TRUE)
### Another example with real data
data(Mroz)
model < gmmModel(log(wage)~educ+exper+I(exper^2),
~exper+I(exper^2)+fatheduc+motheduc, vcov="MDS",
data=Mroz, centeredVcov=FALSE)
R < c("educ=0","I(exper^2)=0")
rmodel < restModel(model, R)
res1 < modelFit(model)
res2 < modelFit(rmodel, weights=res1@wObj)
hypothesisTest(object.u=res1, object.r=res2, type="LR", wObj=res1@wObj)
hypothesisTest(object.u=res1, object.r=res2, type="Wald",
vcov=vcov(res1, breadOnly=TRUE))
## LM test (identical to the other two tests as well)
hypothesisTest(object.r=res2)
# or
hypothesisTest(object.u=res1, object.r=res2, type="LM")
## Wald with the Delta Method:
## To impose nonlinear restrictions, we need to convert
## the linear model into a nonlinear one
NLmodel < as(model1, "nonlinearGmm")
R1 < c("theta2=2", "theta3=theta4^2")
rNLmodel < restModel(NLmodel, R1)
res.u < modelFit(NLmodel)
res.r < modelFit(rNLmodel)
hypothesisTest(object.u=res.u, R=R1)
## LM
hypothesisTest(object.r=res.r)
## LR
hypothesisTest(object.r=res.r, object.u=res.u, type="LR")

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.