Ajout de quelques fonctions
This commit is contained in:
parent
a09ae379c5
commit
0677c1078e
14 changed files with 217 additions and 0 deletions
18
R/covariance.GMM.R
Normal file
18
R/covariance.GMM.R
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Estimated covariance matrix
|
||||
#
|
||||
# Author: Francois Pelletier
|
||||
#
|
||||
# LGPL-3.0
|
||||
###############################################################################
|
||||
|
||||
#' Estimated covariance matrix
|
||||
#' @param conditions.vector Vector of moment conditions
|
||||
#' @param n Sample size
|
||||
#' @param ... Parameters of the vector of moment conditions
|
||||
#' @return A square covariance matrix
|
||||
#'
|
||||
#' @author François Pelletier
|
||||
gmmGAL.mu.vcov <- function(conditions.vector,n,...)
|
||||
{
|
||||
t(conditions.vector(...)) %*% conditions.vector(...) / n
|
||||
}
|
24
R/fourmoments.gmm.vector.R
Normal file
24
R/fourmoments.gmm.vector.R
Normal file
|
@ -0,0 +1,24 @@
|
|||
# GMM vector for 4 first central moments conditions
|
||||
#
|
||||
# Author: Francois Pelletier
|
||||
#
|
||||
# LGPL-3.0
|
||||
###############################################################################
|
||||
|
||||
#' GMM vector for 4 first central moments conditions
|
||||
#' @param param Estimated parameters
|
||||
#' @param sample Data Sample
|
||||
#' @param meanf Mean function
|
||||
#' @param variancef Variance function
|
||||
#' @param skewnessf Skewness function
|
||||
#' @param kurtosisf Kurtosis function
|
||||
#' @return A four column matrix of differences
|
||||
#'
|
||||
#' @author François Pelletier
|
||||
fourmoments.gmm.vector <- function(param,sample,meanf,variancef,skewnessf,kurtosisf)
|
||||
{
|
||||
cbind(X-meanf(param),
|
||||
(X-meanf(param))^2 - variancef(param),
|
||||
(X-meanf(param))^3/variancef(param)^(3/2) - skewnessf(param),
|
||||
(X-meanf(param))^4/variancef(param)^(2) - kurtosisf(param))
|
||||
}
|
20
R/mean.variance.gmm.vector.R
Normal file
20
R/mean.variance.gmm.vector.R
Normal file
|
@ -0,0 +1,20 @@
|
|||
# GMM vector for mean and variance moment conditions
|
||||
#
|
||||
# Author: Francois Pelletier
|
||||
#
|
||||
# LGPL-3.0
|
||||
###############################################################################
|
||||
|
||||
|
||||
#' GMM vector for mean and variance moment conditions
|
||||
#' @param param Estimated parameters
|
||||
#' @param sample Data Sample
|
||||
#' @param meanf Mean function
|
||||
#' @param variancef Variance function
|
||||
#' @return A two column matrix of differences
|
||||
#'
|
||||
#' @author François Pelletier
|
||||
mean.variance.gmm.vector <- function(param,sample,meanf,variancef)
|
||||
{
|
||||
cbind(X-meanf(param),(X-meanf(param))^2 - variancef(param))
|
||||
}
|
18
R/objective.GMM.R
Normal file
18
R/objective.GMM.R
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Objective function for the GMM method
|
||||
#
|
||||
# Author: Francois Pelletier
|
||||
#
|
||||
# LGPL-3.0
|
||||
###############################################################################
|
||||
|
||||
#' Objective function for the GMM method
|
||||
#' @param conditions.vector Vector of moment conditions
|
||||
#' @param ... Parameters of the vector of moment conditions
|
||||
#' @param W Weighting matrix
|
||||
#' @return A scalar value
|
||||
#'
|
||||
#' @author François Pelletier
|
||||
obj.gmmGAL.mu <- function(conditions.vector,...,W=diag(length(conditions.vector)))
|
||||
{
|
||||
colMeans(conditions.vector(...)) %*% ginv(W) %*% colMeans(conditions.vector(...))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue