\documentclass[letter]{report}
\usepackage[margin=0.5in]{geometry}
\usepackage{Sweave}
\usepackage{graphicx}
\usepackage[francais]{babel} 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage{amsmath} 
\usepackage{amsfonts}
\usepackage{verbatim} 
\usepackage{float} 
\usepackage{hyperref}
\usepackage{scrtime}

\begin{document}
\input{GAL-Buckle95-concordance}

\title{GAL Buckle 95}
\author{François Pelletier}
\maketitle
\tableofcontents

\chapter{Initialisation}

\section{Chargement des paquets}
\begin{Schunk}
\begin{Sinput}
> library(actuar)
> library(MASS)
> library(xtable)
> library(moments)
> library(FourierStuff)
> library(GeneralizedAsymmetricLaplace)
> library(GMMStuff)
> library(OptionPricingStuff)
> library(QuadraticEstimatingEquations)
> library(parallel)
\end{Sinput}
\end{Schunk}

\section{Constantes et données}

\begin{Schunk}
\begin{Sinput}
> #Nombre de décimales affichées
> options(digits=6)
> #Marge pour intervalles de confiance
> alpha.confint <- 0.05 
> #Marge pour test d'hypothèses
> alpha.test <- 0.05
> #Chargement des données
> RETURNS <- head(read.csv("abbeyn.csv",sep="\t",header=TRUE)[,1],-1)
> #Taille de l'échantillon
> n <- length(RETURNS)
> #Nom de l'échantillon
> strData <- "Buckle95"
\end{Sinput}
\end{Schunk}

\section{Test de normalité}

\begin{Schunk}
\begin{Sinput}
> EppsPulley.test(RETURNS)
\end{Sinput}
\begin{Soutput}
Epps-Pulley Normality test

 T: 0.626033
 T*: 0.635568
p-value: 0.007178

$Tstat
[1] 0.626033

$Tmod
[1] 0.635568

$Zscore
[1] 2.44824

$Pvalue
[1] 0.00717788

$Reject
[1] TRUE
\end{Soutput}
\end{Schunk}

\chapter{Estimation}

