2014-02-27 03:45:46 +00:00
|
|
|
# Objective function for the GMM method
|
|
|
|
#
|
|
|
|
# Author: Francois Pelletier
|
|
|
|
#
|
|
|
|
# LGPL-3.0
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
#' Objective function for the GMM method
|
2014-03-03 01:20:34 +00:00
|
|
|
#' @param param.lagrangian Vector of parameters and Lagrangian to optimize
|
2014-02-27 03:45:46 +00:00
|
|
|
#' @param conditions.vector Vector of moment conditions
|
2014-03-03 01:20:34 +00:00
|
|
|
#' @param sample Individual data sample
|
|
|
|
#' @param ... Functions of the vector of moment conditions
|
2014-02-27 03:45:46 +00:00
|
|
|
#' @param W Weighting matrix
|
2014-02-28 04:05:30 +00:00
|
|
|
#' @param R Linear constraint matrix of coefficients
|
|
|
|
#' @param r Linear constraint constants
|
2014-02-27 03:45:46 +00:00
|
|
|
#' @return A scalar value
|
2014-03-06 02:48:37 +00:00
|
|
|
#' @export objective.GMM
|
2014-02-27 03:45:46 +00:00
|
|
|
#' @author François Pelletier
|
2014-03-03 01:20:34 +00:00
|
|
|
objective.GMM <- function(param.lagrangian,conditions.vector,sample,...,
|
2014-02-28 04:05:30 +00:00
|
|
|
W=diag(length(conditions.vector)),R=0,r=0)
|
2014-02-27 03:45:46 +00:00
|
|
|
{
|
2014-02-28 04:05:30 +00:00
|
|
|
param <- param.lagrangian[1:num.param]
|
|
|
|
lagrangian <- param.lagrangian[num.param+1:length(param.lagrangian)]
|
2014-03-03 01:20:34 +00:00
|
|
|
colMeans(conditions.vector(param,sample,...)) %*% ginv(W) %*% colMeans(conditions.vector(param,sample,...))+ abs(t(R %*% param - r) %*% lagrangian)
|
2014-02-27 03:45:46 +00:00
|
|
|
}
|