Package 'pa'

Title: Performance Attribution for Equity Portfolios
Description: It provides tools for conducting performance attribution for equity portfolios. The package uses two methods: the Brinson method and a regression-based analysis.
Authors: Yang Lu [aut, cre], David Kane [aut]
Maintainer: Yang Lu <[email protected]>
License: GPL-2
Version: 1.2-4
Built: 2024-11-13 03:43:11 UTC
Source: https://github.com/cran/pa

Help Index


Brinson analysis for equity portfolios

Description

The pa package provides facilities for conducting performance attribution based on the Brinson model and the regression approach.

Author(s)

Yang Lu <[email protected]> David Kane <[email protected]>

Maintainer: Yang Lu <[email protected]>


Creating an object of either class brinson or class brinsonMulti

Description

Conduct Brinson analysis for equity portfolio attribution. Create a class object of either brinson for a single-period data set or brinsonMulti for a multi-period data set.

Usage

brinson(x, date.var = "date", cat.var = "sector", bench.weight =
"benchmark", portfolio.weight = "portfolio", ret.var = "return")

Arguments

x

A data frame containing the data from which brinson analysis will be conducted.

date.var

A character vector which indicates the name of the column in x to be used as a date for each observation. If the unique number of levels of date.var is one, a class object of brinson will be formed. If it is more than one, a class object of brinsonMulti will be formed.

cat.var

A character vector which indicates the name of the column in x to be used as categorical variables.

bench.weight

A character vector which indicates the name of the column or columns in x to be used as benchmark weight.

portfolio.weight

A character vector which indicates the name of the column or columns in x to be used as portfolio weight.

ret.var

A character vector which indicates the name of the column in x to be used as return variable.

Value

Return an object of class brinson when there is only one unique date in the data frame x. Otherwise, an object of class brinsonMulti is returned.

Author(s)

Yang Lu [email protected]

Examples

## Single-period brinson analysis

data(jan)

p1 <- brinson(x = jan, date.var = "date", cat.var = "sector",
bench.weight = "benchmark", portfolio.weight = "portfolio", ret.var =
"return")

summary(p1)

## Multi-period brinson analysis

data(quarter)

p2 <- brinson(x = quarter, date.var = "date", cat.var = "sector",
bench.weight = "benchmark", portfolio.weight = "portfolio", ret.var =
"return")

summary(p2)

Class "brinson"

Description

Class brinson holds the results of an original portfolio, its benchmark, and the results of Brinson analysis of a single-period portfolio.

Slots

date.var:

Object of class "character" storing the date variable name.

cat.var:

Object of class "character" storing the name(s) of the categories in the Brinson analysis.

bench.weight:

Object of class "character" storing the name of the benchmark weight variable.

portfolio.weight:

Object of class "character" storing the name of the portfolio weight variable in the universe data frame.

ret.var:

Object of class "character" storing the name of the return variable.

weight.port:

Object of class "array" storing the weights of the input category of the portfolio.

weight.bench:

Object of class "array" storing the weights of the input category of the benchmark.

ret.port:

Object of class "array" storing the returns of the input category of the portfolio.

ret.bench:

Object of class "array" storing the returns of the input category of the benchmark.

q4:

Object of class "numeric" storing the information of the 4th quadrant in the brinson matrix. It refers to return of the benchmark portfolio.

q3:

Object of class "numeric" storing the information of the 3rd quadrant in the brinson matrix. It refers to return of the portfolio with benchmark sector weights and portfolio sector returns.

q2:

Object of class "numeric" storing the information of the 2nd quadrant in the brinson matrix. It refers to return of the portfolio with portfolio sector weights and benchmark sector returns.

q1:

Object of class "numeric" storing the information of the 1st quadrant in the brinson matrix. It refers to return of the original portfolio.

universe:

Object of class "data.frame" storing the data frame on which the Brinson attribution is based.

Methods

show

signature(object = "brinson"). Summarize the essential information about the portfolio.

summary

