Вы находитесь на странице: 1из 5

VaR{PerformanceAnalytics}

RDocumentation

calculatevariousValueatRisk(VaR)measures
Description
CalculatesValueatRisk(VaR)forunivariate,component,andmarginalcasesusingavarietyof
analyticalmethods.
Usage
VaR(R,p=0.95,method=c("modified","gaussian","historical","kernel"),
clean=c("none","boudt","geltner"),
portfolio_method=c("single","component","marginal"),
weights=NULL,mu=NULL,sigma=NULL,
m3=NULL,m4=NULL,invert=TRUE,...)

Arguments
anxts,vector,matrix,dataframe,timeSeriesorzooobjectofassetreturns
p
confidencelevelforcalculation,defaultp=.99
method
oneof"modified","gaussian","historical","kernel",seeDetails.
clean
methodfordatacleaningthroughReturn.clean.Currentoptionsare"none",
"boudt",or"geltner".
portfolio_method oneof"single","component","marginal"definingwhethertodounivariate,
component,ormarginalcalc,seeDetails.
weights
portfolioweightingvector,defaultNULL,seeDetails
mu
Ifunivariate,muisthemeanoftheseries.Otherwisemuisthevectorofmeansof
thereturnseries,defaultNULL,,seeDetails
sigma
Ifunivariate,sigmaisthevarianceoftheseries.Otherwisesigmaisthecovariance
matrixofthereturnseries,defaultNULL,seeDetails
m3
Ifunivariate,m3istheskewnessoftheseries.Otherwisem3isthecoskewness
matrixofthereturnsseries,defaultNULL,seeDetails
m4
Ifunivariate,m4istheexcesskurtosisoftheseries.Otherwisem4isthe
cokurtosismatrixofthereturnseries,defaultNULL,seeDetails
invert
TRUE/FALSEwhethertoinverttheVaRmeasure.seeDetails.
...
anyotherpassthruparameters
R

Value
VaRmeasure
Background
ThisfunctionprovidesseveralestimationmethodsfortheValueatRisk(typicallywrittenasVaR)of
areturnseriesandtheComponentVaRofaportfolio.TakecaretocapitalizeVaRinthecommonly
acceptedmanner,toavoidconfusionwithvar(variance)andVAR(vectorautoregression).VaRisan
industrystandardformeasuringdownsiderisk.Forareturnseries,VaRisdefinedasthehighquantile
(e.g.~a95%or99%quantile)ofthenegativevalueofthereturns.Thisquantileneedstobe
estimated.Withasufficientlylargedataset,youmaychoosetoutilizetheempiricalquantile
calculatedusingquantile.MoreefficientestimatesofVaRareobtainedifa(correct)assumptionis
madeonthereturndistribution,suchasthenormaldistribution.Ifyourreturnseriesisskewedand/or

