momentModel {momentfit} | R Documentation |
"momentModel"
classesIt 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.
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)
g |
A function of the form g(θ,x) and which returns a n \times q matrix with typical element g_i(θ,x_t) for i=1,...q and t=1,...,n. This matrix is then used to build the q sample moment conditions. It can also be a formula if the model is linear (see detailsbelow). |
x |
The matrix or vector of data from which the function g(θ,x) is computed. If "g" is a formula, it is an n \times Nh matrix of instruments or a formula (see details below). |
theta0 |
A k \times 1 vector of starting values. It is required only when "g" is a function because only then a numerical algorithm is used to minimize the objective function. If the dimension of θ is one, see the argument "optfct". |
grad |
A function of the form G(θ,x) which returns a
q\times k matrix of derivatives of \bar{g}(θ) with
respect to θ. By default, the numerical algorithm
|
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 |
'momentModel' returns an object of one of the subclasses of "momentModel"
.
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.
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)