Learn R Programming

portfolio (version 0.4-3)

portfolioBasic-class: Class "portfolioBasic"

Description

An object of the lightweight class "portfolioBasic" contains a data frame of weights and a data frame of supplementary information.

Arguments

Objects from the Class

Objects can be created by calls of the form new("portfolioBasic", ...).

Matched portfolios

The matching method allows one to benchmark a portfolio against a similar portfolio formed from other stocks in the universe. The universe consists of all the stocks in the data slot of original.

matching calculates a propensity score for each stock in the universe. covariates determines which attributes are used to calculate the propensity score. covariates must refer to the names of columns in the data slot of original.

Matching accepts an optional argument, method, which sets the algorithm for determining the best match for each stock. There are 2 available algorithms, "greedy" and "sample". "greedy" is the default and generates 1 matched portfolio. "sample" randomly matches each stock in original with one of the stocks in the universe. Although the matching is random, stocks in original are most likely to be matched with stocks having similar propensity scores.

n.matches is another optional argument to matching which determines the number of matched portfolios to generate. Requesting more than 1 matched portfolio. (n.matches > 1) while using greedy is not allowed. When using sample, there is no bound on n.matches.

Examples

Run this code
data(dow.jan.2005)

p <- new("portfolioBasic",
         id.var = "symbol",
         in.var = "price",
         sides = "long",
         ret.var = "month.ret",
         data = dow.jan.2005)

summary(p)

exposure(p, exp.var = c("price", "sector"))
performance(p)
contribution(p, contrib.var = c("cap.bil", "sector"))

p <- new("portfolioBasic",
         id.var = "symbol",
         in.var = "price",
         type = "linear",
         sides = c("long", "short"),
         ret.var = "month.ret",
         data = dow.jan.2005)

summary(p)

exposure(p, exp.var = c("price", "sector"))
performance(p)
contribution(p, contrib.var = c("cap.bil","sector"))

Run the code above in your browser using DataLab