hasexcesskurtosis,CornishFisherestimatesofVaRcanbemoreappropriate.FortheVaRofa
portfolio,itisalsoofinteresttodecomposetotalportfolioVaRintotheriskcontributionsofeachof
theportfoliocomponents.FortheabovementionedVaRestimators,suchadecompositionispossible
inafinanciallymeaningfulway.
UnivariateVaRestimationmethods
TheVaRataprobabilitylevelp(e.g.95%)isthepquantileofthenegativereturns,orequivalently,is
thenegativevalueofthec=1pquantileofthereturns.Inasetofreturnsforwhichsufficentlylong
historyexists,theperperiodValueatRiskissimplythequantileoftheperiodnegativereturns:
VaR=quantile(R,p)
whereq_{.99}isthe99%empiricalquantileofthenegativereturnseries.
ThismethodisalsosometimescalledhistoricalVaR,asitisbydefinitionexpostanalysisofthe
returndistribution,andmaybeaccessedwithmethod="historical".
Whenyoudon'thaveasufficientlylongsetofreturnstousenonparametricorhistoricalVaR,orwish
tomorecloselymodelanidealdistribution,itiscommontousaparmetricestimatebasedonthe
distribution.J.P.Morgan'sRiskMetricsparametricmeanVaRwaspublishedin1994andthis
methodologyforestimatingparametricmeanVaRhasbecomewhatmostliteraturegenerallyrefersto
asVaRandwhatwehaveimplementedasVaR.SeeReturntoRiskMetrics:Evolutionofa
Standardhttp://www.riskmetrics.com/publications/techdocs/r2rovv.html.
ParametricmeanVaRdoesabetterjobofaccountingforthetailsofthedistributionbymore
preciselyestimatingshapeofthedistributiontailsoftheriskquantile.Themostcommonestimateisa
normal(orGaussian)distributionR\simN(\mu,\sigma)forthereturnseries.Inthiscase,estimationof
VaRrequiresthemeanreturn\bar{R},thereturndistributionandthevarianceofthereturns\sigma.In
themostcommoncase,parametricVaRisthuscalculatedby
sigma=var(R)
VaR=mean(R)sqrt(sigma)*qnorm(c)
wherez_{c}isthecquantileofthestandardnormaldistribution.RepresentedinRbyqnorm(c),and
maybeaccessedwithmethod="gaussian".
OtherformsofparametricmeanVaRestimationutilizeadifferentdistributionforthedistributionof
lossestobetteraccountforthepossiblefattailednatureofdownsiderisk.ThepackageVaRcontains
methodsforsimulatingandestimatinglognormalVaR.normandgeneralizedParetoVaR.gpd
distributionstoovercomesomeoftheproblemswithnonparametricorparametricmeanVaR
calculationsonalimitedsamplesizeoronpotentiallyfattaileddistributions.Thereisalsoa
VaR.backtestfunctiontoapplysimulationmethodstocreateamorerobustestimateofthepotential
distributionoflosses.Lesscommonlyacovariancematrixofmultipleriskfactorsmaybeapplied.
ThelimitationsofmeanValueatRiskarewellcoveredintheliterature.Thelimitationsoftraditional
meanVaRareallrelatedtotheuseofasymetricaldistributionfunction.Useofsimulations,
resampling,orParetodistributionsallhelpinmakingamoreaccurateprediction,buttheyarestill
flawedforassetswithsignificantlynonnormal(skewedorkurtotic)distributions.Zangari(1996)and
FavreandGaleano(2002)provideamodifiedVaRcalculationthattakesthehighermomentsofnon
normaldistributions(skewness,kurtosis)intoaccountthroughtheuseofaCornishFisherexpansion,
andcollapsestostandard(traditional)meanVaRifthereturnstreamfollowsastandarddistribution.
Thismeasureisnowwidelycitedandusedintheliterature,andisusuallyreferredtoasModified
VaRorModifiedCornishFisherVaR.TheyarriveattheirmodifiedVaRcalculationinthe

