2014-03-04 03:18:26 +00:00
|
|
|
# Iterative GMM method
|
2014-03-03 01:20:34 +00:00
|
|
|
#
|
2014-03-04 03:18:26 +00:00
|
|
|
# Author: Francois Pelletier
|
|
|
|
#
|
|
|
|
# LGPL-3.0
|
2014-03-03 01:20:34 +00:00
|
|
|
###############################################################################
|
|
|
|
|
2014-03-04 03:18:26 +00:00
|
|
|
#' Iterative GMM method
|
|
|
|
#'
|
2014-03-08 05:57:43 +00:00
|
|
|
#' @param start.value Starting values for the parameters and lagrangian
|
2014-03-03 01:20:34 +00:00
|
|
|
#' @param conditions.vector Vector of moment conditions
|
2014-03-08 05:37:30 +00:00
|
|
|
#' @param data Individual data sample
|
2014-03-03 01:20:34 +00:00
|
|
|
#' @param W Weighting matrix
|
2014-03-08 05:41:05 +00:00
|
|
|
#' @param ... Functions of the vector of moment conditions
|
2014-03-03 01:20:34 +00:00
|
|
|
#' @param max.iter Maximum number of iterations
|
|
|
|
#' @param epsilon Minimum precision level
|
|
|
|
#' @return A list containing the optimized vector of parameter and corresponding covariance matrix
|
2014-03-06 02:48:37 +00:00
|
|
|
#' @export iterative.GMM
|
2014-03-03 01:20:34 +00:00
|
|
|
#' @author François Pelletier
|
2014-03-08 05:57:43 +00:00
|
|
|
iterative.GMM <- function(start.value,conditions.vector,data,W,...,max.iter=50,epsilon=1E-6)
|
2014-03-03 01:20:34 +00:00
|
|
|
{
|
2014-03-08 05:57:43 +00:00
|
|
|
theta1 <- optim.GMM(start.value,conditions.vector=conditions.vector,data=data,W=W,...)$par
|
2014-03-03 01:20:34 +00:00
|
|
|
i <- 1
|
|
|
|
repeat
|
|
|
|
{
|
2014-03-08 05:57:43 +00:00
|
|
|
theta2 <- optim.GMM(theta1,conditions.vector,data,W,...)$par
|
2014-03-29 15:02:43 +00:00
|
|
|
S <- covariance.GMM(theta2,conditions.vector,data,...)
|
2014-03-03 01:20:34 +00:00
|
|
|
if(sqrt(sum((theta1-theta2)^2))<epsilon)
|
|
|
|
return(list(par=theta2,cov=S))
|
|
|
|
else if (i>max.iter)
|
|
|
|
stop("Iterative GMM does not converge")
|
|
|
|
else
|
|
|
|
{
|
|
|
|
theta1 <- theta2
|
|
|
|
i <- i+1
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|