Title: | Generating Time Series with Diverse and Controllable Characteristics |
---|---|
Description: | Generates synthetic time series based on various univariate time series models including MAR and ARIMA processes. Kang, Y., Hyndman, R.J., Li, F.(2020) <doi:10.1002/sam.11461>. |
Authors: | Yanfei Kang [aut] , Feng Li [aut, cre] , Rob Hyndman [aut] , Mitchell O'Hara-Wild [ctb] , Bocong Zhao [ctb] |
Maintainer: | Feng Li <[email protected]> |
License: | GPL-3 |
Version: | 1.0.7 |
Built: | 2024-11-04 05:21:44 UTC |
Source: | https://github.com/ykang/gratis |
Web Application to generate time series with controllable features.
app_gratis()
app_gratis()
This function allows the parameters of a Gaussian
process to be specified. The output can be used in
simulate.Arima()
and generate.Arima
.
If any argument is NULL
, the corresponding parameters are randomly selected.
The AR and MA orders p and q are chosen from {0,1,2,3}, the seasonal AR and MA
orders P and Q are from {0,1,2}, while the order of differencing,
d is in {0,1,2}, and the order of seasonal differencing D is in {0,1}, with the
restriction that . If
constant
is NULL
, it is set to
0 if , otherwise it is uniformly sampled on (-3,3).
The model orders and the parameters are uniformly sampled. The AR and MA parameters are selected
to give stationary and invertible processes when
. The noise variance sigma
is uniformly sampled on (1,5). The parameterization is as specified in Hyndman & Athanasopoulos (2021).
arima_model( frequency = 1, p = NULL, d = NULL, q = NULL, P = NULL, D = NULL, Q = NULL, constant = NULL, phi = NULL, theta = NULL, Phi = NULL, Theta = NULL, sigma = NULL )
arima_model( frequency = 1, p = NULL, d = NULL, q = NULL, P = NULL, D = NULL, Q = NULL, constant = NULL, phi = NULL, theta = NULL, Phi = NULL, Theta = NULL, sigma = NULL )
frequency |
The length of the seasonal period (e.g., 12 for monthly data). |
p |
An integer equal to the non-seasonal autoregressive order |
d |
An integer equal to the non-seasonal order of differencing |
q |
An integer equal to the non-seasonal moving average order |
P |
An integer equal to the seasonal autoregressive order |
D |
An integer equal to the seasonal order of differencing |
Q |
An integer equal to the seasonal moving average order |
constant |
The intercept term |
phi |
A numeric p-vector containing the AR parameters. |
theta |
A numeric p-vector containing the MA parameters. |
Phi |
A numeric p-vector containing the seasonal AR parameters. |
Theta |
A numeric p-vector containing the seasonal MA parameters. |
sigma |
The standard deviation of the noise. |
An 'Arima' object as described in the arima
function from the stats package.
Rob J Hyndman
# An AR(2) model with random parameters model1 <- arima_model(p = 2, d = 0, q = 0) # An AR(2) model with specific parameters model2 <- arima_model(p = 2, d = 0, q = 0, phi = c(1.34, -0.64), sigma = 15) # Seasonal ARIMA model with randomly selected parameters model3 <- arima_model(frequency = 4) # Simulate from each model and plot the results library(forecast) simulate(model1, 100) %>% plot() simulate(model2, 100) %>% plot() simulate(model3, 100) %>% plot()
# An AR(2) model with random parameters model1 <- arima_model(p = 2, d = 0, q = 0) # An AR(2) model with specific parameters model2 <- arima_model(p = 2, d = 0, q = 0, phi = c(1.34, -0.64), sigma = 15) # Seasonal ARIMA model with randomly selected parameters model3 <- arima_model(frequency = 4) # Simulate from each model and plot the results library(forecast) simulate(model1, 100) %>% plot() simulate(model2, 100) %>% plot() simulate(model3, 100) %>% plot()
This function allows the parameters of a ETS state space model to be specified.
The output can be used in simulate.ets()
and generate.ets
.
If any argument is NULL
, the corresponding parameters are randomly selected.
The error component is chosen from {A,M}, the trend component is chosen from
{N,A,Ad}, and the seasonal component is chosen from {N,A,M}. In all cases,
the component is selected uniformly on the options. The parameters are selected
uniformly on the forecastable parameter space. The noise variance sigma
is uniformly sampled on (1,5) for additive errors, and on (0.0001,0.05) for
multiplicative errors. The initial states are chosen uniformly on (-1,1)
in all cases except for multiplicative seasonal states which are uniform on
(0.5, 1.5), and models with multiplicative errors for which the level is uniform
on (2, 10). The parameterization is as specified in Hyndman & Athanasopoulos (2021).
ets_model( frequency = 1, error = NULL, trend = NULL, seasonal = NULL, alpha = NULL, beta = NULL, gamma = NULL, phi = NULL, level = NULL, slope = NULL, season = NULL, damped = NULL, sigma = NULL )
ets_model( frequency = 1, error = NULL, trend = NULL, seasonal = NULL, alpha = NULL, beta = NULL, gamma = NULL, phi = NULL, level = NULL, slope = NULL, season = NULL, damped = NULL, sigma = NULL )
frequency |
The length of the seasonal period (e.g., 12 for monthly data). |
error |
A character string specifying the error part of the ETS model: either "A" or "M". |
trend |
A character string specifying the trend part of the ETS model: either "N", "A" or "Ad". |
seasonal |
A character string specifying the seasonal part of the ETS model: either "N", "A" or "M". |
alpha |
A numeric value for the smoothing parameter controlling the level. |
beta |
A numeric value for the smoothing parameter controlling the trend. |
gamma |
A numeric value for the smoothing parameter controlling the seasonality. |
phi |
A numeric value specifying the damping parameter. |
level |
A numeric value specifying the initial level |
slope |
A numeric value specifying the initial slope |
season |
A numeric vector specifying the initial states |
damped |
A logical value indicating if the trend is damped or not. |
sigma |
The standard deviation of the noise. |
An 'ets' object as described in the ets
function from the forecast package.
Rob J Hyndman
# An ETS(A,A,N) model with random parameters model1 <- ets_model(error = "A", trend = "A", seasonal = "N") # An ETS(A,A,N) model with specific parameters model2 <- ets_model( error = "A", trend = "A", seasonal = "N", alpha = 0.3, beta = 0.2, level = 0, slope = 1, sigma = 2 ) # A multiplicative quarterly seasonal ETS model with random parameters model3 <- ets_model(seasonal = "M", frequency = 4) # Simulate from each model and plot the results library(forecast) simulate(model1, 100) %>% plot() simulate(model2, 100) %>% plot() simulate(model3, 100) %>% plot()
# An ETS(A,A,N) model with random parameters model1 <- ets_model(error = "A", trend = "A", seasonal = "N") # An ETS(A,A,N) model with specific parameters model2 <- ets_model( error = "A", trend = "A", seasonal = "N", alpha = 0.3, beta = 0.2, level = 0, slope = 1, sigma = 2 ) # A multiplicative quarterly seasonal ETS model with random parameters model3 <- ets_model(seasonal = "M", frequency = 4) # Simulate from each model and plot the results library(forecast) simulate(model1, 100) %>% plot() simulate(model2, 100) %>% plot() simulate(model3, 100) %>% plot()
Deprecated function. Please use mar_model()
and generate.mar()
instead.
Generates multiple seasonal time series from random parameter spaces of the mixture autoregressive (MAR) models.
generate_msts( seasonal.periods = c(7, 365), n = 800, nComp = NULL, output_format = "list" )
generate_msts( seasonal.periods = c(7, 365), n = 800, nComp = NULL, output_format = "list" )
seasonal.periods |
a vector of seasonal periods of the time series to be generated. |
n |
length of the generated time series. |
nComp |
number of mixing components when simulating time series using MAR models. |
output_format |
An optional argument which allows to choose output format between "list" and "tsibble" |
a time series with multiple seasonal periods.
x <- generate_msts(seasonal.periods = c(7, 365), n = 800, nComp = 2, output_format = "list") forecast::autoplot(x)
x <- generate_msts(seasonal.periods = c(7, 365), n = 800, nComp = 2, output_format = "list") forecast::autoplot(x)
Deprecated function. Please use mar_model()
and generate.mar()
instead.
Generate time series from random parameter spaces of the mixture autoregressive (MAR)
models.
generate_ts(n.ts = 1, freq = 1, nComp = NULL, n = 120, output_format = "list")
generate_ts(n.ts = 1, freq = 1, nComp = NULL, n = 120, output_format = "list")
n.ts |
number of time series to be generated. |
freq |
seasonal period of the time series to be generated. |
nComp |
number of mixing components when simulating time series using MAR models. |
n |
length of the generated time series. |
output_format |
An optional argument which allows to choose output format between "list" and "tsibble" |
A list of time series together with the SARIMA coefficients used in each mixing component and the corresponding mixing weights.
Yanfei Kang and Feng Li
Wong, CS & WK Li (2000).
x <- generate_ts(n.ts = 2, freq = 12, nComp = 2, n = 120) x$N1$pars forecast::autoplot(x$N1$x)
x <- generate_ts(n.ts = 2, freq = 12, nComp = 2, n = 120) x$N1$pars forecast::autoplot(x$N1$x)
Deprecated function. Please use generate_target()
instead.
generate_ts_with_target( n, ts.length, freq, seasonal, features, selected.features, target, parallel = TRUE, output_format = "list" )
generate_ts_with_target( n, ts.length, freq, seasonal, features, selected.features, target, parallel = TRUE, output_format = "list" )
n |
number of time series to be generated. |
ts.length |
length of the time series to be generated. |
freq |
frequency of the time series to be generated. |
seasonal |
0 for non-seasonal data, 1 for single-seasonal data, and 2 for multiple seasonal data. |
features |
a vector of function names. |
selected.features |
selected features to be controlled. |
target |
target feature values. |
parallel |
An optional argument which allows to specify if the Genetic Algorithm should be run sequentially or in parallel. |
output_format |
An optional argument which allows to choose output format between 'list' and 'tsibble' |
A time-series object of class "ts" or "msts".
Yanfei Kang
library(tsfeatures) x <- generate_ts_with_target( n = 1, ts.length = 60, freq = 1, seasonal = 0, features = c("entropy", "stl_features"), selected.features = c("entropy", "trend"), target = c(0.6, 0.9), parallel = FALSE ) forecast::autoplot(x)
library(tsfeatures) x <- generate_ts_with_target( n = 1, ts.length = 60, freq = 1, seasonal = 0, features = c("entropy", "stl_features"), selected.features = c("entropy", "trend"), target = c(0.6, 0.9), parallel = FALSE ) forecast::autoplot(x)
This function simulates multiple random sample paths from a mixture of k Gaussian AR(p) processes. The model is of the form
with probability , where
is a N(0,1) variate.
The index of the tsibble is guessed from the MAR model seasonal periods.
## S3 method for class 'mar' generate(x, length = 100, nseries = 10, ...) ## S3 method for class 'ets' generate(x, length = 100, nseries = 10, ...) ## S3 method for class 'Arima' generate(x, length = 100, nseries = 10, ...)
## S3 method for class 'mar' generate(x, length = 100, nseries = 10, ...) ## S3 method for class 'ets' generate(x, length = 100, nseries = 10, ...) ## S3 method for class 'Arima' generate(x, length = 100, nseries = 10, ...)
x |
A 'mar' object, usually the output of |
length |
length of series to generate |
nseries |
number of series to generate |
... |
Other arguments, passed to |
'tsibble' object with 'length' rows and 3 columns.
Rob J Hyndman
Feng Li, Mattias Villani, and Robert Kohn. (2010). Flexible Modeling of Conditional Distributions using Smooth Mixtures of Asymmetric Student T Densities, Journal of Statistical Planning and Inference, 140(12), pp. 3638-3654.
# MAR model with constant variances phi <- cbind(c(0, 0.8, 0), c(0, 0.6, 0.3)) weights <- c(0.8, 0.2) model1 <- mar_model(phi = phi, sigmas = c(1, 2), weights = weights) generate(model1, nseries = 5) # MAR model for hourly data with daily and weekly periods hourly_model <- mar_model(seasonal_periods = c(24, 24*7)) generate(hourly_model)
# MAR model with constant variances phi <- cbind(c(0, 0.8, 0), c(0, 0.6, 0.3)) weights <- c(0.8, 0.2) model1 <- mar_model(phi = phi, sigmas = c(1, 2), weights = weights) generate(model1, nseries = 5) # MAR model for hourly data with daily and weekly periods hourly_model <- mar_model(seasonal_periods = c(24, 24*7)) generate(hourly_model)
This function allows the parameters of a mixture of k Gaussian ARIMA(p,d,0)(P,D,0)[m] processes
to be specified. The output is used in simulate.mar()
and generate.mar
.
The model is of the form
with probability , where
is the backshift operator,
is the seasonal period,
is a N(0,1) variate, and
and
are polynomials in B of
order
and
respectively.
If any argument is
NULL
, the corresponding parameters are randomly selected.
When randomly selected, the AR parameters are uniformly sampled from the stationary region,
p is in {0,1,2,3}, d is in {0,1,2}, P is in {0,1,2} and D is in {0,1}.
The model orders are uniformly sampled. The constants are uniformly sampled on (-3,3).
The sigmas are uniformly sampled on (1,5) and the weights are uniformly sampled on (0,1).
The number of components is uniformly sampled on {1,2,3,4,5}.
mar_model( k = NULL, p = NULL, d = NULL, phi = NULL, P = NULL, D = NULL, Phi = NULL, constants = NULL, sigmas = NULL, weights = NULL, seasonal_periods = 1L )
mar_model( k = NULL, p = NULL, d = NULL, phi = NULL, P = NULL, D = NULL, Phi = NULL, constants = NULL, sigmas = NULL, weights = NULL, seasonal_periods = 1L )
k |
Number of components. |
p |
Non-negative integer vector giving the orders of non-seasonal AR polynomials |
d |
Non-negative integer vector giving the orders of non-seasonal differencing. |
phi |
A max(p) x k numeric matrix containing the non-seasonal AR parameters
( |
P |
Non-negative integer giving the orders of seasonal AR polynomiasl |
D |
Non-negative integer giving the orders of seasonal differencing.
Ignored if |
Phi |
A max(P) x k numeric matrix containing the seasonal AR parameters
( |
constants |
A numeric vector of length k containing |
sigmas |
A numeric vector of length k or a list of k GARCH specifications.
If it is a vector, it is assumed |
weights |
A numeric vector of length k containing the probability of
each of the component processes, |
seasonal_periods |
Either a scalar or a numeric vector of length k containing the seasonal period of each component. |
A 'mar' object containing a list of k
, m
,
p
, d
, P
, D
,
phi
, Phi
, sigmas
and weights
.
Rob J Hyndman
n <- 100 # Quarterly MAR model with randomly selected parameters model1 <- mar_model(seasonal_periods = 4) # Daily MAR model with randomly selected parameters model2 <- mar_model(seasonal_periods = c(7, 365)) # MAR model with constant variances # containing an AR(1) component and an AR(2) component phi <- cbind(c(0, 0.8, 0), c(0, 0.6, 0.3)) weights <- c(0.8, 0.2) model3 <- mar_model(phi = phi, d = 0, sigmas = c(1, 2), weights = weights) # MAR model with heteroskedastic errors sigmas.spec <- list( fGarch::garchSpec(model = list(alpha = c(0.05, 0.06))), fGarch::garchSpec(model = list(alpha = c(0.05, 0.05))) ) model4 <- mar_model(phi = phi, sigmas = sigmas.spec, weights = weights)
n <- 100 # Quarterly MAR model with randomly selected parameters model1 <- mar_model(seasonal_periods = 4) # Daily MAR model with randomly selected parameters model2 <- mar_model(seasonal_periods = c(7, 365)) # MAR model with constant variances # containing an AR(1) component and an AR(2) component phi <- cbind(c(0, 0.8, 0), c(0, 0.6, 0.3)) weights <- c(0.8, 0.2) model3 <- mar_model(phi = phi, d = 0, sigmas = c(1, 2), weights = weights) # MAR model with heteroskedastic errors sigmas.spec <- list( fGarch::garchSpec(model = list(alpha = c(0.05, 0.06))), fGarch::garchSpec(model = list(alpha = c(0.05, 0.05))) ) model4 <- mar_model(phi = phi, sigmas = sigmas.spec, weights = weights)
Convert SARIMA coefficients to pi coefficients of an AR process.
pi_coefficients( ar = 0, d = 0L, ma = 0, sar = 0, D = 0L, sma = 0, m = 1L, tol = 1e-07 )
pi_coefficients( ar = 0, d = 0L, ma = 0, sar = 0, D = 0L, sma = 0, m = 1L, tol = 1e-07 )
ar |
AR coefficients in the SARIMA model. |
d |
number of differences in the SARIMA model. |
ma |
MA coefficients in the SARIMA model. |
sar |
seasonal AR coefficients in the SARIMA model. |
D |
number of seasonal differences in the SARIMA model. |
sma |
seasonal MA coefficients in the SARIMA model. |
m |
seasonal period in the SARIMA model. |
tol |
tolerance value used. Only return up to last element greater than tolerance. |
A vector of AR coefficients.
Rob J Hyndman
# Not Run
# Not Run
Random variables from a mixture of k multivariate normal distributions, each of dimension q.
rmixnorm(n, means, sigmas, weights)
rmixnorm(n, means, sigmas, weights)
n |
an integer for the number of samples to be generated. |
means |
a q x k matrix (or a vector of length k if q=1) containing the means for each component. |
sigmas |
a q x q x k covariance array (or a vector of length k if q=1) for each component. |
weights |
a vector of length k containing the weights for each component. |
An n x q matrix (or a vector if q=1) containing the generated data.
Feng Li, Central University of Finance and Economics.
Villani et al 2009.
out <- rmixnorm( n = 1000, means = c(-5, 0, 5), sigmas = c(1, 1, 3), weights = c(0.3, 0.4, 0.3) ) hist(out, breaks = 100, freq = FALSE)
out <- rmixnorm( n = 1000, means = c(-5, 0, 5), sigmas = c(1, 1, 3), weights = c(0.3, 0.4, 0.3) ) hist(out, breaks = 100, freq = FALSE)
This function simulates random samples from a finite mixture of Gaussian distribution where the mean from each components are AR(p) process.
rmixnorm_ts(n, means.ar.par.list, sigmas.list, weights, yinit = 0)
rmixnorm_ts(n, means.ar.par.list, sigmas.list, weights, yinit = 0)
n |
number of samples. |
means.ar.par.list |
parameters in AR(p) within each mixing compoment. |
sigmas.list |
variance list. |
weights |
weight in each list. |
yinit |
initial values. |
vector of length n follows a mixture distribution.
Feng Li, Central University of Finance and Economics.
Feng Li, Mattias Villani, and Robert Kohn. (2010). Flexible Modeling of Conditional Distributions using Smooth Mixtures of Asymmetric Student T Densities, Journal of Statistical Planning and Inference, 140(12), pp. 3638-3654.
n <- 1000 means.ar.par.list <- list(c(0, 0.8), c(0, 0.6, 0.3)) require("fGarch") sigmas.spec <- list( fGarch::garchSpec(model = list(alpha = c(0.05, 0.06)), cond.dist = "norm"), fGarch::garchSpec(model = list(alpha = c(0.05, 0.05)), cond.dist = "norm") ) sigmas.list <- lapply( lapply(sigmas.spec, fGarch::garchSim, extended = TRUE, n = n), function(x) x$sigma ) weights <- c(0.8, 0.2) y <- rmixnorm_ts( n = n, means.ar.par.list = means.ar.par.list, sigmas.list = sigmas.list, weights = weights ) plot(y)
n <- 1000 means.ar.par.list <- list(c(0, 0.8), c(0, 0.6, 0.3)) require("fGarch") sigmas.spec <- list( fGarch::garchSpec(model = list(alpha = c(0.05, 0.06)), cond.dist = "norm"), fGarch::garchSpec(model = list(alpha = c(0.05, 0.05)), cond.dist = "norm") ) sigmas.list <- lapply( lapply(sigmas.spec, fGarch::garchSim, extended = TRUE, n = n), function(x) x$sigma ) weights <- c(0.8, 0.2) y <- rmixnorm_ts( n = n, means.ar.par.list = means.ar.par.list, sigmas.list = sigmas.list, weights = weights ) plot(y)
simulate_target
simulate one time series of length 'length' from a MAR model with target features
and returns a ts
or msts
object.
generate_target
simulate multiple time series of length 'length' from a MAR model with target features
and returns a tsibble
object. The index of the tsibble is guessed from the seasonal periods.
The specified features should not depend on the scale of the time series as the series is scaled during simulation.
simulate_target( length = 100, seasonal_periods = 1, feature_function, target, k = ifelse(length(seasonal_periods) == 1, 3, length(seasonal_periods)), tolerance = 0.05, trace = FALSE, parallel = FALSE ) generate_target( length = 100, nseries = 10, seasonal_periods = 1, feature_function, target, k = ifelse(length(seasonal_periods) == 1, 3, length(seasonal_periods)), tolerance = 0.05, trace = FALSE, parallel = FALSE )
simulate_target( length = 100, seasonal_periods = 1, feature_function, target, k = ifelse(length(seasonal_periods) == 1, 3, length(seasonal_periods)), tolerance = 0.05, trace = FALSE, parallel = FALSE ) generate_target( length = 100, nseries = 10, seasonal_periods = 1, feature_function, target, k = ifelse(length(seasonal_periods) == 1, 3, length(seasonal_periods)), tolerance = 0.05, trace = FALSE, parallel = FALSE )
length |
length of the time series to be generated. |
seasonal_periods |
Either a scalar or a numeric vector of length k containing the number of seasonal periods for each component. |
feature_function |
a function that returns a vector of features from a time series. |
target |
target feature values of the same length as that returned by |
k |
integer specifying number of components to use for MAR models. Default is 3 unless there are multiple seasonal periods specified. |
tolerance |
average tolerance per feature. The genetic algorithm will attempt
to find a solution where the average difference between the series features and target
is less than |
trace |
logical indicating if details of the search should be shown. |
parallel |
An optional argument which allows to specify if the Genetic Algorithm should be run sequentially or in parallel. |
nseries |
Number of series to generate |
A time series object of class "ts" or "msts".
Yanfei Kang and Rob J Hyndman
set.seed(1) library(tsfeatures) my_features <- function(y) { c(entropy(y), acf = acf(y, plot = FALSE)$acf[2:3, 1, 1]) } # Simulate a ts with specified target features y <- simulate_target( length = 60, feature_function = my_features, target = c(0.5, 0.9, 0.8) ) my_features(y) plot(y) ## Not run: # Generate a tsibble with specified target features df <- generate_target( length = 60, feature_function = my_features, target = c(0.5, 0.9, 0.8) ) df %>% as_tibble() %>% group_by(key) %>% dplyr::summarise(value = my_features(value), feature=c("entropy","acf1", "acf2"), .groups = "drop") autoplot(df) # Simulate time series similar to an existing series my_features <- function(y) { c(stl_features(y)[c("trend", "seasonal_strength", "peak", "trough")]) } y <- simulate_target( length = length(USAccDeaths), seasonal_periods = frequency(USAccDeaths), feature_function = my_features, target = my_features(USAccDeaths) ) tsp(y) <- tsp(USAccDeaths) plot(cbind(USAccDeaths, y)) cbind(my_features(USAccDeaths), my_features(y)) ## End(Not run)
set.seed(1) library(tsfeatures) my_features <- function(y) { c(entropy(y), acf = acf(y, plot = FALSE)$acf[2:3, 1, 1]) } # Simulate a ts with specified target features y <- simulate_target( length = 60, feature_function = my_features, target = c(0.5, 0.9, 0.8) ) my_features(y) plot(y) ## Not run: # Generate a tsibble with specified target features df <- generate_target( length = 60, feature_function = my_features, target = c(0.5, 0.9, 0.8) ) df %>% as_tibble() %>% group_by(key) %>% dplyr::summarise(value = my_features(value), feature=c("entropy","acf1", "acf2"), .groups = "drop") autoplot(df) # Simulate time series similar to an existing series my_features <- function(y) { c(stl_features(y)[c("trend", "seasonal_strength", "peak", "trough")]) } y <- simulate_target( length = length(USAccDeaths), seasonal_periods = frequency(USAccDeaths), feature_function = my_features, target = my_features(USAccDeaths) ) tsp(y) <- tsp(USAccDeaths) plot(cbind(USAccDeaths, y)) cbind(my_features(USAccDeaths), my_features(y)) ## End(Not run)
This function simulates one random sample path from a mixture of k Gaussian AR(p) processes. The model is of the form
with probability , where
is a N(0,1) variate.
## S3 method for class 'mar' simulate(object, nsim = 100, seed = NULL, n.start = 100, ...)
## S3 method for class 'mar' simulate(object, nsim = 100, seed = NULL, n.start = 100, ...)
object |
A 'mar' object, usually the output of |
nsim |
length of series to generate |
seed |
Either |
n.start |
Length of 'burn-in' period. |
... |
Other arguments, not currently used. |
'ts' object of length nsim
.
Rob J Hyndman
Feng Li, Mattias Villani, and Robert Kohn. (2010). Flexible Modeling of Conditional Distributions using Smooth Mixtures of Asymmetric Student T Densities, Journal of Statistical Planning and Inference, 140(12), pp. 3638-3654.
# MAR model with constant variances phi <- cbind(c(0, 0.8, 0), c(0, 0.6, 0.3)) weights <- c(0.8, 0.2) model1 <- mar_model(phi = phi, sigmas = c(1, 2), weights = weights) y <- simulate(model1, 100) plot(y) # MAR model with heteroskedastic errors sigmas.spec <- list( fGarch::garchSpec(model = list(alpha = c(0.05, 0.06))), fGarch::garchSpec(model = list(alpha = c(0.05, 0.05))) ) model2 <- mar_model(phi = phi, sigmas = sigmas.spec, weights = weights) y <- simulate(model2, 100) plot(y)
# MAR model with constant variances phi <- cbind(c(0, 0.8, 0), c(0, 0.6, 0.3)) weights <- c(0.8, 0.2) model1 <- mar_model(phi = phi, sigmas = c(1, 2), weights = weights) y <- simulate(model1, 100) plot(y) # MAR model with heteroskedastic errors sigmas.spec <- list( fGarch::garchSpec(model = list(alpha = c(0.05, 0.06))), fGarch::garchSpec(model = list(alpha = c(0.05, 0.05))) ) model2 <- mar_model(phi = phi, sigmas = sigmas.spec, weights = weights) y <- simulate(model2, 100) plot(y)