gen_gts: Create a GMWM TS Object based on model

Description Usage Arguments Details Value Examples

View source: R/gts.R

Description

Create a gts object based on a supplied time series model.

Usage

1
2
gen_gts(n, model, start = 0, end = NULL, freq = 1, unit = NULL,
  name = NULL)

Arguments

n

An interger containing the amount of observations for the time series.

model

A ts.model or gmwm object containing one of the allowed models.

start

A numeric that provides the time of the first observation.

end

A numeric that provides the time of the last observation.

freq

A numeric that provides the rate of samples. Default value is 1.

unit

A string that contains the unit expression of the frequency. Default value is NULL.

name

A string that provides an identifier to the data. Default value is NULL.

Details

This function accepts either a ts.model object (e.g. AR1(phi = .3, sigma2 =1) + WN(sigma2 = 1)) or a gmwm object.

Value

A gts object with the following attributes:

start

The time of the first observation

end

The time of the last observation

freq

Numeric representation of frequency

unit

String representation of the unit

name

Name of the dataset

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Set seed for reproducibility
set.seed(1336)
n = 1000

# AR1 + WN
model = AR1(phi = .5, sigma2 = .1) + WN(sigma2=1)
x = gen_gts(n, model)
plot(x)

# Reset seed
set.seed(1336)

# GM + WN
# Convert from AR1 to GM values
m = ar1_to_gm(c(.5,.1),10)

# Beta = 6.9314718, Sigma2_gm = 0.1333333
model = GM(beta = m[1], sigma2_gm = m[2]) + WN(sigma2=1)
x2 = gen_gts(n, model, freq = 10, unit = 'sec')
plot(x2, to.unit = 'min')

# Same time series
all.equal(x, x2, check.attributes = FALSE)

SMAC-Group/gmwm documentation built on Sept. 11, 2021, 10:06 a.m.