lsgr: Least squares growth rate

View source: R/lsgr.R

lsgrR Documentation

Least squares growth rate

Description

Function for generating the n-period rolling least squares growth rate.

Usage

lsgr(x, n = 1)

Arguments

x

The time series for the growth rate to be calculated

n

The period for the growth to be calculated over.

Details

Missing values are ommited in the regression. (Will need to check this.)

WONTFIX (Michael): There is still some error associated with this function, will need to investigate further. Will need a rule for this, when the fluctuation is large and data are sufficient then take the lsgr, otherwise the geogr.

In order to ensure the growth rate calculated is reliable, the following rule are applied.

  1. 50% of the data must be present.

  2. The length of the time series must be greater than n.

Otherwise the growth will not be computed.

Value

The n-period least squares growth rate of the time series

Examples

test.ts = abs(rnorm(100))
lsgr(test.ts, 1)
lsgr(test.ts, 3)
lsgr(test.ts, 10)


FAOSTAT documentation built on March 31, 2023, 8:31 p.m.