split_templ: Sample Splitting

Description Usage Arguments Details Value Examples

View source: R/aux_funs.R

Description

Create a function that will perform sample splitting. Initialise it once by calling split_templ and then re-use where applicable.

Usage

1
2
split_templ(Nburn = 0, Npre = 0, Nest = 0, Ntrain = 0, Neval = 0,
  Noos = 0)

Arguments

Nburn

An integer scalar. The number of burn-in observations in a simulation context. These are observations that are non-existent if the data are actual observation and not synthetically created for simulation purposes.

Npre

An integer scalar. The number of pre-sample observations for lags etc.

Nest

An integer scalar. The number of observations available for estimation.

Ntrain

An integer scalar. The number of observations for training, e.g. hyperparameters, forecasts.

Neval

An integer scalar. The number of observations for model evaluation.

Noos

An integer scalar. The number of true out-of-sample observations for simulation purposes. Can be used for evaluating the final outcome (model choice etc.).

Details

The function split_templ is a template for creating another function. This other function will accept a (K x N) matrix holding N observations of K variables and will slice the columns of that matrix according to the numbers passed to split_templ.

Value

A list with six elements. Each of which is a numeric matrix corresponding to one of the six arguments passed to split_templ. Every matrix has K rows and as many columns as specified in split_templ. If an argument of split_sample is zero (the default), then the matrix will have zero columns.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
p <- 2
N <- 25

Npre <- 2
Nest <- N
Noos <- 5

Nsim <- Npre + Nest + Noos

Y <- matrix(1:Nsim, 1, Nsim)
split_sample <- split_templ(Npre = Npre, Nest = Nest, Noos = Noos)
spl <- split_sample(Y)

spl$est

## Not run: 
split_sample_wrong <- split_templ(Npre = Npre, Nest = Nest)
split_sample_wrong(Y)

## End(Not run)

nielsaka/zeitreihe documentation built on March 17, 2020, 8:38 p.m.