Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

LiborFactorLoading.h

Go to the documentation of this file.
00001 /* WARANTY NOTICE AND COPYRIGHT
00002 This program is free software; you can redistribute it and/or
00003 modify it under the terms of the GNU General Public License
00004 as published by the Free Software Foundation; either version 2
00005 of the License, or (at your option) any later version.
00006 
00007 This program is distributed in the hope that it will be useful,
00008 but WITHOUT ANY WARRANTY; without even the implied warranty of
00009 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010 GNU General Public License for more details.
00011 
00012 You should have received a copy of the GNU General Public License
00013 along with this program; if not, write to the Free Software
00014 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00015 
00016 Copyright (C) Michael J. Meyer
00017 
00018 matmjm@mindspring.com
00019 spyqqqdia@yahoo.com
00020 
00021 */
00022 
00023 
00024 
00025 
00026 #ifndef martingale_liborfactorloading_h    
00027 #define martingale_liborfactorloading_h
00028 
00029 #include "TypedefsMacros.h"
00030 #include "Array.h"                            // direct members
00031 #include "Matrix.h"                           // problem with typedefs in forward declarations
00032 #include <string>                             // problem with string forward declaration
00033 #include "VolatilityAndCorrelation.h"         // reference to VolSurface::JR, Correlations::CS
00034 
00035 MTGL_BEGIN_NAMESPACE(Martingale)
00036 
00037 
00038 // dependencies
00039 class std::ostream;
00040 // class VolSurface;
00041 // class Correlations;
00042 // extern int VolSurface::JR;
00043 // extern int Correlations::CS;
00044 // class std::string;
00045 // class RealArray1D;
00046 
00047 
00048 
00049 
00057 /*******************************************************************************
00058  *
00059  *                     LiborFactorLoadingType
00060  * 
00061  ******************************************************************************/
00062  
00066  struct LiborFactorLoadingType{
00067           
00068           const int volType;
00069           const int corrType;
00070          
00074           LiborFactorLoadingType(int volSurface, int correlations);                                                                    
00075           
00076       std::string volSurfaceType() const;
00077           std::string correlationType() const;
00078           
00079           std::ostream& printSelf(std::ostream&) const;
00080 };
00081 
00082 
00083 
00084 
00085 
00086 /*******************************************************************************
00087  *
00088  *                     LiborFactorLoading
00089  * 
00090  ******************************************************************************/
00091 
00092 
00131 class LiborFactorLoading {      
00132 
00133 protected:
00134         
00135         LiborFactorLoadingType flType;
00136         
00137     int n;                     // dimension of Y        
00138     
00139     RealArray1D delta;         // delta[j]=T[j+1]-T[j]
00140     RealArray1D T;             // tenor structure T[t]=T_t
00141         RealArray1D l;             // l[j]=L_j(0)
00142         RealArray1D x;             // x[j]=X_j(0)=delta_jL_j(0)
00143         RealArray1D k;             // volatility scaling factors
00144         
00145     VolSurface* vol;           // volatility surface
00146         Correlations* corr;        // log-Libor correlations
00147         Correlations&  rho;        // correlations *corrs
00148                 
00149 public:
00150         
00151     
00152 // ACCESSORS
00153         
00156         const LiborFactorLoadingType* getType() const { return &flType; }
00157     
00160     int getDimension() const { return n; }
00161         
00164     const RealArray1D& getDeltas() const { return delta; }
00165     
00168     const RealArray1D& getTenorStructure() const { return T; }
00169         
00171         Real getT(int i) const { return T[i]; }
00172         
00175     const RealArray1D& getInitialLibors() const { return l; }
00176         
00179     const RealArray1D& getInitialXLibors() const { return x; }
00180         
00183         RealArray1D& getScalingFactors(){ return k; }
00184         
00187         const UTRRealMatrix& getRho() const;
00188         
00190         VolSurface* getVolSurface() { return vol; }
00191         
00193         Correlations* getCorrelations() { return corr; }
00194         
00195         
00196     
00197 // CONSTRUCTOR
00198 
00199         
00207     LiborFactorLoading
00208         (const RealArray1D& L0, const RealArray1D& deltas, const RealArray1D& _k, 
00209          VolSurface* vols, Correlations* corrs);
00210         
00211         ~LiborFactorLoading(){ delete vol; delete corr; }
00212         
00213         
00214 // SET THE PARAMETERS (CALIBRATION)
00215         
00220    void setParameters(const RealArray1D& u);
00221         
00222    
00223         
00224         
00225 // CORRELATIONS, VOLATILITIES, LOG-COVARIATION INTEGRALS
00226 
00227    
00234    Real sigma(int i, Real t) const;
00235            
00236    
00244    Real integral_sgi_sgj_rhoij(int i, int j, Real s, Real t) const;
00245            
00246    
00248    Real annualVol(int i) const;
00249    
00250    
00251 
00252 // LOG-LIBOR COVARIATION MATRICES 
00253 
00254    
00261    const UTRRealMatrix&
00262    logLiborCovariationMatrix(int p,int q, Real s, Real t) const;
00263   
00264   
00272    const UTRRealMatrix& 
00273    logLiborCovariationMatrix(int t) const;
00274 
00275    
00276    
00284    const UTRRealMatrix& 
00285    logLiborCovariationMatrixRoot(int t) const;
00286 
00287 
00298    const RealMatrix& 
00299    reducedRankLogLiborCovariationMatrixRoot(int t, int r) const;
00300    
00301 
00302 //  EIGEN ANALYSIS OF THE COVARIATION MATRICES
00303 
00309      void factorAnalysis(int p, int q, Real s, Real t, int r) const;
00310          
00311          
00317      void factorAnalysis(int t, int r) const;
00318 
00319  
00320    
00321    
00322 
00323 // TEST PROGRAM 
00324 
00325                  
00328 void selfTest() const;
00329 
00330 
00334 void factorizationTest(int r) const;
00335 
00336 
00341 static LiborFactorLoading* 
00342 sample(int n, int volType=VolSurface::JR, int corrType=Correlations::CS);
00343 
00344    
00346 std::ostream& printSelf(std::ostream& os) const;
00347    
00348 
00349 }; // end LiborFactorLoading
00350 
00351 
00352 
00353 // GLOBAL INSERTION
00354 std::ostream& operator << (std::ostream& os, const LiborFactorLoading& fl);
00355 
00356 
00357 
00358 MTGL_END_NAMESPACE(Martingale)
00359 
00360 #endif

Generated on Mon Sep 22 02:16:32 2003 for Libor-Library by doxygen1.3-rc3