[R-SIG-Finance] Performance Analytics internal multivariateMoments calculations

Joe W. Byers ecjbosu at aol.com
Mon May 22 21:59:59 CEST 2017


All,


I have carved on all methods in MultivariateMoments.R so I can all them 
directly

I am working on the modified var calculations.  I ran the mVaR.MM on my 
data and the results were odd.  I reran setting skewness and kurtosis to 
0 to compare with GVAR.MM.  Still questions.  I have the following example

#test for sigfinance
w = 1000000;
Mean = 0.0001898251;
Stdev = 0.01612464;
ExKurtosis = 3.946156;
Skewness = -0.1373454;

GVaR = GVaR.MM(w,Mean,Stdev, .95)
GVaR
MVaR = mVaR.MM(w,Mean,Stdev, 0,0, .95);
#shoud be equal to GVaR
GVaR==MVaR
MVaR

mVaR.MM does not return the GVaR.MM.  I found the exkurt was not zero as 
I think it should be.  I remove the - 3 from that line and exkurt became 
zero and mVaR.MM == GVaR results.  I have included this modified version 
of mVaR.MM below and continued the test.  Is this an issue or am I 
missing something?


#corrected exkurt calc
mVaR.MM1 = function(w, mu, sigma, M3, M4, p ){
   skew = skewness.MM(w,sigma,M3);
   exkurt = kurtosis.MM(w,sigma,M4); #removed -3
   z = qnorm(1-p);
   zc = z + (1/6)*(z^2 -1)*skew
   Zcf = zc + (1/24)*(z^3 - 3*z)*exkurt - (1/36)*(2*z^3 - 5*z)*skew^2;
   return ( -multivariate_mean(w,mu) - Zcf*StdDev.MM(w,sigma)  )
}

#call revised mVAR.MM with m3 and m4 equal 0
MVaR1 = mVaR.MM1(w,Mean,Stdev, 0,0, .95);
#shoud be equal to GVaR
GVaR==MVaR1
MVaR1

#with m3 and m4 not zero
MVaR1 = mVaR.MM1(1, Mean, Stdev, Skewness, ExKurtosis, .95);
MVaR1

MVaR1 = mVaR.MM1(w, Mean, Stdev, Skewness, ExKurtosis, .95);
MVaR1

This result still looks strange and would appreciate any thoughts, with 
1 or w weights, I get the same just scaled.  Note this is real commodity 
data with all statistics generated by table.Stats.

Thanks

Joe


-- 
*Joe W. Byers*

	[[alternative HTML version deleted]]



More information about the R-SIG-Finance mailing list