\section{Données mises à l'échelle}

\begin{Schunk}
\begin{Sinput}
> sRET <- as.vector(scale(RETURNS))
\end{Sinput}
\end{Schunk}

\section{Première estimation par QEE}

\begin{Schunk}
\begin{Sinput}
> ## Point de départ	
> pt.depart <- startparamGAL(sRET)
> ## Fonctions pour les moments
> meanQEE <- function(param) mGAL(param,1)
> varianceQEE <- function(param) cmGAL(param,2)
> sdQEE <- function(param) sqrt(cmGAL(param,2))
> skewnessQEE <- function(param) cmGAL(param,3)
> kurtosisQEE <- function(param) cmGAL(param,4)
> ## Fonctions pour les dérivées
> dmeanQEE <- function(param) dmGAL(param,1)
> dsdQEE <- function(param) dmGAL(param,2)
> ## Estimation gaussienne
> optim1 <- optim(pt.depart,obj.gauss,gr=NULL,sRET,
+ 		meanQEE,varianceQEE,dmeanQEE,dsdQEE)
> pt.optim1 <- optim1$par
> ## Estimation de crowder
> optim2 <- optim(pt.depart,obj.Crowder,gr=NULL,sRET,
+ 		meanQEE,varianceQEE,skewnessQEE,kurtosisQEE,dmeanQEE,dsdQEE)
> pt.optim2 <- optim2$par
> ## Estimation de crowder modifiée
> optim3 <- optim(pt.depart,obj.Crowder.Mod,gr=NULL,sRET,
+ 		meanQEE,varianceQEE,dmeanQEE,dsdQEE)
> pt.optim3 <- optim3$par
\end{Sinput}
\end{Schunk}

\section{Résultats de la première estimation par QEE}

\begin{Schunk}
\begin{Sinput}
> cov.optim1 <- covariance.QEE(M.gauss(pt.optim1,sRET,
+ 				meanQEE,varianceQEE,dmeanQEE,dsdQEE),
+ 		V.gauss(pt.optim1,sRET,meanQEE,varianceQEE,
+ 				skewnessQEE,kurtosisQEE,dmeanQEE,dsdQEE),n)
> cov.optim2 <- covariance.QEE(M.Crowder(pt.optim2,sRET,
+ 				varianceQEE,skewnessQEE,kurtosisQEE,dmeanQEE,dsdQEE),
+ 		V.Crowder(pt.optim2,sRET,varianceQEE,
+ 				skewnessQEE,kurtosisQEE,dmeanQEE,dsdQEE),n)
> cov.optim3 <- covariance.QEE(M.Crowder.Mod(pt.optim3,sRET,
+ 				varianceQEE,skewnessQEE,kurtosisQEE,dmeanQEE,dsdQEE),
+ 		V.Crowder.Mod(pt.optim3,sRET,varianceQEE,dmeanQEE,dsdQEE),n)
> confidence.interval.QEE(pt.optim1,cov.optim1,n)
\end{Sinput}
\begin{Soutput}
         LOWER  ESTIMATE     UPPER
[1,] -0.780018 -0.726048 -0.672077
[2,]  0.436002  0.596316  0.756630
[3,]  0.262650  0.359186  0.455722
[4,]  1.994757  2.021370  2.047982
\end{Soutput}
\begin{Sinput}
> confidence.interval.QEE(pt.optim2,cov.optim2,n)
\end{Sinput}
\begin{Soutput}
         LOWER  ESTIMATE     UPPER
[1,] -0.694457 -0.627404 -0.560351
[2,]  0.413764  0.640292  0.866820
[3,]  0.232650  0.334028  0.435405
[4,]  1.839966  1.878296  1.916626
\end{Soutput}
\begin{Sinput}
> confidence.interval.QEE(pt.optim3,cov.optim3,n)
\end{Sinput}
\begin{Soutput}
         LOWER  ESTIMATE     UPPER
[1,] -0.765288 -0.711439 -0.657589
[2,]  0.455485  0.606642  0.757798
[3,]  0.264669  0.362932  0.461195
[4,]  1.932691  1.960299  1.987906
\end{Soutput}
\end{Schunk}

\section{Seconde estimation par QEE}

\begin{Schunk}
\begin{Sinput}
> ## Estimation gaussienne
> optim4 <- optim(pt.optim1,obj.gauss,gr=NULL,sRET,
+ 		meanQEE,varianceQEE,dmeanQEE,dsdQEE,
+ 		ginv(V.gauss(pt.optim1,sRET,meanQEE,
+ 						varianceQEE,skewnessQEE,kurtosisQEE,
+ 						dmeanQEE,dsdQEE)))
> pt.optim4 <- optim4$par
> ## Estimation de crowder
> optim5 <- optim(pt.optim2,obj.Crowder,gr=NULL,sRET,
+ 		meanQEE,varianceQEE,skewnessQEE,kurtosisQEE,dmeanQEE,dsdQEE,
+ 		ginv(V.Crowder(pt.optim2,sRET,varianceQEE,skewnessQEE,
+ 						kurtosisQEE,dmeanQEE,dsdQEE)))
> pt.optim5 <- optim5$par
> ## Estimation de crowder modifiée
> optim6 <- optim(pt.optim3,obj.Crowder.Mod,gr=NULL,sRET,
+ 		meanQEE,varianceQEE,dmeanQEE,dsdQEE,
+ 		ginv(V.Crowder.Mod(pt.optim3,sRET,varianceQEE,
+ 						dmeanQEE,dsdQEE)))
> pt.optim6 <- optim6$par
\end{Sinput}
\end{Schunk}

\section{Résultats de la seconde estimation par QEE}

\begin{Schunk}
\begin{Sinput}
> cov.optim4 <- covariance.QEE(M.gauss(pt.optim4,sRET,
+ 				meanQEE,varianceQEE,dmeanQEE,dsdQEE),
+ 		V.gauss(pt.optim4,sRET,meanQEE,varianceQEE,
+ 				skewnessQEE,kurtosisQEE,dmeanQEE,dsdQEE),n)
> cov.optim5 <- covariance.QEE(M.Crowder(pt.optim5,sRET,
+ 				varianceQEE,skewnessQEE,kurtosisQEE,dmeanQEE,dsdQEE),
+ 		V.Crowder(pt.optim5,sRET,varianceQEE,skewnessQEE,
+ 				kurtosisQEE,dmeanQEE,dsdQEE),n)
> cov.optim6 <- covariance.QEE(M.Crowder.Mod(pt.optim6,sRET,
+ 				varianceQEE,skewnessQEE,kurtosisQEE,dmeanQEE,dsdQEE),
+ 		V.Crowder.Mod(pt.optim6,sRET,varianceQEE,dmeanQEE,dsdQEE),n)
> confidence.interval.QEE(pt.optim4,cov.optim4,n)
\end{Sinput}
\begin{Soutput}
         LOWER  ESTIMATE     UPPER
[1,] -0.779792 -0.725853 -0.671914
[2,]  0.436017  0.596319  0.756622
[3,]  0.262456  0.358969  0.455482
[4,]  1.995452  2.022048  2.048644
\end{Soutput}
\begin{Sinput}
> confidence.interval.QEE(pt.optim5,cov.optim5,n)
\end{Sinput}
\begin{Soutput}
         LOWER  ESTIMATE     UPPER
[1,] -0.692712 -0.625874 -0.559036
[2,]  0.414139  0.640445  0.866750
[3,]  0.231568  0.332845  0.434122
[4,]  1.842116  1.880376  1.918636
\end{Soutput}
\begin{Sinput}
> confidence.interval.QEE(pt.optim6,cov.optim6,n)
\end{Sinput}
\begin{Soutput}
         LOWER  ESTIMATE     UPPER
[1,] -0.766288 -0.712450 -0.658612
[2,]  0.455051  0.606193  0.757334
[3,]  0.264972  0.363196  0.461419
[4,]  1.934050  1.961614  1.989178
\end{Soutput}
\end{Schunk}

\section{Estimation par GMM}

\begin{Schunk}
\begin{Sinput}
> ## GMM régulier
> optim7 <- optim.GMM(pt.depart,
+ 		conditions.vector=meanvariance.gmm.vector,
+ 		data=sRET,W=diag(2),
+ 		meanf=meanQEE,variancef=varianceQEE)
> pt.optim7 <- optim7$par
> cov.optim7 <- mean.variance.GMM.gradient.GAL(pt.optim7,sRET) %*% 
+ 		covariance.GMM(pt.optim7,meanvariance.gmm.vector,sRET,
+ 				meanf=meanQEE,variancef=varianceQEE) %*%
+ 		t(mean.variance.GMM.gradient.GAL(pt.optim7,sRET)) / n
> ## GMM itératif
> optim8 <- iterative.GMM(pt.depart,
+ 		conditions.vector=meanvariance.gmm.vector,
+ 		data=sRET,W=diag(2),
+ 		meanf=meanQEE,variancef=varianceQEE)
> pt.optim8 <- optim8$par
> cov.optim8 <-  mean.variance.GMM.gradient.GAL(pt.optim8,sRET) %*% 
+ 		optim8$cov %*%  
+ 		t(mean.variance.GMM.gradient.GAL(pt.optim8,sRET)) / n
> confidence.interval.QEE(pt.optim7,cov.optim7,n)
\end{Sinput}
\begin{Soutput}
         LOWER  ESTIMATE     UPPER
[1,] -0.878702 -0.641646 -0.404589
[2,] -0.469225  0.625908  1.721040
[3,] -0.192234  0.326366  0.844965
[4,]  1.696121  1.965995  2.235869
\end{Soutput}
\begin{Sinput}
> confidence.interval.QEE(pt.optim8,cov.optim8,n)
\end{Sinput}
\begin{Soutput}
         LOWER  ESTIMATE     UPPER
[1,] -0.874031 -0.636980 -0.399929
[2,] -0.473292  0.626346  1.725984
[3,] -0.193600  0.322895  0.839390
[4,]  1.704166  1.972716  2.241265
\end{Soutput}
\end{Schunk}

\chapter{Comparaison des résultats}
\begin{Schunk}
\begin{Sinput}
> # Aggrégation des estimateurs (pour simplifier les calculs)
> pts.estim <- cbind(pt.optim1,pt.optim2,pt.optim3,pt.optim4,
+ 		pt.optim5,pt.optim6,pt.optim7,pt.optim8)
> l.pts.estim <- as.list(data.frame(pts.estim))
\end{Sinput}
\end{Schunk}

\section{Fonction de répartition}
\begin{Schunk}
\begin{Sinput}
> # Points d'évaluation
> xi <- seq(2*min(sRET),2*max(sRET),length.out=2^6)
> # Fonction de répartition par intégration de la fonction caractéristique
> dist1 <- cbind(cftocdf(xi,cfGAL,param=pt.optim1),
+ 		cftocdf(xi,cfGAL,param=pt.optim2),
+ 		cftocdf(xi,cfGAL,param=pt.optim3),
+ 		cftocdf(xi,cfGAL,param=pt.optim4),
+ 		cftocdf(xi,cfGAL,param=pt.optim5),
+ 		cftocdf(xi,cfGAL,param=pt.optim6),
+ 		cftocdf(xi,cfGAL,param=pt.optim7),
+ 		cftocdf(xi,cfGAL,param=pt.optim8))
> # Fonction de répartition par point de selle
> dist2 <- cbind(psaddleapproxGAL(xi,pt.optim1),
+ 		psaddleapproxGAL(xi,pt.optim2),
+ 		psaddleapproxGAL(xi,pt.optim3),
+ 		psaddleapproxGAL(xi,pt.optim4),
+ 		psaddleapproxGAL(xi,pt.optim5),
+ 		psaddleapproxGAL(xi,pt.optim6),
+ 		psaddleapproxGAL(xi,pt.optim7),
+ 		psaddleapproxGAL(xi,pt.optim8))
> # Fonction de répartition par intégration de la fonction de densité
> dist3 <- cbind(pGAL(xi,pt.optim1),
+ 		pGAL(xi,pt.optim2),
+ 		pGAL(xi,pt.optim3),
+ 		pGAL(xi,pt.optim4),
+ 		pGAL(xi,pt.optim5),
+ 		pGAL(xi,pt.optim6),
+ 		pGAL(xi,pt.optim7),
+ 		pGAL(xi,pt.optim8))
\end{Sinput}
\end{Schunk}
\pagebreak
\subsection{Graphiques}

\begin{Schunk}
\begin{Sinput}
> for (i in 1:8)
+ {
+ 	file<-paste(strData,"-repart-",i,".pdf",sep="")
+ 	pdf(file=file,paper="special",width=6,height=6)
+ 	plot.ecdf(sRET,main=paste("Fonction de répartition ",i))
+ 	lines(xi,dist1[,i],col="green")
+ 	lines(xi,dist2[,1],col="red")
+ 	lines(xi,dist3[,1],col="pink")
+ 	lines(xi,pnorm(xi),type="l",col="blue")
+ 	dev.off()
+ 	cat("\\includegraphics[height=4in,width=4in]{",
+ 			file,"}\n",sep="")
+ }
\end{Sinput}
\includegraphics[height=4in,width=4in]{Buckle95-repart-1.pdf}
\includegraphics[height=4in,width=4in]{Buckle95-repart-2.pdf}
\includegraphics[height=4in,width=4in]{Buckle95-repart-3.pdf}
\includegraphics[height=4in,width=4in]{Buckle95-repart-4.pdf}
\includegraphics[height=4in,width=4in]{Buckle95-repart-5.pdf}
\includegraphics[height=4in,width=4in]{Buckle95-repart-6.pdf}
\includegraphics[height=4in,width=4in]{Buckle95-repart-7.pdf}
\includegraphics[height=4in,width=4in]{Buckle95-repart-8.pdf}\end{Schunk}

\subsection{Statistiques}
Test du $\chi^2$, Méthode avec intégration
\begin{Schunk}
\begin{Sinput}
> chisquare.test1 <- function(param,DATA.hist,FUN,method)
+ {
+ 	chisquare.test(DATA.hist,FUN,param,method=method)
+ }
> xtable(do.call(rbind,lapply(l.pts.estim,chisquare.test1,hist(sRET),
+ 						cfGAL,"integral")),digits=6)
\end{Sinput}
% latex table generated in R 3.0.2 by xtable 1.7-4 package
% Mon Oct 13 12:28:07 2014
\begin{table}[ht]
\centering
\begin{tabular}{rrrr}
  \hline
 & chisquare.stat & df & p.value \\ 
  \hline
pt.optim1 & 5.473824 & 6.000000 & 0.484626 \\ 
  pt.optim2 & 5.329673 & 6.000000 & 0.502277 \\ 
  pt.optim3 & 5.388158 & 6.000000 & 0.495076 \\ 
  pt.optim4 & 5.474310 & 6.000000 & 0.484567 \\ 
  pt.optim5 & 5.337004 & 6.000000 & 0.501372 \\ 
  pt.optim6 & 5.390662 & 6.000000 & 0.494769 \\ 
  pt.optim7 & 5.454256 & 6.000000 & 0.487003 \\ 
  pt.optim8 & 5.476963 & 6.000000 & 0.484245 \\ 
   \hline
\end{tabular}
\end{table}\end{Schunk}

Test du $\chi^2$, Méthode avec point de selle
\begin{Schunk}
\begin{Sinput}
> xtable(do.call(rbind,lapply(l.pts.estim,chisquare.test1,hist(sRET),
+ 						pGAL,"saddlepoint")),digits=6)
\end{Sinput}
% latex table generated in R 3.0.2 by xtable 1.7-4 package
% Mon Oct 13 12:28:07 2014
\begin{table}[ht]
\centering
\begin{tabular}{rrrr}
  \hline
 & chisquare.stat & df & p.value \\ 
  \hline
pt.optim1 & 9.293574 & 6.000000 & 0.157728 \\ 
  pt.optim2 & 8.345592 & 6.000000 & 0.213862 \\ 
  pt.optim3 & 9.050625 & 6.000000 & 0.170751 \\ 
  pt.optim4 & 9.292836 & 6.000000 & 0.157767 \\ 
  pt.optim5 & 8.344140 & 6.000000 & 0.213959 \\ 
  pt.optim6 & 9.062381 & 6.000000 & 0.170100 \\ 
  pt.optim7 & 8.616379 & 6.000000 & 0.196330 \\ 
  pt.optim8 & 8.610490 & 6.000000 & 0.196698 \\ 
   \hline
\end{tabular}
\end{table}\end{Schunk}

Statistique de Kolmogorov-Smirnov
\begin{Schunk}
\begin{Sinput}
> ks.test1 <- function(param,x,y) ks.test(x,y,param)
> xtable(do.call(rbind,mclapply(l.pts.estim,ks.test1,sRET,"pGAL")),digits=6)
\end{Sinput}
% latex table generated in R 3.0.2 by xtable 1.7-4 package
% Mon Oct 13 12:28:07 2014
\begin{table}[ht]
\centering
\begin{tabular}{rrrrrr}
  \hline
 & statistic & p.value & alternative & method & data.name \\ 
  \hline
pt.optim1 & 0.158220 & 0.171912 & two-sided & One-sample Kolmogorov-Smirnov test & x \\ 
  pt.optim2 & 0.140346 & 0.289345 & two-sided & One-sample Kolmogorov-Smirnov test & x \\ 
  pt.optim3 & 0.156772 & 0.179751 & two-sided & One-sample Kolmogorov-Smirnov test & x \\ 
  pt.optim4 & 0.158159 & 0.172235 & two-sided & One-sample Kolmogorov-Smirnov test & x \\ 
  pt.optim5 & 0.139916 & 0.292753 & two-sided & One-sample Kolmogorov-Smirnov test & x \\ 
  pt.optim6 & 0.156960 & 0.178718 & two-sided & One-sample Kolmogorov-Smirnov test & x \\ 
  pt.optim7 & 0.141230 & 0.282437 & two-sided & One-sample Kolmogorov-Smirnov test & x \\ 
  pt.optim8 & 0.140016 & 0.291954 & two-sided & One-sample Kolmogorov-Smirnov test & x \\ 
   \hline
\end{tabular}
\end{table}\end{Schunk}

Statistique de distance minimale

\begin{Schunk}
\begin{Sinput}
> tvariate1 <- seq(-.1,.1,by=0.01)
> xtable(do.call(rbind,mclapply(l.pts.estim,
+ 						md.test,sRET,tvariate1,cfGAL,empCF)),digits=6)
\end{Sinput}
% latex table generated in R 3.0.2 by xtable 1.7-4 package
% Mon Oct 13 12:28:07 2014
\begin{table}[ht]
\centering
\begin{tabular}{rrrr}
  \hline
 & md.stat & df & p.value \\ 
  \hline
pt.optim1 & 0.000422 & 21.000000 & 0.000000 \\ 
  pt.optim2 & 0.120174 & 21.000000 & 0.000000 \\ 
  pt.optim3 & 0.001384 & 21.000000 & 0.000000 \\ 
  pt.optim4 & 0.000388 & 21.000000 & 0.000000 \\ 
  pt.optim5 & 0.123295 & 21.000000 & 0.000000 \\ 
  pt.optim6 & 0.001451 & 21.000000 & 0.000000 \\ 
  pt.optim7 & 0.007980 & 21.000000 & 0.000000 \\ 
  pt.optim8 & 0.010416 & 21.000000 & 0.000000 \\ 
   \hline
\end{tabular}
\end{table}\end{Schunk}

\section{Fonction de densité}

Intégration de la fonction de densité approximée avec le point de selle, pour la
normaliser en fonction qui intègre à 1.

\begin{Schunk}
\begin{Sinput}
> f_integrale_saddle <- function(param,f,lower,upper) 
+ 	integrate(f,lower,upper,param)$value
> norm_int_saddle <- sapply(l.pts.estim,f_integrale_saddle,
+ 		f=dsaddleapproxGAL,lower=-Inf,upper=Inf)
\end{Sinput}
\end{Schunk}

Séquence de points pour les graphiques
\begin{Schunk}
\begin{Sinput}
> x_sRET <- seq(min(sRET)-sd(sRET),max(sRET)+sd(sRET),length.out=50)
\end{Sinput}
\end{Schunk}

Graphique de la fonction de densité

\begin{Schunk}
\begin{Sinput}
> colors2=c("black","red","green","blue","grey")
> for (i in 1:dim(pts.estim)[2])
+ {
+ 	file=paste(strData,"-densite-", i, ".pdf", sep="")
+ 	pdf(file=file, paper="special", width=6, height=6)
+ 	plot(density(sRET),ylim=c(0,.7),type="l",
+ 			main=paste("Densité de",strData, i),xlab=strData,
+ 			ylab="f",lwd=2,lty=1)
+ 	points(x_sRET,
+ 			dGAL(x_sRET,pts.estim[,i]),
+ 			type="b",ylim=c(0,4),col="red",pch=19,lwd=2,lty=2)
+ 	points(x_sRET,
+ 			dsaddleapproxGAL(x_sRET,pts.estim[,i])/norm_int_saddle[i],
+ 			type="b",ylim=c(0,4),col="green",pch=20,lwd=2,lty=3)
+ 	
+ 	lines(x_sRET,dnorm(x_sRET),type="b",col="blue",
+ 			pch=21,lwd=2,lty=4)
+ 	points(seq(-2,4,length.out=1000)[seq(40,1000,by=40)],
+ 			cftodensity.fft(cfGAL,1000,-2,4,pts.estim[,i])$dens[seq(40,1000,by=40)],
+ 			type="b",col="grey",pch=23,lty=6)
+ 	legend(quantile(sRET,0.9),0.7, c("emp","est.GAL","pt.selle","appx.nrm","fft"),
+ 			cex=0.8, col=colors2, pch=c(NA,19:23), lty=1:6, title="Courbes")
+ 	dev.off()
+ 	cat("\\includegraphics[height=4in, width=4in]{"
+ 			,file, "}\n", sep="")
+ }  
\end{Sinput}
\includegraphics[height=4in, width=4in]{Buckle95-densite-1.pdf}
\includegraphics[height=4in, width=4in]{Buckle95-densite-2.pdf}
\includegraphics[height=4in, width=4in]{Buckle95-densite-3.pdf}
\includegraphics[height=4in, width=4in]{Buckle95-densite-4.pdf}
\includegraphics[height=4in, width=4in]{Buckle95-densite-5.pdf}
\includegraphics[height=4in, width=4in]{Buckle95-densite-6.pdf}
\includegraphics[height=4in, width=4in]{Buckle95-densite-7.pdf}
\includegraphics[height=4in, width=4in]{Buckle95-densite-8.pdf}\end{Schunk}

\subsection{Tests avec contraintes}

Test de Wald

\begin{Schunk}
\begin{Sinput}
> R <- matrix(c(0,0,1,0,
+ 				0,0,0,1),ncol=4)
> r <- matrix(c(0,0),ncol=1)
> V <- lapply(l.pts.estim,covariance.GMM,meanvariance.gmm.vector,
+ 		sRET,meanQEE,varianceQEE)
> D <- lapply(l.pts.estim,mean.variance.GMM.gradient.GAL,sRET)
> xtable(mapply(Wald.Test,l.pts.estim,n,list(R),list(r),V,D),
+ 		caption="Test de Wald", digits=2)
\end{Sinput}
\begin{Soutput}
% latex table generated in R 3.0.2 by xtable 1.7-4 package
% Mon Oct 13 12:28:07 2014
\begin{table}[ht]
\centering
\begin{tabular}{rrrrrrrrr}
  \hline
 & pt.optim1 & pt.optim2 & pt.optim3 & pt.optim4 & pt.optim5 & pt.optim6 & pt.optim7 & pt.optim8 \\ 
  \hline
wald.stat & 1861.21 & 1796.75 & 1690.26 & 1865.01 & 1814.81 & 1690.62 & 2111.08 & 2175.45 \\ 
  p.value & 1.00 & 1.00 & 1.00 & 1.00 & 1.00 & 1.00 & 1.00 & 1.00 \\ 
  reject & 1.00 & 1.00 & 1.00 & 1.00 & 1.00 & 1.00 & 1.00 & 1.00 \\ 
   \hline
\end{tabular}
\caption{Test de Wald} 
\end{table}
\end{Soutput}
\end{Schunk}

\subsection{Vrais paramètres}

Comme nous avons estimé avec des données centrées et réduites, nous utilisons
une propriété de la distribution GAL qui nous permet d'obtenir les paramètres
des rendements non réduits.

\begin{Schunk}
\begin{Sinput}
> pts.estim.ns <- apply(pts.estim,2,scaleGAL,type="mu",
+ 		mean(RETURNS),sd(RETURNS))
\end{Sinput}
\end{Schunk}

\begin{Schunk}
\begin{Sinput}
> 	xtable(pts.estim.ns, 
+ 			caption="Paramètres des données non centrées et réduites",
+ 			digits=4)
\end{Sinput}
% latex table generated in R 3.0.2 by xtable 1.7-4 package
% Mon Oct 13 12:28:07 2014
\begin{table}[ht]
\centering
\begin{tabular}{rrrrrrrrr}
  \hline
 & pt.optim1 & pt.optim2 & pt.optim3 & pt.optim4 & pt.optim5 & pt.optim6 & pt.optim7 & pt.optim8 \\ 
  \hline
1 & -0.0092 & -0.0080 & -0.0090 & -0.0092 & -0.0079 & -0.0091 & -0.0081 & -0.0081 \\ 
  2 & 0.0078 & 0.0083 & 0.0079 & 0.0078 & 0.0083 & 0.0079 & 0.0081 & 0.0081 \\ 
  3 & 0.0033 & 0.0031 & 0.0033 & 0.0033 & 0.0031 & 0.0033 & 0.0030 & 0.0030 \\ 
  4 & 2.0214 & 1.8783 & 1.9603 & 2.0220 & 1.8804 & 1.9616 & 1.9660 & 1.9727 \\ 
   \hline
\end{tabular}
\caption{Paramètres des données non centrées et réduites} 
\end{table}\end{Schunk}

\section{Prix d'options}

\subsection{Données de base}

\begin{Schunk}
\begin{Sinput}
> #Taux sans risque
> rfrate <- .05/365
> #Échéance
> Time_to_expiry <- 30
> #Pas de discrétisation courbe des prix
> pas <- 1/300 
> #Prix initial
> stock0 <- 299
> #Prix d'exercice dans le cours (put)
> strike1 <- stock0*seq(0.98,1,pas)  
> #Prix d'exercice hors le cours (put)
> strike2 <- stock0*seq(1+pas,1.02,pas) 
> #Prix d'exercice combinés
> strike <- c(strike1,strike2)
> #Damping parameter
> alpha <- 3
\end{Sinput}
\end{Schunk}

\subsection{Paramètres neutres au risque}

\begin{Schunk}
\begin{Sinput}
> pts.estim.ns.rn <- apply(pts.estim.ns,2,riskneutralparGAL,rfrate)
> l.pts.estim.ns.rn <- as.list(data.frame(pts.estim.ns.rn))
\end{Sinput}
\end{Schunk}

\begin{Schunk}
\begin{Sinput}
> xtable(pts.estim.ns.rn,caption="Paramètres neutres au risque",digits=4)
\end{Sinput}
% latex table generated in R 3.0.2 by xtable 1.7-4 package
% Mon Oct 13 12:28:07 2014
\begin{table}[ht]
\centering
\begin{tabular}{rrrrrrrrr}
  \hline
 & pt.optim1 & pt.optim2 & pt.optim3 & pt.optim4 & pt.optim5 & pt.optim6 & pt.optim7 & pt.optim8 \\ 
  \hline
1 & -0.0066 & -0.0057 & -0.0065 & -0.0066 & -0.0057 & -0.0065 & -0.0058 & -0.0058 \\ 
  2 & 0.0078 & 0.0083 & 0.0079 & 0.0078 & 0.0083 & 0.0079 & 0.0081 & 0.0081 \\ 
  3 & 0.0033 & 0.0031 & 0.0033 & 0.0033 & 0.0031 & 0.0033 & 0.0030 & 0.0030 \\ 
  4 & 2.0214 & 1.8783 & 1.9603 & 2.0220 & 1.8804 & 1.9616 & 1.9660 & 1.9727 \\ 
   \hline
\end{tabular}
\caption{Paramètres neutres au risque} 
\end{table}\end{Schunk}


\subsection{Méthode de Epps}

\begin{Schunk}
\begin{Sinput}
> 	f_putEpps <- function(param,strikeprice,char.fn,eval.time,expiry.time,rate,...)
+ 		putEpps(strikeprice,char.fn,param,eval.time,expiry.time,rate,...)
> 	prix_put_Epps <- as.data.frame(cbind(strike/stock0,sapply(l.pts.estim.ns.rn,f_putEpps,strike/stock0,cfLM,0,Time_to_expiry,rfrate)))
\end{Sinput}
\end{Schunk}

\begin{Schunk}
\begin{Sinput}
> 	xtable(prix_put_Epps,caption="Prix unitaire de l'option de vente, Méthode de Epps",digits=6)
\end{Sinput}
% latex table generated in R 3.0.2 by xtable 1.7-4 package
% Mon Oct 13 12:28:07 2014
\begin{table}[ht]
\centering
\begin{tabular}{rrrrrrrrrr}
  \hline
 & V1 & pt.optim1 & pt.optim2 & pt.optim3 & pt.optim4 & pt.optim5 & pt.optim6 & pt.optim7 & pt.optim8 \\ 
  \hline
1 & 0.980000 & 0.015415 & 0.015785 & 0.015431 & 0.015417 & 0.015794 & 0.015427 & 0.015792 & 0.015819 \\ 
  2 & 0.983333 & 0.016695 & 0.017070 & 0.016711 & 0.016697 & 0.017079 & 0.016707 & 0.017076 & 0.017103 \\ 
  3 & 0.986667 & 0.018041 & 0.018421 & 0.018059 & 0.018043 & 0.018430 & 0.018054 & 0.018426 & 0.018454 \\ 
  4 & 0.990000 & 0.019456 & 0.019838 & 0.019474 & 0.019458 & 0.019847 & 0.019469 & 0.019843 & 0.019871 \\ 
  5 & 0.993333 & 0.020938 & 0.021322 & 0.020957 & 0.020940 & 0.021331 & 0.020952 & 0.021326 & 0.021355 \\ 
  6 & 0.996667 & 0.022489 & 0.022874 & 0.022507 & 0.022491 & 0.022883 & 0.022503 & 0.022877 & 0.022905 \\ 
  7 & 1.000000 & 0.024107 & 0.024492 & 0.024126 & 0.024109 & 0.024501 & 0.024121 & 0.024495 & 0.024523 \\ 
  8 & 1.003333 & 0.025793 & 0.026177 & 0.025812 & 0.025795 & 0.026186 & 0.025808 & 0.026179 & 0.026207 \\ 
  9 & 1.006667 & 0.027546 & 0.027928 & 0.027566 & 0.027548 & 0.027937 & 0.027561 & 0.027929 & 0.027957 \\ 
  10 & 1.010000 & 0.029365 & 0.029745 & 0.029385 & 0.029367 & 0.029753 & 0.029381 & 0.029745 & 0.029773 \\ 
  11 & 1.013333 & 0.031250 & 0.031626 & 0.031271 & 0.031252 & 0.031635 & 0.031266 & 0.031626 & 0.031653 \\ 
  12 & 1.016667 & 0.033200 & 0.033572 & 0.033221 & 0.033202 & 0.033580 & 0.033217 & 0.033571 & 0.033597 \\ 
  13 & 1.020000 & 0.035214 & 0.035580 & 0.035235 & 0.035216 & 0.035589 & 0.035231 & 0.035579 & 0.035605 \\ 
   \hline
\end{tabular}
\caption{Prix unitaire de l'option de vente, Méthode de Epps} 
\end{table}\end{Schunk}

\subsection{Méthode de Carr-Madan}
\begin{Schunk}
\begin{Sinput}
> 	f_callCarrMadan <- function(param,strikeprice,char.fn,eval.time,expiry.time,rate,alpha,...)
+ 	{
+ 		callCarrMadan(strikeprice,char.fn,param,eval.time,expiry.time,rate,alpha,...)
+ 	}
> 	prix_call_CarrMadan <- as.data.frame(cbind(strike/stock0,sapply(l.pts.estim.ns.rn,f_callCarrMadan,strike/stock0,cfLM,0,Time_to_expiry,rfrate,alpha)))
\end{Sinput}
\end{Schunk}

\begin{Schunk}
\begin{Sinput}
> 	xtable(prix_call_CarrMadan,caption="Prix unitaire de l'option d'achat, Méthode de Carr-Madan",digits=6)
\end{Sinput}
% latex table generated in R 3.0.2 by xtable 1.7-4 package
% Mon Oct 13 12:28:07 2014
\begin{table}[ht]
\centering
\begin{tabular}{rrrrrrrrrr}
  \hline
 & V1 & pt.optim1 & pt.optim2 & pt.optim3 & pt.optim4 & pt.optim5 & pt.optim6 & pt.optim7 & pt.optim8 \\ 
  \hline
1 & 0.980000 & 0.044899 & 0.045144 & 0.044912 & 0.044900 & 0.045150 & 0.044909 & 0.045145 & 0.045163 \\ 
  2 & 0.983333 & 0.042853 & 0.043101 & 0.042866 & 0.042854 & 0.043107 & 0.042863 & 0.043102 & 0.043119 \\ 
  3 & 0.986667 & 0.040852 & 0.041102 & 0.040865 & 0.040853 & 0.041108 & 0.040862 & 0.041102 & 0.041120 \\ 
  4 & 0.990000 & 0.038895 & 0.039148 & 0.038909 & 0.038896 & 0.039153 & 0.038906 & 0.039147 & 0.039165 \\ 
  5 & 0.993333 & 0.036983 & 0.037238 & 0.036998 & 0.036985 & 0.037244 & 0.036995 & 0.037237 & 0.037255 \\ 
  6 & 0.996667 & 0.035117 & 0.035373 & 0.035132 & 0.035118 & 0.035379 & 0.035129 & 0.035372 & 0.035390 \\ 
  7 & 1.000000 & 0.033297 & 0.033555 & 0.033312 & 0.033298 & 0.033560 & 0.033309 & 0.033553 & 0.033571 \\ 
  8 & 1.003333 & 0.031522 & 0.031782 & 0.031538 & 0.031524 & 0.031787 & 0.031534 & 0.031780 & 0.031798 \\ 
  9 & 1.006667 & 0.029795 & 0.030055 & 0.029810 & 0.029796 & 0.030061 & 0.029807 & 0.030053 & 0.030071 \\ 
  10 & 1.010000 & 0.028114 & 0.028375 & 0.028130 & 0.028115 & 0.028381 & 0.028126 & 0.028372 & 0.028390 \\ 
  11 & 1.013333 & 0.026480 & 0.026742 & 0.026496 & 0.026481 & 0.026748 & 0.026493 & 0.026739 & 0.026757 \\ 
  12 & 1.016667 & 0.024894 & 0.025156 & 0.024910 & 0.024895 & 0.025162 & 0.024907 & 0.025153 & 0.025171 \\ 
  13 & 1.020000 & 0.023356 & 0.023618 & 0.023373 & 0.023357 & 0.023624 & 0.023369 & 0.023615 & 0.023633 \\ 
   \hline
\end{tabular}
\caption{Prix unitaire de l'option d'achat, Méthode de Carr-Madan} 
\end{table}\end{Schunk}

\subsection{Méthode de Heston}

\begin{Schunk}
\begin{Sinput}
> 	prix_put_Heston <- as.data.frame(cbind(strike/stock0,
+ 					sapply(l.pts.estim.ns.rn,putHeston,strike/stock0,pnormapproxEsscherLM,0,Time_to_expiry,rfrate)))
\end{Sinput}
\end{Schunk}

\begin{Schunk}
\begin{Sinput}
> 	xtable(prix_put_Heston,caption="Prix unitaire de l'option de vente, Méthode de Heston",digits=6)
\end{Sinput}
% latex table generated in R 3.0.2 by xtable 1.7-4 package
% Mon Oct 13 12:28:07 2014
\begin{table}[ht]
\centering
\begin{tabular}{rrrrrrrrrr}
  \hline
 & V1 & pt.optim1 & pt.optim2 & pt.optim3 & pt.optim4 & pt.optim5 & pt.optim6 & pt.optim7 & pt.optim8 \\ 
  \hline
1 & 0.980000 & 0.000042 & 0.000050 & 0.000042 & 0.000042 & 0.000050 & 0.000042 & 0.000050 & 0.000050 \\ 
  2 & 0.983333 & 0.000112 & 0.000127 & 0.000113 & 0.000112 & 0.000127 & 0.000113 & 0.000127 & 0.000128 \\ 
  3 & 0.986667 & 0.000258 & 0.000282 & 0.000259 & 0.000258 & 0.000283 & 0.000259 & 0.000282 & 0.000284 \\ 
  4 & 0.990000 & 0.000529 & 0.000565 & 0.000531 & 0.000529 & 0.000566 & 0.000530 & 0.000565 & 0.000568 \\ 
  5 & 0.993333 & 0.000988 & 0.001037 & 0.000991 & 0.000988 & 0.001039 & 0.000990 & 0.001038 & 0.001041 \\ 
  6 & 0.996667 & 0.001704 & 0.001766 & 0.001707 & 0.001704 & 0.001767 & 0.001706 & 0.001766 & 0.001770 \\ 
  7 & 1.000000 & 0.002739 & 0.002811 & 0.002743 & 0.002740 & 0.002812 & 0.002742 & 0.002811 & 0.002816 \\ 
  8 & 1.003333 & 0.004140 & 0.004216 & 0.004144 & 0.004141 & 0.004217 & 0.004143 & 0.004216 & 0.004221 \\ 
  9 & 1.006667 & 0.005924 & 0.005997 & 0.005928 & 0.005925 & 0.005999 & 0.005927 & 0.005998 & 0.006003 \\ 
  10 & 1.010000 & 0.008078 & 0.008144 & 0.008081 & 0.008078 & 0.008145 & 0.008081 & 0.008144 & 0.008148 \\ 
  11 & 1.013333 & 0.010561 & 0.010615 & 0.010564 & 0.010561 & 0.010616 & 0.010563 & 0.010615 & 0.010619 \\ 
  12 & 1.016667 & 0.013314 & 0.013356 & 0.013316 & 0.013315 & 0.013357 & 0.013316 & 0.013356 & 0.013359 \\ 
  13 & 1.020000 & 0.016273 & 0.016303 & 0.016275 & 0.016274 & 0.016304 & 0.016275 & 0.016303 & 0.016305 \\ 
   \hline
\end{tabular}
\caption{Prix unitaire de l'option de vente, Méthode de Heston} 
\end{table}\end{Schunk}

\subsection{Méthode de Heston avec point de selle}


\begin{Schunk}
\begin{Sinput}
> 	prix_put_Heston_Saddle <- as.data.frame(cbind(strike/stock0,
+ 					sapply(l.pts.estim.ns.rn,putHestonSaddle,strike/stock0,psaddleapproxGAL,psaddleapproxEsscherGAL,0,Time_to_expiry,rfrate)
+ 	)
+ 	)
> 	
> 	
\end{Sinput}
\end{Schunk}

\begin{Schunk}
\begin{Sinput}
> 	xtable(prix_put_Heston_Saddle,caption="Prix unitaire de l'option de vente, Méthode de Heston avec point de selle",digits=6)
\end{Sinput}
% latex table generated in R 3.0.2 by xtable 1.7-4 package
% Mon Oct 13 12:28:07 2014
\begin{table}[ht]
\centering
\begin{tabular}{rrrrrrrrrr}
  \hline
 & V1 & pt.optim1 & pt.optim2 & pt.optim3 & pt.optim4 & pt.optim5 & pt.optim6 & pt.optim7 & pt.optim8 \\ 
  \hline
1 & 0.980000 & 0.000013 & 0.000028 & 0.000014 & 0.000013 & 0.000029 & 0.000014 & 0.000027 & 0.000028 \\ 
  2 & 0.983333 & 0.000031 & 0.000058 & 0.000033 & 0.000031 & 0.000059 & 0.000033 & 0.000057 & 0.000059 \\ 
  3 & 0.986667 & 0.000080 & 0.000125 & 0.000082 & 0.000080 & 0.000126 & 0.000082 & 0.000125 & 0.000129 \\ 
  4 & 0.990000 & 0.000218 & 0.000286 & 0.000219 & 0.000219 & 0.000288 & 0.000219 & 0.000289 & 0.000295 \\ 
  5 & 0.993333 & 0.000643 & 0.000731 & 0.000640 & 0.000643 & 0.000734 & 0.000639 & 0.000742 & 0.000751 \\ 
  6 & 0.996667 & 0.002824 & 0.002995 & 0.002821 & 0.002825 & 0.003000 & 0.002818 & 0.003015 & 0.003032 \\ 
  7 & 1.000000 & 50.670706 & 54.250289 & 50.855258 & 50.688713 & 54.335797 & 50.813217 & 54.254710 & 54.521211 \\ 
  8 & 1.003333 & 0.000672 & 0.000579 & 0.000654 & 0.000672 & 0.000579 & 0.000655 & 0.000601 & 0.000599 \\ 
  9 & 1.006667 & 0.005575 & 0.005597 & 0.005572 & 0.005575 & 0.005598 & 0.005571 & 0.005606 & 0.005609 \\ 
  10 & 1.010000 & 0.008175 & 0.008202 & 0.008176 & 0.008175 & 0.008202 & 0.008175 & 0.008204 & 0.008206 \\ 
  11 & 1.013333 & 0.010842 & 0.010867 & 0.010845 & 0.010842 & 0.010868 & 0.010845 & 0.010865 & 0.010866 \\ 
  12 & 1.016667 & 0.013672 & 0.013694 & 0.013677 & 0.013672 & 0.013694 & 0.013676 & 0.013689 & 0.013689 \\ 
  13 & 1.020000 & 0.016638 & 0.016658 & 0.016643 & 0.016638 & 0.016658 & 0.016643 & 0.016651 & 0.016651 \\ 
   \hline
\end{tabular}
\caption{Prix unitaire de l'option de vente, Méthode de Heston avec point de selle} 
\end{table}\end{Schunk}





















\end{document}
