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

iterate.lin.recursion

Generate Sequence Iterating a Linear Recursion


Description

Generate numeric sequences applying a linear recursion nr.it times.

Usage

iterate.lin.recursion(x, coeff, delta = 0, nr.it)

Arguments

x

numeric vector with initial values, i.e., specifying the beginning of the resulting sequence; must be of length (larger or) equal to length(coeff).

coeff

coefficient vector of the linear recursion.

delta

numeric scalar added to each term; defaults to 0. If not zero, determines the linear drift component.

nr.it

integer, number of iterations.

Value

numeric vector, say r, of length n + nr.it, where n = length(x). Initialized as r[1:n] = x, the recursion is r[k+1] = sum(coeff * r[(k-m+1):k]), where m = length(coeff).

Note

Depending on the zeroes of the characteristic polynomial of coeff, there are three cases, of convergence, oszillation and divergence.

Author(s)

Martin Maechler

See Also

seq can be regarded as a trivial special case.

Examples

## The Fibonacci sequence:
iterate.lin.recursion(0:1, c(1,1), nr = 12)
## 0 1 1 2 3 5 8 13 21 34 55 89 144 233

## seq() as a special case:
stopifnot(iterate.lin.recursion(4,1, d=2, nr=20)
          == seq(4, by=2, length=1+20))

## ''Deterministic AR(2)'' :
round(iterate.lin.recursion(1:4, c(-0.7, 0.9), d = 2, nr=15), dig=3)
## slowly decaying :
plot(ts(iterate.lin.recursion(1:4, c(-0.9, 0.95), nr=150)))

sfsmisc

Utilities from 'Seminar fuer Statistik' ETH Zurich

v1.1-11
GPL (>= 2)
Authors
Martin Maechler [aut, cre] (<https://orcid.org/0000-0002-8685-9910>), Werner Stahel [ctb] (Functions: compresid2way(), f.robftest(), last(), p.scales(), p.dnorm()), Andreas Ruckstuhl [ctb] (Functions: p.arrows(), p.profileTraces(), p.res.2x()), Christian Keller [ctb] (Functions: histBxp(), p.tachoPlot()), Kjetil Halvorsen [ctb] (Functions: KSd(), ecdf.ksCI()), Alain Hauser [ctb] (Functions: cairoSwd(), is.whole(), toLatex.numeric()*), Christoph Buser [ctb] (to function Duplicated()), Lorenz Gygax [ctb] (to function p.res.2fact()), Bill Venables [ctb] (Functions: empty.dimnames(), primes()), Tony Plate [ctb] (to inv.seq()), Isabelle Fl<fc>ckiger [ctb], Marcel Wolbers [ctb], Markus Keller [ctb], Sandrine Dudoit [ctb], Jane Fridlyand [ctb], Greg Snow [ctb] (to loessDemo()), Henrik Aa. Nielsen [ctb] (to loessDemo()), Vincent Carey [ctb], Ben Bolker [ctb], Philippe Grosjean [ctb], Fr<e9>d<e9>ric Ibanez [ctb], Caterina Savi [ctb], Charles Geyer [ctb], Jens Oehlschl<e4>gel [ctb]
Initial release
2021-04-03

We don't support your browser anymore

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