followingmanner:
z_cf=z_c+[(z_c^21)S]/6+[(z_c^33z_c)K]/24[(2z_c^35z_c)S^2]/36
VaR=mean(R)sqrt(sigma)*z_cf
whereSistheskewnessofRandKistheexcesskurtosisofR.
CornishFisherVaRcollapsestotraditionalmeanVaRwhenreturnsarenormallydistributed.As
such,theVaRandVaRfunctionsarewrappersfortheVaRfunction.TheCornishFisherexpansionalso
naturallyencompassesmuchofthevariabilityinreturnsthatcouldbeuncoveredbymore
computationallyintensivetechniquessuchasresamplingorMonteCarlosimulation.Thisisthe
defaultmethodfortheVaRfunction,andmaybeaccessedbysettingmethod="modified".
FavreandGaleanoalsoutilizemodifiedVaRinamodifiedSharpeRatioasthereturn/riskmeasure
fortheirportfoliooptimizationanalysis,seeSharpeRatio.modifiedformoreinformation.
ComponentVaR
Bysettingportfolio_method="component"youmaycalculatetheriskcontributionofeachelementof
theportfolio.Thereturnfromthefunctioninthiscasewillbealistwiththreecomponents:the
univariateportfolioVaR,thescalarcontributionofeachcomponenttotheportfolioVaR(thesewill
sumtotheportfolioVaR),andapercentageriskcontribution(whichwillsumto100%).
BoththenumericalandpercentagecomponentcontributionstoVaRmaycontainbothpositiveand
negativecontributions.AnegativecontributiontoComponentVaRindicatesaportfoliorisk
diversifier.IncreasingthepositionweightwillreduceoverallportoflioVaR.
Ifaweightingvectorisnotpassedinviaweights,thefunctionwillassumeanequalweighted
(neutral)portfolio.
Multipleriskdecompositionapproacheshavebeensuggestedintheliterature.Anaveapproachis
tosettheriskcontributionequaltothestandalonerisk.Thisapproachisoverlysimplisticand
neglectsimportantdiversificationeffectsoftheunitsbeingexposeddifferentlytotheunderlyingrisk
factors.AnalternativeapproachistomeasuretheVaRcontributionastheweightofthepositionin
theportfoliotimesthepartialderivativeoftheportfolioVaRwithrespecttothecomponentweight.
C[i]VaR=w[i]*(dVaR/dw[i]).
BecausetheportfolioVaRislinearinpositionsize,wehavethatbyEuler'stheoremtheportfolioVaR
isthesumoftheseriskcontributions.Gouriroux(2000)showsthatforVaR,thismathematical
decompositionofportfolioriskhasafinancialmeaning.Itequalsthenegativevalueoftheasset's
expectedcontributiontotheportfolioreturnwhentheportfolioreturnequalsthenegativeportfolio
VaR:
C[i]VaR=E(w[i]r[i]|rp=VaR)
ForthedecompositionofGaussianVaR,theestimatedmeanandcovariancematrixareneeded.For
thedecompositionofmodifiedVaR,alsoestimatesofthecoskewnessandcokurtosismatricesare
needed.IfrdenotestheNx1returnvectorandmuisthemeanvector,thentheN\timesN^2co
skewnessmatrixis
m3=E[(rmu)(rmu)'%x%(r\mu)']
TheN\timesN^3cokurtosismatrixis