signature(object = "brinson"). Summarize the portfolio and the Brinson attribution.

exposure

signature(object = "brinson"). Calculate and display the exposure of the input category of a portfolio.

returns

signature(object = "brinson"). Calculate the contribution of various effects based on the Brinson analysis.

plot

signature(x = "brinson", var = "character", type = "character"). Plot the exposure or the return of a portfolio class object.

Author(s)

Yang Lu [email protected]

Examples

data(jan)

## Single-period brinson analysis

p1 <- brinson(x = jan, date.var = "date", cat.var = "sector",
    bench.weight = "benchmark", portfolio.weight = "portfolio", ret.var
    = "return")

summary(p1)

exposure(p1, var = "sector")

returns(p1)

plot(p1, var = "sector", type = "exposure")

plot(p1, var = "sector", type = "return")

Class "brinsonMulti"

Description

Class "brinsonMulti" holds the results of an original portfolio, its benchmark, and the results of brinson analysis of a multi-period portfolio.

Slots

date.var:

Object of class character storing all the dates occurred in the universe data frame.

cat.var:

Object of class character storing the variable name of the categories in the universe data frame.

bench.weight:

Object of class character storing the benchmark weight variable name in the universe data frame.

portfolio.weight:

Object of class character storing the portfolio weight variable name in the universe data frame.

ret.var:

Object of class character storing the return variable name in the universe data frame.

weight.port:

Object of class matrix storing the sector weights of the original portfolio.

weight.bench:

Object of class matrix storing the sector weights of the benchmark portfolio.

ret.port:

Object of class matrix storing the sector returns of the original portfolio.

ret.bench:

Object of class matrix storing the sector returns of the benchmark portfolio.

brinson.mat:

Object of class matrix storing the information of the brinson matrix across period.

universe:

Data frame storing the universe environment.

Methods

show

signature(object = "brinson"). Summarize the essential information about the portfolio.

summary

signature(object = "brinson"). Summarize the portfolio and the brinson analysis.

exposure

signature(object = "brinson"). Calculate and display the sector exposure of a portfolio.

returns

signature(object = "brinson"). Calculate the contribution of various effects based on the brinson model.

plot

signature(x = "brinson", var = "character", type = "character"). Plot the exposure or the return of a portfolio class object.

Author(s)

Yang Lu [email protected]

Examples

## Multi-period brinson analysis
data(quarter)
p2 <- brinson(x = quarter, date.var = "date", cat.var = "sector",
bench.weight = "benchmark", portfolio.weight = "portfolio", ret.var = "return")
summary(p2)

Calculate and display the sector exposure of a portfolio

Description

Calculate and display the exposure of a portfolio based on any given category. Both the portfolio and benchmark exposures are displayed.

Usage

exposure(object, var, ...)

Arguments

object

An object of either class brinson or class brinsonMulti.

var

Any user-defined category whose exposure is to be displayed.

...

Other options.

Value

Return a matrix if the input object is of class brinson with portfolio, benchmark exposures, and their differences, and return a list if the input object is of class brinsonMulti including portfolio, benchmark exposures, and their differences for each period.

If the input var is categorical, it will show exposure of each sub-groups within the category. If the input var is continuous, it will show exposure of the category in quintiles.

Author(s)

Yang Lu [email protected]

Examples

## Single-period brinson analysis

data(jan)

p1 <- brinson(x = jan, date.var = "date", cat.var = "sector",
    bench.weight = "benchmark", portfolio.weight = "portfolio", ret.var
    = "return")

exposure(p1, var = "size")

## Multi-period brinson analysis

data(quarter)

p2 <- brinson(x = quarter, date.var = "date", cat.var = "sector",
bench.weight = "benchmark", portfolio.weight = "portfolio", ret.var =
"return")

exposure(p2, var = "sector")

Edited Barra data set in Jan. 2010.

Description

A modified version of the data set based on MSCI Barra GEM2 data set in year 2010.

Usage

data(jan)

Format

A data frame with 3000 observations on the following 15 variables.

barrid

barra id of a security

name

name of a security

return

a numeric vector

date

a Date

sector

an ordered factor with levels Energy < Materials < Industrials < ConDiscre < ConStaples < HealthCare < Financials < InfoTech < TeleSvcs < Utilities

momentum

a numeric vector

value

a numeric vector

size

a numeric vector

growth

a numeric vector

cap.usd

a numeric vector

yield

a numeric vector

country

a factor with levels ARE ARG AUS AUT BEL BHR BRA CAN CHE CHL CHN CHX COL CZE DEU DNK EGY ESP FIN FRA GBR GRC HKG HUN IDN IND IRL ISR ITA JOR JPN KOR KWT MAR MEX MYS NLD NOR NZL OMN PAK PER PHL POL PRT QAT RUS SAU SGP SWE THA TUR TWN USA ZAF

currency

a factor with levels AREC ARGC AUSC BHRC BRAC CANC CHEC CHLC CHNC COLC CZEC DNKC EGYC EMUC GBRC HKGC HUNC IDNC INDC ISRC JORC JPNC KORC KWTC MARC MEXC MYSC NORC NZLC OMNC PAKC PERC PHLC POLC QATC RUSC SAUC SGPC SWEC THAC TURC TWNC USAC ZAFC

portfolio

a numeric vector

benchmark

a numeric vector

Details

A subset of the data set year. jan contains all the information necessary to conduct a single-period Brinson analysis. date.var, cat.var, and return identify the columns containing the date, the factor to be analyzed, and the return variable, respectively. bench.weight and portfolio.weight specify the name of the benchmark weight column and that of the portfolio weight column in the data frame.

Examples

data(jan)
head(jan)

Plot the exposure or the return of a brinson, brinsonMulti, regression or regressionMulti object

Description

This method plots the exposure or return comparison graph of a portfolio and its benchmark based on a portfolio class object.

Methods

signature(x = "ANY", y = "ANY")

The usual plot method from the base package.

signature(x = "brinsonMulti", y = "missing")

The x must be a brinsonMulti class object.

The var can be used to specified the factor whose exposure to be shown. sector is the default setting where the exposure comparison graph based on sectors will be shown.

The type can be either exposure or return. The default setting is exposure. When the type is set to return, the var option is no longer in use.

signature(x = "brinson", y = "missing")

The x must be a brinson class object.

The var can be used to specified the factor whose exposure to be shown. sector is the default setting where the exposure comparison graph based on sectors will be shown.

The type can be either exposure or return. The default setting is exposure. When the type is set to return, the var option is no longer in use.

signature(x = "regressionMulti", y = "missing")

The x must be a regressionMulti class object.

The var can be used to specified the factor whose exposure to be shown. sector is the default setting where the exposure comparison graph based on sectors will be shown.

The type can be either exposure or return. The default setting is exposure. When the type is set to return, the var option is no longer in use.

signature(x = "regression", y = "missing")

The x must be a regression class object.

The var can be used to specified the factor whose exposure to be shown. sector is the default setting where the exposure comparison graph based on sectors will be shown.

The type can be either exposure or return. The default setting is exposure. When the type is set to return, the var option is no longer in use.


Edited Barra data set for Q1, 2010.

Description

An edited version of the data set based on GEM2 data set in year 2010.

Usage

data(quarter)

Format

A data frame with 9000 observations on the following 15 variables.

barrid

barra id for a security

name

name of a security

return

a numeric vector

date

a Date

sector

an ordered factor with levels Energy < Materials < Industrials < ConDiscre < ConStaples < HealthCare < Financials < InfoTech < TeleSvcs < Utilities

momentum

a numeric vector

value

a numeric vector

size

a numeric vector

growth

a numeric vector

cap.usd

a numeric vector

yield

a numeric vector

country

a factor with levels ARE ARG AUS AUT BEL BHR BRA CAN CHE CHL CHN CHX COL CZE DEU DNK EGY ESP FIN FRA GBR GRC HKG HUN IDN IND IRL ISR ITA JOR JPN KOR KWT MAR MEX MYS NLD NOR NZL OMN PAK PER PHL POL PRT QAT RUS SAU SGP SWE THA TUR TWN USA ZAF

currency

a factor with levels AREC ARGC AUSC BHRC BRAC CANC CHEC CHLC CHNC COLC CZEC DNKC EGYC EMUC GBRC HKGC HUNC IDNC INDC ISRC JORC JPNC KORC KWTC MARC MEXC MYSC NORC NZLC OMNC PAKC PERC PHLC POLC QATC RUSC SAUC SGPC SWEC THAC TURC TWNC USAC ZAFC

portfolio

a numeric vector

benchmark

a numeric vector

Details

A subset of the data set year. quarter contains all the information necessary to conduct a multi-period Brinson analysis. date.var, cat.var, and return identify the columns containing the date, the factor to be analyzed, and the return variable, respectively. bench.weight and portfolio.weight specify the name of the benchmark weight column and that of the portfolio weight column in the data frame.

Examples

data(quarter)
head(quarter)

Create an object of either class regress or class regressMulti

Description

Conduct regression analysis for equity portfolio attribution. Create an object of either class regression for a single-period data set or class regressionMulti for a multi-period data set.

Usage

regress(x, date.var = "date", ret.var = "return", reg.var = c("sector",
"value", "growth"), benchmark.weight = "benchmark", portfolio.weight =
"portfolio")

Arguments

x

A data frame containing the data from which regression analysis will be conducted.

date.var

A character vector which indicates the name of the column in x to be used as a date for each observation. If the unique number of levels of date.var is one, a class object of regression will be formed. If it is more than one, a class object of regressionMulti will be formed.

ret.var

A character vector which indicates the name of the column in x to be used as the return variable.

reg.var

Input variables to be used as independent variables in the regression analysis.

benchmark.weight

A character vector which indicates the name of the column or columns in x to be used as benchmark weight.

portfolio.weight

A character vector which indicates the name of the column or columns in x to be used as portfolio weight.

Value

Return an object of class regression when there is only one unique date in the data frame x. Otherwise, an object of class regressionMulti is returned.

Author(s)

Yang Lu [email protected]

Examples

## Single-period regression analysis

data(jan)

r1 <-regress(x = jan, date.var = "date", ret.var = "return", reg.var =
c("sector", "value", "growth"), benchmark.weight = "benchmark",
portfolio.weight = "portfolio")

summary(r1)

## Multi-period regression analysis

data(quarter)

r2 <-regress(x = quarter, date.var = "date", ret.var = "return", reg.var
= c("sector", "value", "growth"), benchmark.weight = "benchmark",
portfolio.weight = "portfolio")

summary(r2)

Class "regression"

Description

Class "regression" holds the results of an original portfolio, its benchmark, and the results of regression analysis of a single-period portfolio.

Slots

date.var:

Object of class "character" storing the name of the date column in the class object.

ret.var:

Object of class "character" storing the name of the return variable.

reg.var:

Object of class "character" storing the name of the regressors.

benchmark.weight:

Object of class "character" storing the name of the benchmark weight variable.

portfolio.weight:

Object of class "character" storing the name of the portfolio weight variable in the universe dataframe.

coefficients:

Object of class "numeric" storing the estimated coefficients of the regression model.

benchmark.ret:

Object of class "matrix" storing the benchmark return of the input portfolio.

portfolio.ret:

Object of class "matrix" storing the portfolio return of the input portfolio.

act.ret:

Object of class "matrix" storing the active return of the input portfolio.

act.expo:

Object of class "numeric" storing the active exposure according to the regressors.

contrib:

Object of class "numeric" storing the contribution of the regressors according to the input.

universe:

Object of class "data.frame" storing the entire input data frame.

Methods

exposure

signature(object = "regression"): Calculate and display the exposure of the input category of a portfolio.

plot

signature(x = "regression", y = "missing"): Plot the exposure or the return of a regression class object.

returns

signature(object = "regression"): Calculate the contribution of various effects based on the regression analysis.

show

signature(object = "regression"): Summarize the essential information about the portfolio.

summary

signature(object = "regression"): Summarize the portfolio and the regression-based attribution.

Author(s)

Yang Lu [email protected]

Examples

## Single-period regression analysis

data(jan)

r1 <-regress(x = jan, date.var = "date", ret.var = "return", reg.var = c("sector",
"value", "growth"), benchmark.weight = "benchmark", portfolio.weight =
"portfolio")

summary(r1)

Class "regressionMulti"

Description

Class "regressionMulti" holds the results of an original portfolio, its benchmark, and the results of regression analysis of a multi-period portfolio.

Slots

date.var:

Object of class "character" storing the date(s) in the class object.

ret.var:

Object of class "character" storing the name of the return variable.

reg.var:

Object of class "character" storing the name of the regressors.

benchmark.weight:

Object of class "character" storing the name of the benchmark weight variable.

portfolio.weight:

Object of class "character" storing the name of the portfolio weight variable in the universe dataframe.

coefficients:

Object of class "matrix" storing the estimated coefficients of the regression model for each time period.

benchmark.ret:

Object of class "matrix" storing the benchmark return of the input portfolio for each time period.

portfolio.ret:

Object of class "matrix" storing the portfolio return of the input portfolio for each time period.

act.ret:

Object of class "matrix" storing the active return of the input portfolio for each time period.

act.expo:

Object of class "matrix" storing the active exposure according to the regressors for each time period.

contrib:

Object of class "matrix" storing the contribution of the regressors according to the input for each time period.

universe:

Object of class "list" storing the entire input data frame.

Methods

exposure

signature(object = "regressionMulti"): Calculate and display the exposure of the input category of a portfolio.

plot

signature(x = "regressionMulti", y = "missing"): Plot the exposure or the return of a regressionMulti class object.

returns

signature(object = "regressionMulti"): Calculate the contribution of various effects based on the regression analysis.

show

signature(object = "regressionMulti"): Summarize the essential information about the portfolio.

summary

signature(object = "regressionMulti"): Summarize the portfolio and the regression-based attribution.

Author(s)

Yang Lu [email protected]

Examples

## Multi-period regression analysis

data(quarter)

r2 <-regress(x = quarter, date.var = "date", ret.var = "return", reg.var = c("sector",
"value", "growth"), benchmark.weight = "benchmark", portfolio.weight =
"portfolio")

summary(r2)

Calculate the attribution results

Description

Calculate and display the attribution results. Allocation effect, selection effect, interaction, and active return are displayed for brinson analysis. Returns of user-defined input variables, portfolio return, benchmark return, and active return are shown for regression analysis.

Usage

returns(object, ...)

Arguments

object

An object of either class brinson or class brinsonMulti.

...

Other options including type which refers to the type of returns to be shown for regression analysis. They include arithmetic, geometric, and linking. The default is geometric.

Value

When the input is an object of class brinson, return a list of two matrices. The first one is the allocation, selection, and interaction for each groups in the specified category. The second matrix has 4 rows including Allocation, Selection, Interaction, and Active Return.

When the input is an object of class brinsonMulti, return a list including brison attribution for each individual period and the aggregate.

When the input is an object of class regression, return a matrix including contributions of input variables, Portfolio Return, Benchmark Return, and Active Return.

When the input is an object of class regressionMulti, return a list including regression analysis for each individual period and the aggregate.

Author(s)

Yang Lu [email protected]

Examples

## Single-period brinson analysis

data(jan)

p1 <- brinson(x = jan, date.var = "date", cat.var = "sector",
bench.weight = "benchmark", portfolio.weight = "portfolio", ret.var =
"return")

returns(p1)

## Multi-period brinson analysis

data(quarter)

p2 <- brinson(x = quarter, date.var = "date", cat.var = "sector",
bench.weight = "benchmark", portfolio.weight = "portfolio", ret.var =
"return")

returns(p2, type = "linking")

Provide a summary for Brinson or regression analysis

Description

Summarize a portfolio and its benchmark. Present the attribution information including basic portfolio information, expsosures, and returns. The input can be any of the four class objects including brinson, brinsonMulti, regression, and regressionMulti.

Usage

summary(object, ...)

Arguments

object

An object of brinson, brinsonMulti, regression or regressionMulti.

...

Other options.

Value

Return relevant information about a portfolio and its benchmark. It includes their exposures based on input categories (for Brinson analysis only) and the results of either Brinson analysis or regression analysis.

Author(s)

Yang Lu [email protected]

Examples

## Single-period brinson analysis

data(jan)

p1 <- brinson(x = jan, date.var = "date", cat.var = "sector",
    bench.weight = "benchmark", portfolio.weight = "portfolio", ret.var
    = "return")

summary(p1)

## Multi-period brinson analysis

data(quarter)

p2 <- brinson(x = quarter, date.var = "date", cat.var = "sector",
bench.weight = "benchmark", portfolio.weight = "portfolio", ret.var =
"return")

summary(p2)

A sample portfolio edited based on Barra data set in Jan. 2010.

Description

An edited version of the data set based on Barra GEM2 data set in year 2010.

Usage

data(jan)

Format

A data frame with 3000 observations on the following 6 variables.

name

name of a security

return

a numeric vector

date

a Date

sector

an ordered factor with levels Energy < Materials < Industrials < ConDiscre < ConStaples < HealthCare < Financials < InfoTech < TeleSvcs < Utilities

portfolio

a numeric vector

benchmark

a numeric vector

Details

A edited version of the data set jan. test contains all the information necessary to conduct a single-period Brinson analysis. date.var, cat.var, and return identify the columns containing the date, the factor to be analyzed, and the return variable, respectively. bench.weight and portfolio.weight specify the name of the benchmark weight column and that of the portfolio weight column in the data frame.

In the paper, we use this data set to showcase that the Brinson model is a special case of the regression approach.

In this data set, the universe of the portfolio is assumed to be the same as the benchmark.

Examples

data(test)
head(test)

Edited Barra data set in year 2010.

Description

An edited version of the data set based on Barra GEM2 data set in year 2010.

Usage

data(year)

Format

A data frame with 36000 observations on the following 15 variables.

barrid

barra id for a security

name

name of a security

return

a numeric vector

date

a Date

sector

an ordered factor with levels Energy < Materials < Industrials < ConDiscre < ConStaples < HealthCare < Financials < InfoTech < TeleSvcs < Utilities

momentum

a numeric vector

value

a numeric vector

size

a numeric vector

growth

a numeric vector

cap.usd

a numeric vector

yield

a numeric vector

country

a factor with levels ARE ARG AUS AUT BEL BHR BRA CAN CHE CHL CHN CHX COL CZE DEU DNK EGY ESP FIN FRA GBR GRC HKG HUN IDN IND IRL ISR ITA JOR JPN KOR KWT MAR MEX MYS NLD NOR NZL OMN PAK PER PHL POL PRT QAT RUS SAU SGP SWE THA TUR TWN USA ZAF

currency

a factor with levels AREC ARGC AUSC BHRC BRAC CANC CHEC CHLC CHNC COLC CZEC DNKC EGYC EMUC GBRC HKGC HUNC IDNC INDC ISRC JORC JPNC KORC KWTC MARC MEXC MYSC NORC NZLC OMNC PAKC PERC PHLC POLC QATC RUSC SAUC SGPC SWEC THAC TURC TWNC USAC ZAFC

portfolio

a numeric vector

benchmark

a numeric vector

Details

year contains all the information necessary to conduct a multi-period Brinson analysis. date.var, cat.var, and return identify the columns containing the date, the factor to be analyzed, and the return variable, respectively. bench.weight and portfolio.weight specify the name of the benchmark weight column and that of the portfolio weight column in the data frame.

Examples

data(year)
head(year)