Last data update: 2014.03.03

R: Investing in a Toy Market
InvestR Documentation

Investing in a Toy Market

Description

Given the portfolio weights and a toy market, the function Invest simulates the growth of $1 of the corresponding portfolio and that of the benchmark.

Usage

Invest(market, weight, plot = TRUE)

Arguments

market

a toymkt object.

weight

the portfolio weights. The portfolio weights must be non-negative and sum to one (full investment with no short sales). It can be a zoo object or matrix/dataframe whose number of rows is at least as large as that of market$R. If the number of rows of weight is larger than required, only the initial rows will be used. weight can also be a numeric vector whose length is equal to the number of columns of market$R (the number of assets). In the latter case the portfolio is assumed to be constant-weighted through out.

plot

TRUE or FALSE. If TRUE, the growth of $1 of the portfolio will be plotted together with the growth of $1 of the market portfolio. The default value is TRUE.

Details

The relative value in the second plot is the ratio of the growth of $1 of the portfolio to that of the benchmark. It is called relative because the value is normalized by the value of the benchmark portfolio.

Value

A list containing the following components.

growth

a zoo object representing the growth of $1 of the portfolio and the benchmark.

R

a zoo object of simple returns of the two portfolios.

r

a zoo object of log returns of the two portfolios.

See Also

toymkt

Examples

# Performance of the equal-weighted portfolio
data(applestarbucks)
market <- toymkt(applestarbucks)
weight <- c(0.5, 0.5)  # equal-weighted portfolio
result <- Invest(market, weight, plot = TRUE)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

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.

> library(RelValAnalysis)
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/RelValAnalysis/Invest.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Invest
> ### Title: Investing in a Toy Market
> ### Aliases: Invest
> 
> ### ** Examples
> 
> # Performance of the equal-weighted portfolio
> data(applestarbucks)
> market <- toymkt(applestarbucks)
Warning message:
In toymkt(applestarbucks) :
  Since initial.weight is not given, the benchmark is assumed to be equal-weighted initially.
> weight <- c(0.5, 0.5)  # equal-weighted portfolio
> result <- Invest(market, weight, plot = TRUE)
Warning message:
In Invest(market, weight, plot = TRUE) :
  Since only one weight vector is supplied, the portfolio is assumed to be constant-weighted.
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>