E[(r\mu)(r\mu)'%x%(r\mu)'%x%(r\mu)']
where%x%standsfortheKroneckerproduct.Thematricescanbeestimatedthroughthefunctions
skewness.MMandkurtosis.MM.MoreefficientestimatorshavebeenproposedbyMartelliniand
Ziemann(2007)andwillbeimplementedinthefuture.
AsdiscussedamongothersinCont,DeguestandScandolo(2007),itisimportantthattheestimation
oftheVaRmeasureisrobusttosingleoutliers.ThisisespeciallythecaseformodifiedVaRandits
decomposition,sincetheyusehigherordermoments.Bydefault,theportfoliomomentsareestimated
bytheirsamplecounterparts.Ifclean="boudt"thenthe1pmostextremeobservationsarewinsorized
iftheyaredetectedasbeingoutliers.Formoreinformation,seeBoudt,PetersonandCroux(2008)
andReturn.clean.Ifyourdataconsistofreturnsforhighlyilliquidassets,thenclean="geltner"may
bemoreappropriatetoreducedistortioncausedbyautocorrelation,seeReturn.Geltnerfordetails.
EpperleinandSmillie(2006)introducedanonparametrickernelestimatorforcomponentrisk
contributions,whichisavailableviamethod="kernel"andportfolio_method="component".
MarginalVaR
Differentpaperscallthisdifferentthings.IntheDentonandJayaramanpaperreferencedhere,this
calculationiscalledIncrementalVaR.Wehavechosenthemorecommonusageofcallingthis
differenceinVaR'sinportfolioswithouttheinstrumentandwiththeinstrumentasthedifferenceat
theMargin,thusthenameMarginalVaR.Thisisincrediblyconfusing,andhasn'tbeenresolvedin
theliteratureatthistime.SimonKeelandDavidArdia(2009)attempttoreconcilesomeofthe
definitionalissuesandaddresssomeoftheshortcomingsofthismeasureintheirworkingpapertitled
GeneralizedMarginalRisk.HopefullytheirimprovedMarginalRiskmeasuresmaybeincluded
hereinthefuture.
Note
TheoptiontoinverttheVaRmeasureshouldappeasebothacademicsandpractitioners.The
mathematicaldefinitionofVaRasthenegativevalueofaquantilewill(usually)produceapositive
number.PractitionerswillarguethatVaRdenotesaloss,andshouldbeinternallyconsistentwiththe
quantile(anegativenumber).Fortablesandcharts,differentpreferencesmayapplyforclarityand
compactness.Assuch,weprovidetheoption,andsetthedefaulttoTRUEtokeepthereturn
consistentwithpriorversionsofPerformanceAnalytics,butmakenovaluejudgementonwhich
approachispreferable.
TheprototypeoftheunivariateCornishFisherVaRfunctionwascompletedbyProf.Diethelm
Wuertz.AllcorrectionstothecalculationanderrorhandlingarethefaultofBrianPeterson.
Author(s)
BrianG.PetersonandKrisBoudt
References
Boudt,Kris,Peterson,Brian,andChristopheCroux.2008.Estimationanddecompositionofdownside
riskforportfolioswithnonnormalreturns.2008.TheJournalofRisk,vol.11,79103.
Cont,Rama,Deguest,RomainandGiacomoScandolo.Robustnessandsensitivityanalysisofrisk
measurementprocedures.FinancialEngineeringReportNo.200706,ColumbiaUniversityCenterfor
FinancialEngineering.
DentonM.andJayaraman,J.D.Incremental,Marginal,andComponentVaR.Sunguard.2004.

Epperlein,E.,Smillie,A.CrackingVaRwithkernels.RISK,2006,vol.19,7074.
Gouriroux,Christian,Laurent,JeanPaulandOlivierScaillet.Sensitivityanalysisofvalueatrisk.
JournalofEmpiricalFinance,2000,Vol.7,225245.
Keel,SimonandArdia,David.Generalizedmarginalrisk.AerisCAPITALdiscussionpaper.
LaurentFavreandJoseAntonioGaleano.MeanModifiedValueatRiskOptimizationwithHedge
Funds.JournalofAlternativeInvestment,Fall2002,v5.
Martellini,Lionel,andVolkerZiemann.ImprovedForecastsofHigherOrderComomentsand
ImplicationsforPortfolioSelection.2007.EDHECRiskandAssetManagementResearchCentre
workingpaper.
ReturntoRiskMetrics:EvolutionofaStandard
http://www.riskmetrics.com/publications/techdocs/r2rovv.html
Zangari,Peter.AVaRMethodologyforPortfoliosthatincludeOptions.1996.RiskMetricsMonitor,
FirstQuarter,412.
SeeAlso
SharpeRatio.modified
chart.VaRSensitivity
VaR.gpd
VaR.norm
VaR.backtest
Return.clean

Examples
data(edhec)
#firstdonormalVaRcalc
VaR(edhec,p=.95,method="historical")
#nowuseGaussian
VaR(edhec,p=.95,method="gaussian")
#nowusemodifiedCornishFishercalctotakenonnormaldistributionintoaccount
VaR(edhec,p=.95,method="modified")
#nowusep=.99
VaR(edhec,p=.99)
#ortheequivalentalpha=.01
VaR(edhec,p=.01)
#nowwithoutlierssquished
VaR(edhec,clean="boudt")
#addComponentVaRfortheequalweightedportfolio
VaR(edhec,clean="boudt",portfolio_method="component")

[PackagePerformanceAnalyticsversion0.9.95Index]

Вам также может понравиться