gains.rate {stocks} | R Documentation |
The formula is simply: overall.rate = prod(gains + 1) - 1
. If
units.rate
is specified, then it converts to x-unit growth rate.
gains.rate(gains, units.rate = NULL, nas = FALSE)
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 |
nas |
If |
Numeric value indicating the growth rate.
Dane R. Van Domelen
Acknowledgment: This material is based upon work supported by the National Science Foundation Graduate Research Fellowship under Grant No. DGE-0940903.
# 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)