Skip to contents

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.

Value

An 'FLQuant' object.

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'.

See also

Author

Iago Mosqueira, WMR (2023)

Examples

data(ple4)
# Generate random walk recruitmrnt with positive drift
rwalk(rec(ple4), end=5, sd=0.08, delta=0.05)
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> age   2018    2019    2020    2021    2022   
#>   all 2183684 2539488 2826942 2967576 3195928
#> 
#> units:  1000 
# Use append() to add the new values at the end
append(rec(ple4), rwalk(rec(ple4), end=10, sd=0.04, delta=0))
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>    year
#> age 1957    1958    1959    1960    1961    1962    1963    1964    1965   
#>   1  477074  710748  874712  797702  870799  615691  610017 2449900  664500
#>    year
#> age 1966    1967    1968    1969    1970    1971    1972    1973    1974   
#>   1  579075  428110  418228  666902  671454  433599  367450 1391430 1074920
#>    year
#> age 1975    1976    1977    1978    1979    1980    1981    1982    1983   
#>   1  787372  674010 1033740  879043  915553 1078660  999968 1935350 1375880
#>    year
#> age 1984    1985    1986    1987    1988    1989    1990    1991    1992   
#>   1 1302060 1792220 4303680 1910200 1774940 1250510 1083810  981356  854841
#>    year
#> age 1993    1994    1995    1996    1997    1998    1999    2000    2001   
#>   1  550376  566448  932162  893056 2431310  778427  683151  857525  634808
#>    year
#> age 2002    2003    2004    2005    2006    2007    2008    2009    2010   
#>   1 1792880  557844 1235790  863893  875191 1379750 1135050 1088820 1444570
#>    year
#> age 2011    2012    2013    2014    2015    2016    2017    2018    2019   
#>   1 1608190 1278010 1455050 1640700  895620 1211320 1823000 1759380 1729163
#>    year
#> age 2020    2021    2022    2023    2024    2025    2026    2027   
#>   1 1744349 1673871 1763022 1747150 1687970 1608391 1675001 1645038
#> 
#> units:  1000 
# Use end as number of years
rwalk(rec(ple4), end=5)
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> age   2018    2019    2020    2021    2022   
#>   all 1815915 1820430 1807299 1679329 1714100
#> 
#> units:  1000 
# or as final year
rwalk(rec(ple4), end=2020)
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> age   2018    2019    2020   
#>   all 1799865 1792118 1925256
#> 
#> units:  1000