This document is meant to describe how to create system of equations objects, estimating them and peforming hypothesis tests.
Instread of repeating the same eample for each method, we are going through all methods and classes for systems of 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 70 71 72 | data(simData)
## first, we create an sysGmm object
g1 <- y1~x1+x4; h1 <- ~x4+z1+z2+z3+z4
g2 <- y2~x1+x2+x3; h2 <- ~x3+z1+z2+z3+z4
g3 <- y3~x2+x3+x4; h3 <- ~x3+x4+z1+z2+z3+z4
g <- list(g1,g2,g3)
h <- list(h1,h2,h3)
smodel <- sysGmmModel(g, h, data=simData, vcov="MDS")
## The show or print method
smodel
## The ']' method
smodel[1:2]
smodel[1] ## becomes a one equation model
## equation by equation 2SLS
tsls(smodel)
## or manually
lapply(1:3, function(i) coef(tsls(smodel[i])))
## Fitting the model by two-step GMM
res <- modelFit(smodel)
## testing Overidentifying restrictions
specTest(res)
## All info using the summary method
## which includes equation by equation measures of
## the instrument stengths
summary(res)
### When the error id iid (homoscedastic), we have a
### FIVE estimator with 2SLS as the first step
smodel <- sysGmmModel(g, h, data=simData, vcov="iid")
modelFit(smodel)
### When the error is iid (homoscedastic),
### all instruments are the same, and the first step is 2SLS,
### we have 3SLS
smodel <- sysGmmModel(g, ~x4+z1+z2+z3+z4, data=simData, vcov="iid")
modelFit(smodel, initW='tsls')
### When the error is iid (homoscedastic),
### the instruments are the same and are the union of all regressors,
### we have SUR
smodel <- sysGmmModel(g, NULL, data=simData, vcov="iid")
modelFit(smodel, initW='tsls')
############ Restricted models ##################
## unrestricted
smodel <- sysGmmModel(g, h, data=simData, vcov="MDS")
res <- modelFit(smodel)
## no cross-equation restrictions
R1 <- list(c("x1=-12*x4"), character(), c("x2=0.8", "x4=0.3"))
rm1 <- restModel(smodel, R1)
(res1 <- modelFit(rm1))
## Cross equation restrictions
R2<- c("Eqn1.x1=1", "Eqn2.x1=Eqn3.x2")
rm2 <- restModel(smodel, R2)
(es2 <- modelFit(rm2))## no longer expressed as a system
## testing the restriction
hypothesisTest(res, res1, type="LR")
hypothesisTest(res, res1, type="LM")
hypothesisTest(res, res1, type="Wald")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.