plot.portfolio: Plot method of class portfolio

Description Usage Arguments Author(s) Examples

View source: R/plot.portfolio.R

Description

The plot() method shows a bar chart of the portfolio weights.

Usage

1
2
## S3 method for class 'portfolio'
plot(x, ...)

Arguments

x

object of class portfolio

...

additional arguments passed to barplot()

Author(s)

Eric Zivot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# construct the data
asset.names = c("MSFT", "NORD", "SBUX")
er = c(0.0427, 0.0015, 0.0285)
names(er) = asset.names
covmat = matrix(c(0.0100, 0.0018, 0.0011,
                  0.0018, 0.0109, 0.0026,
                  0.0011, 0.0026, 0.0199),
                nrow=3, ncol=3)
r.free = 0.005
dimnames(covmat) = list(asset.names, asset.names)

# compute equally weighted portfolio
ew = rep(1,3)/3
equalWeight.portfolio = getPortfolio(er=er,cov.mat=covmat,weights=ew)
plot(equalWeight.portfolio, col="blue")

IntroCompFinR documentation built on May 2, 2019, 4:46 p.m.