R Under development (unstable) (2023-08-20 r84995 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ## summary.test.R > ## Yang Lu Yang.Lu@williams.edu > > library(pa) > > ## data(jan) > ## b1 <- brinson(x = jan) > ## truth <- summary(b1) > ## data(quarter) > ## b2 <- brinson(x = quarter) > ## truth.multi <- summary(b2) > ## save(truth, truth.multi, file = "summary.test.RData") > > > load("summary.test.RData") > > ## Single-period > > data(jan) > b1 <- brinson(x = jan) > result <- summary(b1) 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 > stopifnot(all.equal(result, truth)) > > ## Multi-period > > data(quarter) > b2 <- brinson(x = quarter) > result.multi <- summary(b2) Period starts: 2010-01-01 Period ends: 2010-03-01 Methodology: Brinson Avg securities in the portfolio: 200 Avg securities in the benchmark: 1000 Exposures $Portfolio 2010-01-01 2010-02-01 2010-03-01 Energy 0.085 0.085 0.085 Materials 0.070 0.070 0.070 Industrials 0.045 0.045 0.045 ConDiscre 0.050 0.050 0.050 ConStaples 0.030 0.030 0.030 HealthCare 0.015 0.015 0.015 Financials 0.370 0.370 0.370 InfoTech 0.005 0.005 0.005 TeleSvcs 0.300 0.300 0.300 Utilities 0.030 0.030 0.030 $Benchmark 2010-01-01 2010-02-01 2010-03-01 Energy 0.2782 0.2667 0.26985 Materials 0.0277 0.0354 0.02493 Industrials 0.0330 0.0357 0.03809 ConDiscre 0.0188 0.0196 0.01676 ConStaples 0.0148 0.0137 0.01381 HealthCare 0.0608 0.0590 0.07144 Financials 0.2979 0.2943 0.30752 InfoTech 0.0129 0.0119 0.00616 TeleSvcs 0.1921 0.1983 0.19225 Utilities 0.0640 0.0656 0.05919 $Diff 2010-01-01 2010-02-01 2010-03-01 Energy -0.19319 -0.1817 -0.18485 Materials 0.04230 0.0346 0.04507 Industrials 0.01201 0.0093 0.00691 ConDiscre 0.03124 0.0304 0.03324 ConStaples 0.01518 0.0163 0.01619 HealthCare -0.04576 -0.0440 -0.05644 Financials 0.07215 0.0757 0.06248 InfoTech -0.00787 -0.0069 -0.00116 TeleSvcs 0.10792 0.1017 0.10775 Utilities -0.03399 -0.0356 -0.02919 Returns $Raw 2010-01-01 2010-02-01 2010-03-01 Allocation -0.0014 0.0062 0.0047 Selection 0.0142 0.0173 -0.0154 Interaction 0.0019 -0.0072 -0.0089 Active Return 0.0147 0.0163 -0.0196 $Aggregate 2010-01-01, 2010-03-01 Allocation 0.0092 Selection 0.0173 Interaction -0.0139 Active Return 0.0127 > stopifnot(all.equal(result.multi, truth.multi)) > > > proc.time() user system elapsed 1.40 0.26 1.62