ts_data {exams.forge}R Documentation

Time Series

Description

Creates an univariate time series based on a linear or an exponential trend, an additive or multiplicative seasonal adjustment and with white noise.

Usage

ts_data(
  end,
  trend = TRUE,
  trend.coeff = c(1, 1),
  season = TRUE,
  season.coeff = NULL,
  error = TRUE,
  error.coeff = NULL,
  digits = NA
)

dts(
  end,
  trend = TRUE,
  trend.coeff = c(1, 1),
  season = TRUE,
  season.coeff = NULL,
  error = TRUE,
  error.coeff = NULL,
  digits = NA
)

Arguments

end

integer: length of time series

trend

logical: if TRUE a linear trend otherwise a exponential trend (default: TRUE)

trend.coeff

numeric: coefficients for a linear model (default: c(1,1))

season

logical: if TRUE an additive seasonal adjustment is done otherwise, a multiplicative seasonal adjustment (default: TRUE)

season.coeff

numeric: coefficients for the adjustment (default: NULL). If NULL then no seasonal adjustment is made.

error

logical: if TRUE an additive error term is used, otherwise, a multiplicative error term (default: TRUE).

error.coeff

numeric: standard deviation(s) for white noise error (default: NULL). If NULL then no error is added.

digits

integer: number of digits to round the time series (default: NA). If NA then no rounding is done.

Value

A ts_data object with the following list of elements:

Examples

# Time series from linear trend
ts <- ts_data(12, trend.coeff= c(sample(0:10, 1), sample(1+(1:10)/20, 1)))
ts
# Time series from exponential trend
ts <- ts_data(12, trend.coeff= c(sample(0:10, 1), sample(1+(1:10)/20, 1)), trend=FALSE)
ts   
# Time series from linear trend and additive seasonal adjustment (quartely data)
ts <- ts_data(12, trend.coeff=c(sample(0:10, 1), sample(1+(1:10)/20, 1)),
                  season.coeff=sample((-20:20)/20, 4))
ts   
# Time series from linear trend and additive seasonal adjustment (half-yearly data)
ts <- ts_data(12, trend.coeff=c(sample(0:10, 1), sample(1+(1:10)/20, 1)),
                  season.coeff=sample((-20:20)/20, 2))
ts   
# Time series from linear trend and mutliplicative seasonal adjustment (quartely data)
ts <- ts_data(12, trend.coeff=c(sample(0:10, 1), sample(1+(1:10)/20, 1)),
                  season.coeff=sample((-20:20)/20, 4), season=FALSE)
ts   

[Package exams.forge version 1.0.10 Index]