portfolio_cor: Calculate pairwise asset correlation vs. a portfolio

Description Usage Arguments Details Value

View source: R/portfolio_cor.R


Calculates the pairwise correlation between all assets in a universe vs. a portfolio of assets.


portfolio_cor(rets, portassets = colnames(rets)[1], maxwtsvec = 1,
  port_size = length(portassets) + 1, on = "days")



An xts matrix of asset returns that include all assets in the analysis universe, the latter being a superset of the portfolio assets. The correlation is calculated over all returns provided by rets.


A character vector containing the names of assets in the portfolio. Must contain at least one name.


Either an ordered or named numeric vector containing the relative weight of each asset in the universe or a single number. The sum of all weights does not need to equal one (it would normally exceed one), as this is used for relative weights. If a single number (for example set to 1) then, this result in equal weights.


The number of assets in the final portfolio. This is used to compute the weight of each asset when a test portfolio is built. The test portfolio includes the portassets + one asset under test. Default is length(portassets) + 1, but this can be overridden to a larger value if the final portfolio size is known.


Specifies the returns period to use to calculate the correlation. Default is "days", but can also be "weeks" or "months" for weekly and montly correlations. The portfolio is also rebalanced at that same frequency.


The portfolio must comprise assets in the universe otherwise an error will result. A named vector is return with the correlation of each asset not in the portfolio vs. the portfolio. The portfolio may be built of equal weights or a set of predefined weights, as specified by maxwtsvec.


Returns a named vector of correlation values for each asset vs. the given portfolio.

jeanmarcgp/ResilientPortfolio documentation built on April 8, 2018, 5:43 p.m.