gains_graph: Create Scatterplot of Investment Gains

Description Usage Arguments Details Value Note Author(s) References Examples

Description

Creates scatterplot of gains (daily or otherwise) for one or more investments vs. another.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
gains.graph(tickers = NULL, ...,
            gains = NULL,
            prices = NULL,
            orders = 1,
            add.plot = FALSE,
            colors = NULL,
            plot.list = NULL,
            points.list = NULL,
            legend.list = NULL,
            pdf.list = NULL,
            bmp.list = NULL,
            jpeg.list = NULL,
            png.list = NULL,
            tiff.list = NULL)

Arguments

tickers

Character vector of ticker symbols. Gains for the first ticker are plotted on the x-axis, and gains for all other tickers are plotted on the y-axis.

...

Arguments to pass along with tickers to load.gains function, if you wish to load data on the fly rather than specify gains or prices.

gains

Numeric matrix of gains (daily or otherwise), where each column has gains for a particular investment. Gains from the first column are plotted on the x-axis, and gains for all other columns are plotted on the y-axis.

prices

Numeric matrix of prices (daily or otherwise), where each column has prices for a particular investment. Gains derived from the first column are plotted on the x-axis, and gains derived from all other columns are plotted on the y-axis.

orders

Numeric value or vector of values specifying the order of linear regression models for each y-axis fund. Set to 1 for simple linear regression, 2 for linear regression with first-order and second-order terms, and so on.

add.plot

If TRUE, data is plotted on current plot frame rather than a new one.

colors

Character string of colors for each y-axis investment.

plot.list

Optional list of inputs to pass to plot function.

points.list

Optional list of inputs to pass to points function.

legend.list

Optional list of inputs to pass to legend function.

pdf.list

Optional list of inputs to pass to pdf function. If not NULL, .pdf file is created.

bmp.list

Optional list of inputs to pass to bmp function. If not NULL, .bmp file is created.

jpeg.list

Optional list of inputs to pass to jpeg function. If not NULL, .jpg file is created.

png.list

Optional list of inputs to pass to png function. If not NULL, .png file is created.

tiff.list

Optional list of inputs to pass to tiff function. If not NULL, .tif file is created.

Details

If tickers input is specified, it gets passed to load.gains to load historical prices from Yahoo! Finance using the quantmod package [1]. If gains or prices is specified, the graph is based directly on that information. Either way, the first fund's gains are plotted on the x-axis, and all the others are plotted on the y-axis.

Value

In addition to the graph, a list containing fitted linear regression models returned by the lm function for each y-axis fund vs. the x-axis fund.

Note

NA

Author(s)

Dane R. Van Domelen

References

1. Jeffrey A. Ryan (2016). quantmod: Quantitative Financial Modelling Framework. R package version 0.4-6, https://cran.r-project.org/package=quantmod.

Acknowledgment: This material is based upon work supported by the National Science Foundation Graduate Research Fellowship under Grant No. DGE-0940903.

Examples

1

Example output

Loading required package: rbenchmark
[1] NA

stocks documentation built on May 2, 2019, 5:22 p.m.