DWH-methods {momentfit} | R Documentation |
DWH
in Package momentfit ~~It performs the Durbin-Wu-Hausman test on GMM fit models.
## S4 method for signature 'gmmfit,missing' DWH(object1, object2) ## S4 method for signature 'gmmfit,lm' DWH(object1, object2, tol=sqrt(.Machine$double.eps), v1=NULL, v2=NULL, ...) ## S4 method for signature 'gmmfit,gmmfit' DWH(object1, object2, tol=sqrt(.Machine$double.eps), v1=NULL, v2=NULL, ...)
object1 |
Object of class |
object2 |
Object of class |
v1 |
Alternatively, we can provide a different covariance matrix for object1 |
v2 |
Alternatively, we can provide a different covariance matrix for object2 |
tol |
Tolerance for the Moore-Penrose generalized inverse |
... |
Argument to pass to |
signature(object1 = "gmmfit", object2 = "lm")
signature(object1 = "gmmfit", object2 = "gmmfit")
signature(object1 = "gmmfit", object2 = "missing")
Green, W.H.. (2012). Econometric Analysis, 7th edition, Prentice Hall.
### Exampe 8.7 of Greene (2012) data(ConsumptionG) Y <- ConsumptionG$REALDPI C <- ConsumptionG$REALCONS n <- nrow(ConsumptionG) Y1 <- Y[-n]; Y <- Y[-1] C1 <- C[-n]; C <- C[-1] dat <- data.frame(Y=Y,Y1=Y1,C=C,C1=C1) model1 <- momentModel(C~Y, ~Y, data=dat, vcov="iid") model2 <- momentModel(C~Y, ~Y1+C1, data=dat, vcov="iid") res1 <- tsls(model1) res2 <- tsls(model2) res <- lm(C~Y) ## Exampke 8.7-2. The difference is explained by the rounding ## error in Greene. Only the first the 3 digits of the t-test are used. DWH(res2) ## Example 8.7-1. Not quite the same. DWH(res2, res1) ## using lm object to compare OLS and 2SLS: ## The same adjustment on the vcov must be done (it is by default in lm) ## otherwise the different in the covariance matrices is mostly caused by the ## different ways to compute them. DWH(res2, res, df.adj=TRUE) ## To reproduce the same results as Exampke 8.7-1, ## we need to specify the variance. ## But it is not necessary as the above way is ## asymptotically equivalent X <- model.matrix(model1) Xhat <- qr.fitted(res2@wObj@w, X) s2 <- sum(residuals(res)^2)/(res$df.residual) v1 <- solve(crossprod(Xhat))*s2 v2 <- solve(crossprod(X))*s2 DWH(res2, res, v1=v1, v2=v2)