rwalk: Generate a random walk time series from a starting point

View source: R/FLQuant.R

rwalkR Documentation

Generate a random walk time series from a starting point

Description

The last year of an FLQuant object is used as atrating point to generate a time series following a random walk with drift:

z_t = z_{t-1} + \epsilon_t + \delta_t, t=1,2,...

where \epsilon is \mathcal{N}(0, \sigma)

Usage

rwalk(x0, end = 1, sd = 0.05, delta = 0)

Arguments

x0

The initial state of the random walk, 'FLQuant'.

end

The number of years or the final year of the series. numeric.

sd

The standard deviation of the random walk, numeric.

delta

The drift of the random walk.

Details

The length of the series is set by argument end. This is taken as a number of years, if its value is smaller than the final 'year' of 'x0', or as a final year if larger or of class 'character'.

Value

An 'FLQuant' object.

Author(s)

Iago Mosqueira, WMR (2023)

See Also

FLQuant rnorm

Examples

data(ple4)
# Generate random walk recruitmrnt with positive drift
rwalk(rec(ple4), end=5, sd=0.08, delta=0.05)
# Use append() to add the new values at the end
append(rec(ple4), rwalk(rec(ple4), end=10, sd=0.04, delta=0))
# Use end as number of years
rwalk(rec(ple4), end=5)
# or as final year
rwalk(rec(ple4), end=2020)

flr/FLCore documentation built on May 4, 2024, midnight