Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

lagratio

Ratio of lagged observations.


Description

Computes the ratio of lagged observations in a vector.

Usage

lagratio(
  x,
  lag = 1L,
  recursion = 1L,
  differences = recursion,
  direction = c("backward", "forward"),
  ...
)

Arguments

x

A numeric vector or matrix.

lag

An integer representing the lag ‘distance’.

recursion

An integer that indicates the level of recursion for the calculations. A 1 will simply compute the ratios. A 2, for example, will compute the ratios, save the result, and then compute the ratios of the results using the same lag. See examples.

differences

Same as recursion. Used for symmetry with diff.

direction

A string that indicates the direction of calculation. A "backward" indicates that ‘latter’ values are divided by ‘former’ values. A "forward" indicates that ‘former’ values are divided by ‘latter’ values. See examples.

...

Additional arguments to diff().

Details

This function behaves similarly to diff() except that it returns a vector or matrix of ratios rather than differences.

Value

A vector or matrix of lagged ratios.

Author(s)

Derek H. Ogle, derek@derekogle.com

See Also

diff

Examples

## Backward lagged ratios
# no recursion
lagratio(1:10,1)
lagratio(1:10,2)
# with recursion
lagratio(1:10,1,2)
lagratio(1:10,2,2)

## Forward lagged ratios
# no recursion
lagratio(10:1,1,direction="forward")
lagratio(10:1,2,direction="forward")
# with recursion
lagratio(10:1,1,2,direction="forward")
lagratio(10:1,2,2,direction="forward")

FSA

Simple Fisheries Stock Assessment Methods

v0.8.32
GPL (>= 2)
Authors
Derek Ogle [aut, cre] (<https://orcid.org/0000-0002-0370-9299>), Powell Wheeler [aut], Alexis Dinno [aut] (Provided base functionality of dunnTest())
Initial release
2021-1-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.