Risk Analysis with Copula

library(PortRisk)
# 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
                 , data = SnP500Returns
                 , start = "2013-01-01"
                 , end = "2013-01-31"
                 , sim.size = 1000
                 , df=15)
fit$Volatility
##         weight        vol      mctr       cctr
## AAPL 0.2137888 0.03505336 2.4552664 0.52490840
## IBM  0.0000000 0.01169305 0.7533587 0.00000000
## INTC 0.0747648 0.01948613 0.9964611 0.07450022
## MSFT 0.7114464 0.01194353 0.9379433 0.66729642
fit$`Portfolio Volatility`
## [1] 1.266705
fit$`Portfilio VaR`
##        1%        5% 
## -3.136417 -1.791881
fit$`Total Portfolio Value`
## NULL