Title | 6-Estimate Corr Const - Matematica finanziaria progredito (corso Finanza) |
---|---|
Author | Luca Zaffaina |
Course | Matematica finanziaria |
Institution | Università degli Studi di Trento |
Pages | 1 |
File Size | 37 KB |
File Type | |
Total Downloads | 621 |
Total Views | 931 |
16/11/20 18 C:\Users\laky_...\EstimateCorrConst 1 of 1function [SigmaCorrCost]=EstimateCorrCost(LogReturns, rho)% Function to compute the covariance matrix with constant correlation % INPUTS % LogReturns: (matrix: TxN assets) of log-returns % rho: (scalar) correlation coefficient% OUTPUTS% SigmaCorr...
16/11/20 18.06
C:\Users\laky_\...\EstimateCorrConst.m
1 of 1
function [SigmaCorrCost]=EstimateCorrCost(LogReturns, rho) % % % %
Function to compute the covariance matrix with constant correlation INPUTS LogReturns: (matrix: TxN assets) of log-returns rho: (scalar) correlation coefficient
% OUTPUTS % SigmaCorrCost: (matrix: N assets x N assets) of estimated covariance % with the method of constant correlation
[M,N]=size(LogReturns); % CALCOLO LA MATRICE DI COVARIANZA CON IL METODO DELLA CORRELAZIONE COSTANTE % Per i che va da StandardDeviation=std(LogReturns); Variance=var(LogReturns); SigmaCorrCost=[]; for i=1:N % sul numero di righe for j=1:N % calcola per ciascuna colonna j -> per j che va da 1 a N if i==j % se i è uguale a j, il valore nella matrice è: SigmaCorrCost(i,j)=Variance(i); % metti la varianza in posizione i,j else % se i è diverso da j SigmaCorrCost(i,j)=rho*StandardDeviation(i)*StandardDeviation(j); % in ogni altro caso la sigma (i,j), la covarianza è uguale a % rho per le deviazioni standard del titolo i-esimo per la % deviazione standard del titolo j-esimo. end end end % se avessi avuto più condizioni avrei potuto usare % "if ...else if ... else if... end" inserendo in else if tutte le mie % condizioni....