Function JBTest(ReturnVector, SignificanceLevel)
Jarque-Bera hypothesis
test of normality:
' Andreas Steiner, March 2006
' http://www.andreassteiner.net/performanceanalysis
n = WorksheetFunction.Max(ReturnVector.Columns.Count, ReturnVector.Rows.Count)
ReturnVectorMean = WorksheetFunction.Average(ReturnVector)
ReturnVectorStDev = WorksheetFunction.StDev(ReturnVector)
' Normalize returns
ReDim NormalizedReturns(1 To n)
For i = 1 To n
NormalizedReturns(i) = (ReturnVector(i) - ReturnVectorMean) / ReturnVectorStDev
Next i
' Calculate 3rd and 4th moments (skewness and kurtosis)
S = 0
K = 0
For i = 1 To n
S = S + NormalizedReturns(i) ^ 3
K = K + NormalizedReturns(i) ^ 4
Next i
S = S / n
K = K / n - 3
JB = n * ((S ^ 2) / 6 + (K ^ 2) / 24)
pValue = WorksheetFunction.ChiDist(JB, 2)
JBTest = (SignificanceLevel < pValue)
End Function
Function JBCriticalValue(ReturnVector, SignificanceLevel)
' Jarque-Bera hypothesis test of normality.
'
' Andreas Steiner, March 2006
' http://www.andreassteiner.net/performanceanalysis
JBCriticalValue = WorksheetFunction.ChiInv(SignificanceLevel, 2)
End Function
Function JBpValue(ReturnVector, SignificanceLevel)
' Jarque-Bera hypothesis test of normality.
'
' Andreas Steiner, March 2006
' http://www.andreassteiner.net/performanceanalysis
n = WorksheetFunction.Max(ReturnVector.Columns.Count, ReturnVector.Rows.Count)
ReturnVectorMean = WorksheetFunction.Average(ReturnVector)
ReturnVectorStDev = WorksheetFunction.StDev(ReturnVector)
' Normalize returns
ReDim NormalizedReturns(1 To n)
For i = 1 To n
NormalizedReturns(i) = (ReturnVector(i) - ReturnVectorMean) / ReturnVectorStDev
Next i
' Calculate 3rd and 4th moments (skewness and kurtosis)
S = 0
K = 0
For i = 1 To n
S = S + NormalizedReturns(i) ^ 3
K = K + NormalizedReturns(i) ^ 4
Next i
S = S / n
K = K / n - 3
JB = n * ((S ^ 2) / 6 + (K ^ 2) / 24)
JBpValue = WorksheetFunction.ChiDist(JB, 2)
End Function
Function JBStat(ReturnVector, SignificanceLevel)
' Jarque-Bera hypothesis test of normality.
'
' Andreas Steiner, March 2006
' http://www.andreassteiner.net/performanceanalysis
n = WorksheetFunction.Max(ReturnVector.Columns.Count, ReturnVector.Rows.Count)
ReturnVectorMean = WorksheetFunction.Average(ReturnVector)
ReturnVectorStDev = WorksheetFunction.StDev(ReturnVector)
' Normalize returns
ReDim NormalizedReturns(1 To n)
For i = 1 To n
NormalizedReturns(i) = (ReturnVector(i) - ReturnVectorMean) / ReturnVectorStDev
Next i
' Calculate 3rd and 4th moments (skewness and kurtosis)
S = 0
K = 0
For i = 1 To n
S = S + NormalizedReturns(i) ^ 3
K = K + NormalizedReturns(i) ^ 4
Next i
S = S / n
K = K / n - 3
JBStat = n * ((S ^ 2) / 6 + (K ^ 2) / 24)
End Function
EXCEL FUNCTION
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment