Learn R Programming

pa (version 1.2-4)

regress: 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")

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.

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.

Author

Yang Lu Yang.Lu@williams.edu

Examples

Run this code

## 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)

Run the code above in your browser using DataLab