sim_pwn: Simulate periodic white noise

View source: R/pc03simu.r

sim_pwnR Documentation

Simulate periodic white noise

Description

Simulate periodic white noise.

Usage

sim_pwn(n = 100, period = NA, seasonof1st = 1, scale = NULL, 
        shift = NULL, f = rnorm, ...)

Arguments

n

length of the generated sample.

period

number of seasons in an epoch.

seasonof1st

season of the first observation in the result.

scale

scale the series by this amount, a vector of length period or 1.

shift

shift the series by this amount, a vector of length period or 1.

f

a function or list of functions to generate random numbers.

...

arguments for the random number generator(s) specified by f.

Details

First a series, say x, of random numbers is generated as requested by the argument f. Then, if shift and/or scale are supplied, the values are modified as follows:

y_t = shift_{k} + scale_{k} x_t

where k is the season corresponding to time t. The vector y is returned.

If f is a single a function (or name of a function), then the series is generated (effectively) by the call f(n,...).

The argument f may also be a list whose kth element is itself a list specifying the random number generator for the kth season. The first element being the function (such as rnorm) and the remaining elements being parameters for that function. Parameters common to all seasons may be supplied through the ... argument.

The argument period may be omitted. In that case it is inferred from f and/or the lengths of shift and scale. Currently there is no check for consistency here.

The arguments shift and scale may be used to specify simple linear transformations of the generated values, possibly different for the different seasons. Each of them should be a vector of length period or one.

seasonof1st can be used to request the simulated time series to start from a season other than the first one. Note that whatever the value of seasonof1st, the first elements of scale, shift and f (if a list) are taken to refer to season one.

Value

A vector of length n representing a realization of a periodic white noise series. The season of the first observation is seasonof1st.

Level

0 (base)

Author(s)

Georgi N. Boshnakov

Examples

## three equivalent ways to specify periodic white noise with
## normal innovatios, 2 seasons, s.d. = 0.5 for season 1, and 2 for season 2
sim_pwn(100, f = rnorm, scale = c(0.5, 2))
sim_pwn(n = 100, scale = c(0.5, 2))  # rnorm is the default generator
sim_pwn(100, f = list(c(rnorm, 0, 0.5), c(rnorm, 0, 2)))

GeoBosh/pcts documentation built on Dec. 8, 2023, 9:57 p.m.