[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-sig-finance
Subject:    Re: [R-SIG-Finance] performance attribution output
From:       Yang Lu <Yang.Lu () williams ! edu>
Date:       2013-06-06 2:41:45
Message-ID: 201306060241.000059 () miram7700b ! williams ! edu
[Download RAW message or body]

Hi Roger, 

The last part of the summary output '$Aggregate' comes from the returns method in the \
package. There are two parts (in a list) in the returns output. The '$Aggregate' is \
the second part. To save it as a data.frame, you can do the following:

> df = as.data.frame(returns(br.single)[[2]])

To see the source code from R, 

> getMethods("summary")
> getMethods("returns")

Hope this helps. Please let me know if you have any other questions,

Best,
Yang

Yang Lu '14
SU 2896  Paresky Center
Williams College, MA
(413)884-4847


---- Original message ----
> Date: Wed, 5 Jun 2013 20:17:17 +0000
> From: r-sig-finance-bounces@r-project.org (on behalf of "Bos, Roger" \
>                 <roger.bos@rothschild.com>)
> Subject: [R-SIG-Finance] performance attribution output  
> To: "r-sig-finance@r-project.org" <r-sig-finance@r-project.org>
> 
> I have been trying out the performance attribution package and find it very \
> interesting, but I can't figure out how to get the output into a data.frame or \
> other object that would make it easy for me to store it.  Here is some example \
> code: 
> library(pa)
> data(jan)
> br.single <- brinson(x = jan, date.var = "date", cat.var = "sector", bench.weight = \
> "benchmark", portfolio.weight = "portfolio", ret.var = "return") summary(br.single)
> 
> Running this example will produce the following output (which looks better in R \
> than it does here) 
> Period:                              2010-01-01
> Methodology:                         Brinson
> Securities in the portfolio:         200
> Securities in the benchmark:         1000
> 
> Exposures 
> Portfolio Benchmark     Diff
> Energy          0.085    0.2782 -0.19319
> Materials       0.070    0.0277  0.04230
> Industrials     0.045    0.0330  0.01201
> ConDiscre       0.050    0.0188  0.03124
> ConStaples      0.030    0.0148  0.01518
> HealthCare      0.015    0.0608 -0.04576
> Financials      0.370    0.2979  0.07215
> InfoTech        0.005    0.0129 -0.00787
> TeleSvcs        0.300    0.1921  0.10792
> Utilities       0.030    0.0640 -0.03399
> 
> Returns 
> $`Attribution by category in bps`
> Allocation Selection Interaction
> Energy         110.934    -37.52      26.059
> Materials      -41.534      0.48       0.734
> Industrials      0.361      1.30       0.473
> ConDiscre      -28.688     -4.23      -7.044
> ConStaples       5.467     -3.59      -3.673
> HealthCare      -6.692     -4.07       3.063
> Financials     -43.998     70.13      16.988
> InfoTech        -3.255     -5.32       3.255
> TeleSvcs       -23.106     41.55      23.348
> Utilities       16.544     83.03     -44.108
> Total          -13.966    141.77      19.095
> 
> $Aggregate
> 2010-01-01
> Allocation Effect    -0.00140
> Selection Effect      0.01418
> Interaction Effect    0.00191
> Active Return         0.01469
> 
> My question is, how can I, say, save the $Aggregate output into a data.frame?  I \
> have been trying to read about S4 objects, but I am still not able to figure this \
> out.  As long as I am asking, could anyone tell me how to see the code behind the \
> "summary" function being used here?  The following is not very enlightening: 
> > showMethods("summary", classes="brinson")
> Function: summary (package base)
> object="brinson"
> 
> Thanks in advance for any help!
> 
> _______________________________________________
> R-SIG-Finance@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.

_______________________________________________
R-SIG-Finance@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic