From 01505a567bd989de95e0eb17a55c932f8a1a5f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pelletier?= Date: Wed, 19 Feb 2014 21:49:11 -0500 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20fonctions=20pour=20les=20quantit?= =?UTF-8?q?=C3=A9s=20empiriques?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- R/emk.R | 20 ++++++++++++++++++++ R/empCF.R | 17 +++++++++++++++++ R/empCGF.R | 17 +++++++++++++++++ R/empMGF.R | 17 +++++++++++++++++ man/emk.Rd | 22 ++++++++++++++++++++++ man/empCF.Rd | 21 +++++++++++++++++++++ man/empCGF.Rd | 21 +++++++++++++++++++++ man/empMGF.Rd | 21 +++++++++++++++++++++ 8 files changed, 156 insertions(+) create mode 100644 R/emk.R create mode 100644 R/empCF.R create mode 100644 R/empCGF.R create mode 100644 R/empMGF.R create mode 100644 man/emk.Rd create mode 100644 man/empCF.Rd create mode 100644 man/empCGF.Rd create mode 100644 man/empMGF.Rd diff --git a/R/emk.R b/R/emk.R new file mode 100644 index 0000000..97c174b --- /dev/null +++ b/R/emk.R @@ -0,0 +1,20 @@ +# Empirical cumulants for individual data +# +# Author: François Pelletier +############################################################################### + + +#' Empirical cumulants for individual data +#' @param DATA a vector of individual data +#' @param order order of the cumulant. Must be between 1 and 4. +#' @return A vector of cumulants +#' @author François Pelletier +emk <- function(DATA,order=1:4) +{ + library(actuar) + m <- emm(DATA,1:4) + c(m[1], + m[2]-m[1]^2, + m[3]-3*m[1]*m[2]+2*m[1]^2, + m[4]-3*m[2]^2-4*m[1]*m[3]+12*m[1]^2*m[2]-6*m[1]^4)[order] +} diff --git a/R/empCF.R b/R/empCF.R new file mode 100644 index 0000000..7cad2ec --- /dev/null +++ b/R/empCF.R @@ -0,0 +1,17 @@ +# Empirical Characteristic function +# +# Author: François Pelletier +############################################################################### + + +#' Empirical Characteristic function +#' +#' Evaluate the empirical CF from a data sample +#' @param t Vector of transform variates +#' @param DATA Vector of individual data +#' @return A vector of CF values +#' @author François Pelletier +empCF <- function(t,DATA) +{ + colMeans(outer(DATA,t,function(x,y) exp(1i*x*y))) +} diff --git a/R/empCGF.R b/R/empCGF.R new file mode 100644 index 0000000..c9753f3 --- /dev/null +++ b/R/empCGF.R @@ -0,0 +1,17 @@ +# Empirical Cumulant Generating function +# +# Author: François Pelletier +############################################################################### + + +#' Empirical Coment Generating function +#' +#' Evaluate the empirical CGF from a data sample +#' @param t Vector of transform variates +#' @param DATA Vector of individual data +#' @return A vector of CGF values +#' @author François Pelletier +empCGF <- function(t,DATA) +{ + log(colMeans(outer(DATA,t,function(x,y) exp(x*y)))) +} diff --git a/R/empMGF.R b/R/empMGF.R new file mode 100644 index 0000000..63e5e71 --- /dev/null +++ b/R/empMGF.R @@ -0,0 +1,17 @@ +# Empirical Moment Generating function +# +# Author: François Pelletier +############################################################################### + + +#' Empirical Moment Generating function +#' +#' Evaluate the empirical MGF from a data sample +#' @param t Vector of transform variates +#' @param DATA Vector of individual data +#' @return A vector of MGF values +#' @author François Pelletier +empMGF <- function(t,DATA) +{ + colMeans(outer(DATA,t,function(x,y) exp(x*y))) +} diff --git a/man/emk.Rd b/man/emk.Rd new file mode 100644 index 0000000..7240173 --- /dev/null +++ b/man/emk.Rd @@ -0,0 +1,22 @@ +\name{emk} +\alias{emk} +\title{Empirical cumulants for individual data} +\usage{ +emk(DATA, order = 1:4) +} +\arguments{ + \item{DATA}{a vector of individual data} + + \item{order}{order of the cumulant. Must be between 1 and + 4.} +} +\value{ +A vector of cumulants +} +\description{ +Empirical cumulants for individual data +} +\author{ +François Pelletier +} + diff --git a/man/empCF.Rd b/man/empCF.Rd new file mode 100644 index 0000000..00e16ff --- /dev/null +++ b/man/empCF.Rd @@ -0,0 +1,21 @@ +\name{empCF} +\alias{empCF} +\title{Empirical Characteristic function} +\usage{ +empCF(t, DATA) +} +\arguments{ + \item{t}{Vector of transform variates} + + \item{DATA}{Vector of individual data} +} +\value{ +A vector of CF values +} +\description{ +Evaluate the empirical CF from a data sample +} +\author{ +François Pelletier +} + diff --git a/man/empCGF.Rd b/man/empCGF.Rd new file mode 100644 index 0000000..0737410 --- /dev/null +++ b/man/empCGF.Rd @@ -0,0 +1,21 @@ +\name{empCGF} +\alias{empCGF} +\title{Empirical Coment Generating function} +\usage{ +empCGF(t, DATA) +} +\arguments{ + \item{t}{Vector of transform variates} + + \item{DATA}{Vector of individual data} +} +\value{ +A vector of CGF values +} +\description{ +Evaluate the empirical CGF from a data sample +} +\author{ +François Pelletier +} + diff --git a/man/empMGF.Rd b/man/empMGF.Rd new file mode 100644 index 0000000..7f571d5 --- /dev/null +++ b/man/empMGF.Rd @@ -0,0 +1,21 @@ +\name{empMGF} +\alias{empMGF} +\title{Empirical Moment Generating function} +\usage{ +empMGF(t, DATA) +} +\arguments{ + \item{t}{Vector of transform variates} + + \item{DATA}{Vector of individual data} +} +\value{ +A vector of MGF values +} +\description{ +Evaluate the empirical MGF from a data sample +} +\author{ +François Pelletier +} +