[R-SIG-Finance] Portfolio Attributino example with one common benchmark

Bos, Roger roger.bos at rothschild.com
Wed Nov 9 18:48:57 CET 2016


The help shows an example with one benchmark for each asset:

    library(PortfolioAttribution)
    data(attrib)
    Attribution(Rp = attrib.returns[, 1:10],
      wp = attrib.weights[1, ],
      Rb = attrib.returns[, 11:20],
      wb = attrib.weights[2, ],
      method = "top.down",
      linking = "carino")

I tried to create modify the example to use one benchmark, as the following error message hints is possible:

Error in Attribution(Rp = attrib.returns[, 1:10], wp = attrib.weights[1,  :
  Please use benchmark xts that has columns with benchmarks for each
            asset or one common benchmark for all assets

But this is not working, giving the following error:

   Attribution(Rp = attrib.returns[, 1:10],
      wp = attrib.weights[1, ],
      Rb = attrib.returns[, 11],
      wb = 1,
      method = "top.down",
      linking = "carino")

Error in checkData(R, method = "xts") :
  The data cannot be converted into a time series.  If you are trying to pass in names from a data object with one column, you should use the form 'data[rows, columns, drop = FALSE]'.  Rownames should have standard date formats, such as '1985-03-15'.

And for completeness, drop=FALSE  does not fix the error:

    Attribution(Rp = attrib.returns[, 1:10],
      wp = attrib.weights[1, ],
      Rb = attrib.returns[, 11, drop=FALSE],
      wb = 1,
      method = "top.down",
      linking = "carino")

Could anyone please show me how to do this?

Thanks, Roger




This message and any attachments are for the intended recipient’s use only. This message may contain confidential, proprietary or legally privileged information. No right to confidential or privileged treatment of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately notify the sender by e-mail, delete the message, any attachments and all copies from your system and destroy any hard copies. You must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message or any attachments if you are not the intended recipient.






More information about the R-SIG-Finance mailing list