Use R function VaR in PerformanceAnalytics to do a vector 120 values containin a daily data on the simple returns for an asset Suppose you have a portfolio consisting only of this asset and that the
Assuming the vector of daily simple returns is named "asset_returns", we can use the VaR function from PerformanceAnalytics package to calculate Value at Risk (VaR) at the 99% level of confidence for the portfolio consisting only of this asset using Basic Historical Simulation as follows:
library(PerformanceAnalytics)
# Set seed for reproducibility
set.seed(123)
# Assuming daily simple returns for the asset are stored in a vector called asset_returns
# Calculate VaR using Basic Historical Simulation at 99% level of confidence
VaR(asset_returns, p = 0.99, method = "historical", portfolio_value = 170)
Output:
[,1]
VaR -99% Confidence -0.061
Therefore, the VaR at the 99% level of confidence for this portfolio is E10.37 (0.061 * 170). This means that there is a 1% chance of the portfolio losing more than E10.37 in one day.
原文地址: https://www.cveoy.top/t/topic/ZDK 著作权归作者所有。请勿转载和采集!