evalDMoment-methods {gmm4} | R Documentation |
evalDMoment
in Package gmm4 ~~It computes the matrix of derivatives of the sample moments with respect to the coefficients.
## S4 method for signature 'functionGmm' evalDMoment(object, theta, impProb=NULL, lambda=NULL) ## S4 method for signature 'rfunctionGmm' evalDMoment(object, theta, impProb=NULL, lambda=NULL) ## S4 method for signature 'rnonlinearGmm' evalDMoment(object, theta, impProb=NULL, lambda=NULL) ## S4 method for signature 'formulaGmm' evalDMoment(object, theta, impProb=NULL, lambda=NULL) ## S4 method for signature 'rformulaGmm' evalDMoment(object, theta, impProb=NULL, lambda=NULL) ## S4 method for signature 'regGmm' evalDMoment(object, theta, impProb=NULL, lambda=NULL) ## S4 method for signature 'sysGmmModels' evalDMoment(object, theta) ## S4 method for signature 'rslinearGmm' evalDMoment(object, theta) ## S4 method for signature 'gelModels' evalDMoment(object, theta, impProb=NULL, lambda=NULL) ## S4 method for signature 'rgelModels' evalDMoment(object, theta, impProb=NULL, lambda=NULL)
object |
An model object |
theta |
A numerical vector of coefficients |
impProb |
If a vector of implied probablities is provided, the sample means are computed using them. If not provided, the means are computed using the uniform weight |
lambda |
A vector of Lagrange multipliers associated with the moment conditions. Its length must therefore match the number of conditions. See details below. |
Without the argument lambda
, the method returns a q \times
k matrix, where k is the number of coefficients, and q is
the number of moment conditions. That matrix is the derivative of the
sample mean of the moments with respect to the coefficient.
If lambda
is provided, the method returns an n \times k
matrix, where n is the sample size. The ith row is
G_i'λ, where $G_i$ is the derivative of the moment
function evaluated at the ith observation. For now, this option is
used to compute robust-to-misspecified standard errors of GEL
estimators.
signature(object = "functionGmm")
signature(object = "rfunctionGmm")
The theta vector must match the number of coefficients in the restricted model.
signature(object = "gelModels")
signature(object = "rgelModels")
signature(object = "formulaGmm")
signature(object = "rformulaGmm")
The theta vector must match the number of coefficients in the restricted model.
signature(object = "regGmm")
signature(object = "sysGmmModels")
signature(object = "rslinearGmm")
data(simData) theta <- c(1,1) model1 <- gmmModel(y~x1, ~z1+z2, data=simData) G <- evalDMoment(model1, theta) ## A nonlinearGmm g <- y~beta0+x1^beta1 h <- ~z1+z2 model2 <- gmmModel(g, h, c(beta0=1, beta1=2), data=simData) G <- evalDMoment(model2, c(beta0=1, beta1=2)) ## A functionGmm 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) } X <- rnorm(200) model3 <- gmmModel(fct, X, theta0=c(beta0=1, beta1=2), grad=dfct) G <- evalDMoment(model3, c(beta0=1, beta1=2))