rc: Return Contribution

View source: R/rc.R

rcR Documentation

Return Contribution

Description

Return contribution of portfolio segments.

Usage

rc(R, weights, timestamp, segments = NULL,
   R.bm = NULL, weights.bm = NULL,
   method = "contribution",
   linking.method = NULL,
   allocation.minus.bm = TRUE,
   tol = sqrt(.Machine$double.eps))

Arguments

R

returns: a numeric matrix

weights

the segment weights: a numeric matrix. weights[i, j] must correspond to R[i, j]

timestamp

character or numeric

segments

character. If missing, column names of R or of weights are used (if they are not NULL).

method

a string; default is contribution

linking.method

NULL or a string. Currently supported are geometric{0,1,0.5} and logarithmic. See Examples.

allocation.minus.bm

logical

tol

numeric: weights whose absolute value is below tol are considered zero and not used for computations. Ignored if NA.

If portfolio returns are to be compared against benchmark returns, benchmark returns and weights must be supplied:

R.bm

benchmark returns: a numeric matrix

weights.bm

the benchmark weights of segments: a numeric matrix. weights.bm[i, j] must correspond to R.bm[i, j]

Details

The function computes segment contribution, potentially over time. Returns and weights must be arranged in matrices, with rows corresponding to time periods and columns to portfolio segments. If weights and R are atomic vectors, then they are interpreted as cross-sectional weights/returns for a single period, i.e. they are handled like row vectors.

Weights can be missing, in which case R is assumed to already comprise segment returns.

Note that the segment contributions need not come from asset classes; the computation works for any additive single-period decomposition of portfolio returns.

Value

A list of two components:

period_contributions

a data.frame of single-period contributions, sorted in time

total_contributions

a numeric vector

Author(s)

Enrico Schumann

References

David R. Cariño (1999). Combining Attribution Effects Over Time. Journal of Performance Measurement. 3 (4), 5–14.

Jon A. Christopherson and David R. Cariño and Wayne E. Ferson (2009), Portfolio Performance Measurement and Benchmarking, McGraw-Hill.

Feibel, Bruce (2003), Investment Performance Measurement, Wiley.

http://enricoschumann.net/R/packages/PMwR/manual/PMwR.html#return-contribution

See Also

returns

Examples

weights <- rbind(c( 0.25, 0.75),
                 c( 0.40, 0.60),
                 c( 0.25, 0.75))

R <- rbind(c( 1  ,    0),
           c( 2.5, -1.0),
           c(-2  ,  0.5))/100

rc(R, weights, segment = c("equities", "bonds"))



## EXAMPLE of Christopherson et al., ch 19
weights <- cbind(stocks = c(0.5,  0.55),
                 bonds  = c(0.5, 0.45))
##      stocks bonds
## [1,]   0.50  0.50
## [2,]   0.55  0.45

R <- cbind(stocks = c(.4, 0.1),
           bonds  = c(.1, 0.2))
##      stocks bonds
## [1,]    0.4   0.1
## [2,]    0.1   0.2

## ==> contributions grow at portfolio rate-of-return
rc(R, weights, linking.method =  "geometric1")

## ==> contributions are made on top of current portfolio-value
rc(R, weights, linking.method =  "geometric0")

## ==> mixture
rc(R, weights, linking.method =  "geometric0.5")



## EXAMPLE https://quant.stackexchange.com/questions/36520/how-to-calculate-the-annual-contribution-of-a-fund-to-a-portfolio-of-funds/36530#36530

weights <- rbind(c( 0.5, 0.5),
                 c( 0.5, 0.5))

R <- rbind(c( 10,   0),
           c( 0 ,  10))/100


rc(R, weights, segment = c("F1", "F2"), timestamp = 1:2,
   linking.method = "geometric1")
## ==> F1 contributed first, and so gets a higher total
##     contribution

rc(R, weights, segment = c("F1", "F2"), timestamp = 1:2,
   linking.method = "geometric0")
## ==> F2 contributed later, and so gets a higher total
##     contribution because it started off a higher base
##     value




## contribution for btest:
##   run a portfolio 10% equities, 90% bonds
P <- as.matrix(merge(DAX, REXP, by = "row.names")[, -1])
(bt <- btest(prices = list(P),
            signal = function() c(0.1, 0.9),
            convert.weights = TRUE,
            initial.cash = 100))

W <- bt$position*P/bt$wealth
rc(returns(P)*W[-nrow(W), ])$total_contributions

enricoschumann/PMwR documentation built on April 13, 2024, 12:18 p.m.