Ajout de quelques fonctions

This commit is contained in:
François Pelletier 2014-02-26 22:45:46 -05:00
parent a09ae379c5
commit 0677c1078e
14 changed files with 217 additions and 0 deletions

6
.Rbuildignore Normal file
View file

@ -0,0 +1,6 @@
^.*\.Rproj$
^\.Rproj\.user$
.gitignore
.project
.git
.settings

1
.gitignore vendored
View file

@ -3,3 +3,4 @@
# Example code in package build process
*-Ex.R
.Rproj.user

19
.project Normal file
View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>GMMStuff</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>de.walware.statet.r.builders.RSupport</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>de.walware.statet.base.StatetNature</nature>
<nature>de.walware.statet.r.RNature</nature>
<nature>de.walware.statet.r.RPkgNature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,2 @@
RProjectBuild/Package.name=GMMStuff
eclipse.preferences.version=1

9
DESCRIPTION Normal file
View file

@ -0,0 +1,9 @@
Package: GMMStuff
Title: GMM Stuff
Version: 0.1
Date: 2014-02-11
Author: Francois Pelletier
Maintainer: Francois Pelletier <francois@francoispelletier.org>
Description: This is a package gathering different functions to work with
GMM
License: LGPL-3

0
NAMESPACE Normal file
View file

18
R/covariance.GMM.R Normal file
View 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
}

View 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))
}

View 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
View 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(...))
}

View file

@ -0,0 +1,29 @@
\name{fourmoments.gmm.vector}
\alias{fourmoments.gmm.vector}
\title{GMM vector for 4 first central moments conditions}
\usage{
fourmoments.gmm.vector(param, sample, meanf, variancef, skewnessf, kurtosisf)
}
\arguments{
\item{param}{Estimated parameters}
\item{sample}{Data Sample}
\item{meanf}{Mean function}
\item{variancef}{Variance function}
\item{skewnessf}{Skewness function}
\item{kurtosisf}{Kurtosis function}
}
\value{
A four column matrix of differences
}
\description{
GMM vector for 4 first central moments conditions
}
\author{
François Pelletier
}

23
man/gmmGAL.mu.vcov.Rd Normal file
View file

@ -0,0 +1,23 @@
\name{gmmGAL.mu.vcov}
\alias{gmmGAL.mu.vcov}
\title{Estimated covariance matrix}
\usage{
gmmGAL.mu.vcov(conditions.vector, n, ...)
}
\arguments{
\item{conditions.vector}{Vector of moment conditions}
\item{n}{Sample size}
\item{...}{Parameters of the vector of moment conditions}
}
\value{
A square covariance matrix
}
\description{
Estimated covariance matrix
}
\author{
François Pelletier
}

View file

@ -0,0 +1,25 @@
\name{mean.variance.gmm.vector}
\alias{mean.variance.gmm.vector}
\title{GMM vector for mean and variance moment conditions}
\usage{
\method{mean}{variance.gmm.vector}(param, sample, meanf, variancef)
}
\arguments{
\item{param}{Estimated parameters}
\item{sample}{Data Sample}
\item{meanf}{Mean function}
\item{variancef}{Variance function}
}
\value{
A two column matrix of differences
}
\description{
GMM vector for mean and variance moment conditions
}
\author{
François Pelletier
}

23
man/obj.gmmGAL.mu.Rd Normal file
View file

@ -0,0 +1,23 @@
\name{obj.gmmGAL.mu}
\alias{obj.gmmGAL.mu}
\title{Objective function for the GMM method}
\usage{
obj.gmmGAL.mu(conditions.vector, ..., W = diag(length(conditions.vector)))
}
\arguments{
\item{conditions.vector}{Vector of moment conditions}
\item{...}{Parameters of the vector of moment conditions}
\item{W}{Weighting matrix}
}
\value{
A scalar value
}
\description{
Objective function for the GMM method
}
\author{
François Pelletier
}