corrections GMM pour paramètres de la fonction optim
This commit is contained in:
parent
3aecd56cc4
commit
5f356f6383
6 changed files with 17 additions and 17 deletions
|
@ -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)
|
||||
}
|
|
@ -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))<epsilon)
|
||||
return(list(par=theta2,cov=S))
|
||||
else if (i>max.iter)
|
||||
|
|
|
@ -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,...)
|
||||
}
|
|
@ -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}
|
||||
}
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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}
|
||||
|
||||
|
|
Loading…
Reference in a new issue