gains_rate: Calculate Growth Rate From a Vector of Investment Gains

Description Usage Arguments Value Author(s) References See Also Examples

Description

The formula is simply: overall.rate = prod(gains + 1) - 1. If units.rate is specified, then it converts to x-unit growth rate.

Usage

1
gains.rate(gains, units.rate = NULL, nas = FALSE)

Arguments

gains

Numeric vector of investment gains.

units.rate

Number of units for growth rate calculation. If unspecified, function returns total growth. To get annualized growth rate, set to 252 if gains vector contains daily gains, 12 if gains vector contains monthly gains, etc.

nas

If TRUE, function finds and removes any missing values (NA's) in prices vector. The default is FALSE to maximize speed for the usual case where there are no missing values.

Value

Numeric value indicating the growth rate.

Author(s)

Dane R. Van Domelen

References

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

See Also

prices.rate

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Create vector of daily gains for a hypothetical stock
daily.gains <- c(-0.02, -0.01, 0.01, 0.02, 0.01)

# Overall growth is 0.95%
gains.rate(daily.gains)

# Average daily growth is 0.19%
gains.rate(daily.gains, 1)

# Corresponds to 61.0% annual growth
gains.rate(daily.gains, 252)


Search within the stocks package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.