momentModel {momentfit} | R Documentation |
Constructor for "momentModel"
classes
Description
It builds an object class "momentModel"
, which is a
union class for "linearModel"
, "nonlinearModel"
,
"formulaModel"
and "functionModel"
classes. These are
classes for moment based models. This is the first step before running
any estimation algorithm.
Usage
momentModel(g, x=NULL, theta0=NULL,grad=NULL,
vcov = c("iid", "HAC", "MDS", "CL"),
vcovOptions=list(), centeredVcov = TRUE, data=parent.frame(),
na.action="na.omit", survOptions=list(), smooth=FALSE)
Arguments
g |
A function of the form |
x |
The matrix or vector of data from which the function
|
theta0 |
A |
grad |
A function of the form |
vcov |
Assumption on the properties of the moment conditions. By
default, they are weakly dependant processes. For |
vcovOptions |
A list of options for the covariance matrix of the
moment conditions. See |
centeredVcov |
Should the moment function be centered when computing its covariance matrix. Doing so may improve inference. |
data |
A data.frame or a matrix with column names (Optional). |
na.action |
Action to take for missing values. If missing values
are present and the option is set to |
survOptions |
If needed, a list with the type of survey weights and
the weights as a numeric vector, data.frame or formula. The type is either
|
smooth |
If |
Value
'momentModel' returns an object of one of the subclasses of "momentModel"
.
References
Andrews DWK (1991), Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Estimation. Econometrica, 59, 817–858.
Newey WK & West KD (1987), A Simple, Positive Semi-Definite, Heteroskedasticity and Autocorrelation Consistent Covariance Matrix. Econometrica, 55, 703–708.
Newey WK & West KD (1994), Automatic Lag Selection in Covariance Matrix Estimation. Review of Economic Studies, 61, 631-653.
Examples
data(simData)
theta <- c(beta0=1,beta1=2)
## A linearModel
model1 <- momentModel(y~x1, ~z1+z2, data=simData)
## A nonlinearModel
g <- y~beta0+x1^beta1
h <- ~z1+z2
model2 <- momentModel(g, h, c(beta0=1, beta1=2), data=simData)
## A functionModel
fct <- function(tet, x)
{
m1 <- (tet[1] - x)
m2 <- (tet[2]^2 - (x - tet[1])^2)
m3 <- x^3 - tet[1]*(tet[1]^2 + 3*tet[2]^2)
f <- cbind(m1, m2, m3)
return(f)
}
dfct <- function(tet, x)
{
jacobian <- matrix(c( 1, 2*(-tet[1]+mean(x)), -3*tet[1]^2-3*tet[2]^2,0, 2*tet[2],
-6*tet[1]*tet[2]), nrow=3,ncol=2)
return(jacobian)
}
model3 <- momentModel(fct, simData$x3, theta0=c(beta0=1, beta1=2), grad=dfct)