portvol.Bayes: Portfolio Volatility and Contribution to Total Volatility...

Description Usage Arguments Details Value See Also Examples

View source: R/portvol.Bayes.R

Description

portvol.Bayes computes portfolio volatility of a given portfolio for specific weight and time period. mctr.Bayes & cctr.Bayes computes the Marginal Contribution to Total Risk (MCTR) & Conditional Contribution to Total Risk (CCTR) for the given portfolio.

Usage

1
2
3
4
5
6
7
8
portvol.Bayes(tickers, weights = rep(1,length(tickers)),
              start, end, data, sim.size = 1000)

mctr.Bayes(tickers, weights = rep(1,length(tickers)),
              start, end, data, sim.size = 1000)

cctr.Bayes(tickers, weights = rep(1,length(tickers)),
              start, end, data, sim.size = 1000)

Arguments

tickers

A character vector of ticker names of companies in the portfolio.

weights

A numeric vector of weights assigned to the stocks corresponding to the ticker names in tickers. The sum of the weights need not to be 1 or 100 (in percentage). By default, equal weights to all the stocks are assigned (i.e., by rep(1, length(tickers))).

start

Start date in the format "yyyy-mm-dd".

end

End date in the format "yyyy-mm-dd".

data

A zoo object whose rownames are dates and colnames are ticker names of the companies. Values of the table corresponds to the daily returns of the stocks of corresponding ticker names.

sim.size

Simulation size, default 1000.

Details

As any portfolio can be considered as bag of p-many risky assets, it is important to figureout how these assets contributes to total volatility risk of the portfolio. We consider an investment period and suppose rj denote return to source j for the same period, where j = 1, 2,…, p. The portfolio return over the period is

Rp = ∑ wj rj , j = 1, 2,…, p

where wj is the portfolio exposure to the asset j, i.e., portfolio weight, such that wj ≥ 0 and ∑ wj = 1. Portfolio manager determines the size of wj at the beginning of the investment period. Portfolio volatility is defined as

σ = √(w' Σ w)

where w = (w1, w2,…, wp) and Σ being the variance-covariance matrix of the assets in the portfolio. S is the sample portfolio-covariance matrix. If

S ~ Wishart(n-1,Σ)

and prior distribution on Σ is

Σ ~ Inv-Wishart(n_0,Ψ)

Then posterior distribution is

Σ | S ~ Inv-Wishart(n_0+n-1,Ψ+S)

For more detail, see portvol, mctr, cctr

Value

portvol

A numeric value. Volatility of a given portfolio in percentage.

mctr

A named numeric vector of Marginal Contribution to Total Risk (MCTR) in percentage with names being the ticker names.

cctr

A named numeric vector of Conditional Contribution to Total Risk (CCTR) in percentage with names being the ticker names.

See Also

zoo

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
data(SnP500Returns)

# consider the portfolio containing the first 4 stocks
pf <- colnames(SnP500Returns)[1:4]

st <- "2013-01-01" # start date
en <- "2013-01-31" # end date

# suppose the amount of investments in the above stocks are
# $1,000, $2,000, $3,000 & $1,000 respectively
wt <- c(1000,2000,3000,1000) # weights

# portfolio volatility for the portfolio 'pf' with equal (default) weights
pv1 <- portvol(pf, start = st, end = en,
                data = SnP500Returns)

# portfolio volatility for the portfolio 'pf' with weights as 'wt'
pv2 <- portvol(pf, weights = wt, start = st, end = en,
                data = SnP500Returns)

# similarly,
# mctr for the portfolio 'pf' with weights as 'wt'
mc <- mctr(pf, weights = wt, start = st, end = en,
            data = SnP500Returns)

# cctr for the portfolio 'pf' with weights as 'wt'
cc <- cctr(pf, weights = wt, start = st, end = en,
            data = SnP500Returns)

sum(cc) == pv2
# note that, sum of the cctr values is the portfolio volatility

Example output

[1] TRUE

PortRisk documentation built on May 2, 2019, 7:22 a.m.