Correction iterative GMM
This commit is contained in:
parent
445e334b28
commit
3aecd56cc4
8 changed files with 17 additions and 26 deletions
|
@ -10,23 +10,20 @@
|
|||
#' @param start Starting values for the parameters and lagrangian
|
||||
#' @param conditions.vector Vector of moment conditions
|
||||
#' @param data Individual data sample
|
||||
#' @param ... Functions of the vector of moment conditions
|
||||
#' @param W Weighting matrix
|
||||
#' @param R Linear constraint matrix of coefficients
|
||||
#' @param r Linear constraint constants
|
||||
#' @param ... Functions of the vector of moment conditions
|
||||
#' @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
|
||||
#' @export iterative.GMM
|
||||
#' @author François Pelletier
|
||||
iterative.GMM <- function(start,conditions.vector,data,...,
|
||||
W=diag(length(conditions.vector)),R=0,r=0,lagrangian.start=rep(0,length(conditions.vector)),max.iter=50,epsilon=1E-6)
|
||||
iterative.GMM <- function(start,conditions.vector,data,W,...,max.iter=50,epsilon=1E-6)
|
||||
{
|
||||
theta1 <- optim.GMM(start,conditions.vector,data,...,W,R,r,lagrangian.start)
|
||||
theta1 <- optim.GMM(start,conditions.vector,data,W,...)
|
||||
i <- 1
|
||||
repeat
|
||||
{
|
||||
theta2 <- optim.GMM(theta1,conditions.vector,data,...,W,R,r,lagrangian.start)
|
||||
theta2 <- optim.GMM(theta1,conditions.vector,data,W,...)
|
||||
S <- covariance.GMM(conditions.vector,param,data,...)
|
||||
if(sqrt(sum((theta1-theta2)^2))<epsilon)
|
||||
return(list(par=theta2,cov=S))
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
|
||||
#' GMM vector for mean and variance moment conditions
|
||||
#' @param param Estimated parameters
|
||||
#' @param X Data Sample
|
||||
#' @param data Data Sample
|
||||
#' @param meanf Mean function
|
||||
#' @param variancef Variance function
|
||||
#' @return A two column matrix of differences
|
||||
#' @export meanvariance.gmm.vector
|
||||
#' @author François Pelletier
|
||||
meanvariance.gmm.vector <- function(param,X,meanf,variancef)
|
||||
meanvariance.gmm.vector <- function(param,data,meanf,variancef)
|
||||
{
|
||||
cbind(X-meanf(param),(X-meanf(param))^2 - variancef(param))
|
||||
cbind(data-meanf(param),(data-meanf(param))^2 - variancef(param))
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
#' @param param Vector of parameters
|
||||
#' @param conditions.vector Vector of moment conditions
|
||||
#' @param data Individual data sample
|
||||
#' @param ... Functions of the vector of moment conditions
|
||||
#' @param W Weighting matrix
|
||||
#' @param ... Functions of the vector of moment conditions
|
||||
#' @return A scalar value
|
||||
#' @export objective.GMM
|
||||
#' @author François Pelletier
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#' @param start Starting values for the parameters
|
||||
#' @param conditions.vector Vector of moment conditions
|
||||
#' @param data Individual data sample
|
||||
#' @param ... Functions of the vector of moment conditions
|
||||
#' @param W Weighting matrix
|
||||
#' @param ... Functions of the vector of moment conditions
|
||||
#' @return a list with optimization results
|
||||
#' @export optim.GMM
|
||||
#' @author François Pelletier
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
\alias{iterative.GMM}
|
||||
\title{Iterative GMM method}
|
||||
\usage{
|
||||
iterative.GMM(start, conditions.vector, data, ...,
|
||||
W = diag(length(conditions.vector)), R = 0, r = 0,
|
||||
lagrangian.start = rep(0, length(conditions.vector)), max.iter = 50,
|
||||
iterative.GMM(start, conditions.vector, data, W, ..., max.iter = 50,
|
||||
epsilon = 1e-06)
|
||||
}
|
||||
\arguments{
|
||||
|
@ -15,13 +13,9 @@ iterative.GMM(start, conditions.vector, data, ...,
|
|||
|
||||
\item{data}{Individual data sample}
|
||||
|
||||
\item{...}{Functions of the vector of moment conditions}
|
||||
|
||||
\item{W}{Weighting matrix}
|
||||
|
||||
\item{R}{Linear constraint matrix of coefficients}
|
||||
|
||||
\item{r}{Linear constraint constants}
|
||||
\item{...}{Functions of the vector of moment conditions}
|
||||
|
||||
\item{max.iter}{Maximum number of iterations}
|
||||
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
\alias{meanvariance.gmm.vector}
|
||||
\title{GMM vector for mean and variance moment conditions}
|
||||
\usage{
|
||||
meanvariance.gmm.vector(param, X, meanf, variancef)
|
||||
meanvariance.gmm.vector(param, data, meanf, variancef)
|
||||
}
|
||||
\arguments{
|
||||
\item{param}{Estimated parameters}
|
||||
|
||||
\item{X}{Data Sample}
|
||||
\item{data}{Data Sample}
|
||||
|
||||
\item{meanf}{Mean function}
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ objective.GMM(param, conditions.vector, data, W, ...)
|
|||
|
||||
\item{data}{Individual data sample}
|
||||
|
||||
\item{...}{Functions of the vector of moment conditions}
|
||||
|
||||
\item{W}{Weighting matrix}
|
||||
|
||||
\item{...}{Functions of the vector of moment conditions}
|
||||
}
|
||||
\value{
|
||||
A scalar value
|
||||
|
|
|
@ -11,9 +11,9 @@ optim.GMM(start, conditions.vector, data, W, ...)
|
|||
|
||||
\item{data}{Individual data sample}
|
||||
|
||||
\item{...}{Functions of the vector of moment conditions}
|
||||
|
||||
\item{W}{Weighting matrix}
|
||||
|
||||
\item{...}{Functions of the vector of moment conditions}
|
||||
}
|
||||
\value{
|
||||
a list with optimization results
|
||||
|
|
Loading…
Reference in a new issue