diff --git a/R/covariance.GMM.R b/R/covariance.GMM.R index 6c5b67a..e0cf340 100644 --- a/R/covariance.GMM.R +++ b/R/covariance.GMM.R @@ -8,12 +8,12 @@ #' Estimated covariance matrix #' @param conditions.vector Vector of moment conditions #' @param param Vector of estimated parameters -#' @param sample Individual data sample +#' @param data Individual data sample #' @param ... Functions of the vector of moment conditions #' @return A square covariance matrix #' @export covariance.GMM #' @author François Pelletier -covariance.GMM <- function(conditions.vector,param,sample...) +covariance.GMM <- function(conditions.vector,param,data,...) { - t(conditions.vector(param,sample,...)) %*% conditions.vector(param,sample,...) / length(sample) + t(conditions.vector(param,data,...)) %*% conditions.vector(param,data,...) / length(data) } \ No newline at end of file diff --git a/R/iterative.GMM.R b/R/iterative.GMM.R index 8774529..63dc27b 100644 --- a/R/iterative.GMM.R +++ b/R/iterative.GMM.R @@ -7,7 +7,7 @@ #' Iterative GMM method #' -#' @param start Starting values for the parameters and lagrangian +#' @param start.value Starting values for the parameters and lagrangian #' @param conditions.vector Vector of moment conditions #' @param data Individual data sample #' @param W Weighting matrix @@ -17,14 +17,14 @@ #' @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,...,max.iter=50,epsilon=1E-6) +iterative.GMM <- function(start.value,conditions.vector,data,W,...,max.iter=50,epsilon=1E-6) { - theta1 <- optim.GMM(start,conditions.vector,data,W,...) + theta1 <- optim.GMM(start.value,conditions.vector=conditions.vector,data=data,W=W,...)$par i <- 1 repeat { - theta2 <- optim.GMM(theta1,conditions.vector,data,W,...) - S <- covariance.GMM(conditions.vector,param,data,...) + theta2 <- optim.GMM(theta1,conditions.vector,data,W,...)$par + S <- covariance.GMM(conditions.vector,theta2,data,...) if(sqrt(sum((theta1-theta2)^2))max.iter) diff --git a/R/optim.GMM.R b/R/optim.GMM.R index af8c28a..4a03b35 100644 --- a/R/optim.GMM.R +++ b/R/optim.GMM.R @@ -7,7 +7,7 @@ #' Optimization for GMM method #' -#' @param start Starting values for the parameters +#' @param start.value Starting values for the parameters #' @param conditions.vector Vector of moment conditions #' @param data Individual data sample #' @param W Weighting matrix @@ -15,7 +15,7 @@ #' @return a list with optimization results #' @export optim.GMM #' @author François Pelletier -optim.GMM <- function(start,conditions.vector,data,W,...) +optim.GMM <- function(start.value,conditions.vector,data,W,...) { - optim(start,objective.GMM,conditions.vector,data,W,...) + optim(start.value,objective.GMM,gr=NULL,conditions.vector,data,W,...) } \ No newline at end of file diff --git a/man/covariance.GMM.Rd b/man/covariance.GMM.Rd index 9b0e6dd..38da47d 100644 --- a/man/covariance.GMM.Rd +++ b/man/covariance.GMM.Rd @@ -2,14 +2,14 @@ \alias{covariance.GMM} \title{Estimated covariance matrix} \usage{ -covariance.GMM(conditions.vector, param, sample...) +covariance.GMM(conditions.vector, param, data, ...) } \arguments{ \item{conditions.vector}{Vector of moment conditions} \item{param}{Vector of estimated parameters} - \item{sample}{Individual data sample} + \item{data}{Individual data sample} \item{...}{Functions of the vector of moment conditions} } diff --git a/man/iterative.GMM.Rd b/man/iterative.GMM.Rd index 106facb..71e6a39 100644 --- a/man/iterative.GMM.Rd +++ b/man/iterative.GMM.Rd @@ -2,11 +2,11 @@ \alias{iterative.GMM} \title{Iterative GMM method} \usage{ -iterative.GMM(start, conditions.vector, data, W, ..., max.iter = 50, +iterative.GMM(start.value, conditions.vector, data, W, ..., max.iter = 50, epsilon = 1e-06) } \arguments{ - \item{start}{Starting values for the parameters and + \item{start.value}{Starting values for the parameters and lagrangian} \item{conditions.vector}{Vector of moment conditions} diff --git a/man/optim.GMM.Rd b/man/optim.GMM.Rd index dd5ddbf..55a46b8 100644 --- a/man/optim.GMM.Rd +++ b/man/optim.GMM.Rd @@ -2,10 +2,10 @@ \alias{optim.GMM} \title{Optimization for GMM method} \usage{ -optim.GMM(start, conditions.vector, data, W, ...) +optim.GMM(start.value, conditions.vector, data, W, ...) } \arguments{ - \item{start}{Starting values for the parameters} + \item{start.value}{Starting values for the parameters} \item{conditions.vector}{Vector of moment conditions}