Risk Analysis with Copula

library(PortRisk)
## Loading required package: MCMCpack
## Loading required package: coda
## Loading required package: MASS
## ##
## ## Markov Chain Monte Carlo Package (MCMCpack)
## ## Copyright (C) 2003-2016 Andrew D. Martin, Kevin M. Quinn, and Jong Hee Park
## ##
## ## Support provided by the U.S. National Science Foundation
## ## (Grants SES-0350646 and SES-0350613)
## ##
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: copula
## Loading required package: tseries
# load the data 'SnP500Returns'
data(SnP500Returns)

# consider the portfolio containing the stocks of the companies
# Apple, IBM, Intel, Microsoft
pf <- c("AAPL","IBM","INTC","MSFT")

# suppose the amount of investments in the above stocks are

# $10,000, $40,000, $20,000 & $30,000 respectively

wt <- c(10000,40000,20000,30000) # weights

# risk attribution for the portfolio 'pf' with weights 'wt'
# for the time period January 1, 2013 - January 31, 2013


fit<-risk.attrib.Copula(tickers = pf
                 , weights = wt
                 , data = SnP500Returns
                 , start = "2013-01-01"
                 , end = "2013-01-31"
                 , sim.size = 1000
                 , df=15)
fit$Volatility
##      weight        vol      mctr      cctr
## AAPL  10000 0.03505336 2.0614388 0.2061439
## IBM   40000 0.01169305 0.9297546 0.3719018
## INTC  20000 0.01948613 1.2062182 0.2412436
## MSFT  30000 0.01194353 0.9228293 0.2768488
fit$`Portfolio Volatility`
## [1] 1.096138
fit$`Portfilio VaR`
##        1%        5% 
## -2267.739 -1220.453
fit$`Total Portfolio Value`
## [1] 1e+05