Movatterモバイル変換


[0]ホーム

URL:


Type:Package
Title:Forecasting Using Multivariate Models
Version:0.2.1
Date:2025-02-03
URL:https://github.com/config-i1/legion
BugReports:https://github.com/config-i1/legion/issues
Language:en-GB
Description:Functions implementing multivariate state space models for purposes of time series analysis and forecasting. The focus of the package is on multivariate models, such as Vector Exponential Smoothing, Vector ETS (Error-Trend-Seasonal model) etc. It currently includes Vector Exponential Smoothing (VES, de Silva et al., 2010, <doi:10.1177/1471082X0901000401>), Vector ETS (Svetunkov et al., 2023, <doi:10.1016/j.ejor.2022.04.040>) and simulation function for VES.
License:LGPL-2.1
Depends:R (≥ 3.5.0), greybox (≥ 1.0.4), smooth (≥ 3.1.0)
Imports:Rcpp (≥ 0.12.3), stats, generics (≥ 0.1.2), graphics,grDevices, Matrix, nloptr, utils, zoo
LinkingTo:Rcpp, RcppArmadillo (≥ 0.8.100.0.0)
Suggests:numDeriv, testthat, knitr, rmarkdown, doMC, doParallel,foreach
VignetteBuilder:knitr
RoxygenNote:7.3.2
Encoding:UTF-8
NeedsCompilation:yes
Packaged:2025-02-03 14:14:35 UTC; config
Author:Ivan Svetunkov [aut, cre] (Senior Lecturer, Centre for Marketing Analytics and Forecasting, Lancaster University, UK), Kandrika Fadhlan Pritularga [aut] (Lecturer, Centre for Marketing Analytics and Forecasting, Lancaster University, UK)
Maintainer:Ivan Svetunkov <ivan@svetunkov.com>
Repository:CRAN
Date/Publication:2025-02-03 16:10:02 UTC

Legion package

Description

Package contains functions for multivariate time series forecasting

Details

Package: legion
Type: Package
Date:2021-02-18 - Inf
License: GPL-2

The following functions areincluded in the package:

Author(s)

Ivan Svetunkov,ivan@svetunkov.com

Kandrika Pritularga

References

See Also

forecast,es,adam

Examples

## Not run: y <- cbind(rnorm(100,10,3),rnorm(100,10,3))ves(y,h=20,holdout=TRUE)## End(Not run)

Vector ETS-PIC model

Description

Function constructs vector ETS model based on VETS-PIC taxonomy and returnsforecast, fitted values, errors and matrix of states along with other useful variables.

Usage

auto.vets(data, model = "PPP", lags = c(frequency(data)),  loss = c("likelihood", "diagonal", "trace"), ic = c("AICc", "AIC", "BIC",  "BICc"), h = 10, holdout = FALSE, occurrence = c("none", "fixed",  "logistic"), bounds = c("admissible", "usual", "none"), silent = TRUE,  parallel = FALSE, ...)vets(data, model = "PPP", lags = c(frequency(data)),  parameters = c("level", "trend", "seasonal", "damped"),  initials = c("seasonal"), components = c("none"),  loss = c("likelihood", "diagonal", "trace"), ic = c("AICc", "AIC", "BIC",  "BICc"), h = 10, holdout = FALSE, occurrence = c("none", "fixed",  "logistic"), bounds = c("admissible", "usual", "none"), silent = TRUE,  ...)

Arguments

data

The matrix with the data, where series are in columns andobservations are in rows.

model

The type of ETS model. Can consist of 3 or 4 chars:ANN,AAN,AAdN,AAA,AAdA,MMdM etc.PPP means that the best pure model will be selected based on the choseninformation criteria type.ATTENTION! ONLY PURE ADDITIVE AND PURE MULTIPLICATIVE MODELS AREAVAILABLE!Pure multiplicative models are done as additive model applied to log(y).

Alsomodel can accept a previously estimated VETS model and use all itsparameters.

lags

The lags of the model. Needed for seasonal models.

loss

Type of Loss Function used in optimization.loss canbe:

  • "likelihood" - which implies the maximisation of likelihood ofmultivariate normal distribution (or log Normal if the multiplicative modelis constructed);

  • "diagonal" - similar to"likelihood", but assumes thatcovariances between the error terms are zero.

  • "trace" - the trace of the covariance matrix of errors.The sum of variances is minimised in this case.

  • Provided by user as a custom function ofactual,fitted andB. Note that internally function transposes the data, so thatactualandfitted contain observations in columns and series in rows.

An example of the latter option is:lossFunction <- function(actual,fitted,B){return(mean(abs(actual - fitted)))}followed byloss=lossFunction.

ic

The information criterion used in the model selection procedure.

h

Length of forecasting horizon.

holdout

IfTRUE, holdout sample of sizeh is taken fromthe end of the data.

occurrence

Defines type of occurrence model used. Can be:

  • none, meaning that the data should be considered as non-intermittent;

  • fixed, taking into account constant Bernoulli distribution ofdemand occurrences;

  • logistic, based on logistic regression.

In this case, the ETS model inside the occurrence part will correspond tomodel andprobability="dependent".Alternatively, model estimated usingoves function can be providedhere.

bounds

What type of bounds to use in the model estimation. The firstletter can be used instead of the whole word."admissible" means that themodel stability is ensured, while"usual" means that the all the parametersare restricted by the (0, 1) region.

silent

Ifsilent="none", then nothing is silent, everything isprinted out and drawn.silent="all" means that nothing is produced ordrawn (except for warnings). In case ofsilent="graph", no graph isproduced. Ifsilent="legend", then legend of the graph is skipped.And finallysilent="output" means that nothing is printed out in theconsole, but the graph is produced.silent also acceptsTRUEandFALSE. In this casesilent=TRUE is equivalent tosilent="all", whilesilent=FALSE is equivalent tosilent="none". The parameter also accepts first letter of words ("n","a", "g", "l", "o").

parallel

If TRUE, the estimation of ADAM models is done in parallel (used inauto.adam only).If the number is provided (e.g.parallel=41), then the specified number of cores is set up.WARNING! Packagesforeach and eitherdoMC (Linux and Mac only)ordoParallel are needed in order to run the function in parallel.

...

Other non-documented parameters. For exampleFI=TRUE willmake the function also produce Fisher Information matrix, which then can beused to calculated variances of smoothing parameters and initial states ofthe model. The vector of initial parameter for the optimiser can be providedhere as the variableB. The upper bound for the optimiser is providedviaub, while the lower one islb. Also, the options for nloptr can bepassed here:

  • maxeval=40*k is the default number of iterations for both optimisersused in the function (k is the number of parameters to estimate).

  • algorithm1="NLOPT_LN_BOBYQA" is the algorithm used in the firstoptimiser, whilealgorithm2="NLOPT_LN_NELDERMEAD" is the second one.

  • xtol_rel1=1e-8 is the relative tolerance in the first optimiser,whilextol_rel2=1e-6 is for the second one. All of this can be amended andpassed in ellipsis for finer tuning.

  • print_level - the level of output for the optimiser (0 by default).If equal to 41, then the detailed results of the optimisation are returned.

parameters

The character vector, specifying, which of the parametersshould be common between time series. This includes smoothing parameters for"level","trend","seasonal" components and"damped"trend parameter. Ifparameters="none", then all parameters are set to beindividual. An example is the model with all parameters being common:parameters=c("level","trend","seasonal","damped"). The order is not importantand the first letters can be used instead of the full words as well.

initials

The character vector, specifying, which of the initial values ofcomponents should be common. This can be"level","trend" and / or"seasonal", setting initials of respective components to be common. Thiscan also be"none", making the initials individual for all series. Anexample is the model with only seasonal initials being common:initials="seasonal". The order is not important, and the first letters canbe used instead of the full words.

components

The character vector, specifying, which of the componentscomponents should be shared between time series. This can be"level","trend" and / or"seasonal", setting respective components to beshared. This can also be"none", making them individual for all series.The order is not important, and the first letters can be used instead of the fullwords. Please, note that making components common automatically sets therespectiveinitials common as well.

Details

Function estimates vector ETS in the form of the Single Source of Error state spacemodel of the following type:

\mathbf{y}_{t} = \mathbf{o}_{t} (\mathbf{W} \mathbf{v}_{t-l} + \mathbf{x}_t\mathbf{a}_{t-1} + \mathbf{\epsilon}_{t})

\mathbf{v}_{t} = \mathbf{F} \mathbf{v}_{t-l} + \mathbf{G}\mathbf{\epsilon}_{t}

\mathbf{a}_{t} = \mathbf{F_{X}} \mathbf{a}_{t-1} + \mathbf{G_{X}}\mathbf{\epsilon}_{t} / \mathbf{x}_{t}

Wherey_{t} is the vector of time series on observationt,o_{t}is the vector of Bernoulli distributed random variable (in case of normal data itbecomes unit vector for all observations),\mathbf{v}_{t} is the matrix ofstates andl is the matrix of lags,\mathbf{x}_t is the vector ofexogenous variables.\mathbf{W} is the measurement matrix,\mathbf{F}is the transition matrix and\mathbf{G} is the persistence matrix.Finally,\epsilon_{t} is the vector of error terms.

Conventionally we formulate values as:

\mathbf{y}'_t = (y_{1,t}, y_{2,t}, \dots, y_{m,t})

wherem is the number of series in the group.

\mathbf{v}'_t = (v_{1,t}, v_{2,t}, \dots, v_{m,t})

wherev_{i,t} is vector of components for i-th time series.

\mathbf{W}' = (w_{1}, \dots , 0;\vdots , \ddots , \vdots;0 , \vdots , w_{m})

is matrix of measurement vectors.

The main idea of the function is in imposing restrictions on parameters / initials /components of the model in order to capture the common dynamics between series.

In case of multiplicative model, instead of the vector y_t we use its logarithms.As a result the multiplicative model is much easier to work with.

For some more information about the model and its implementation, see thevignette:vignette("vets","legion")

Value

Object of class "legion" is returned. It contains the following list ofvalues:

Author(s)

Ivan Svetunkov,ivan@svetunkov.com

References

See Also

ves,es,adam

Examples

Y <- ts(cbind(rnorm(100,100,10),rnorm(100,75,8)),frequency=12)# The simplest model applied to the data with the default valuesvets(Y,model="ANN",h=10,holdout=TRUE)# Multiplicative damped trend model with common parameters# and initial seasonal indicesvets(Y,model="MMdM",h=10,holdout=TRUE,parameters=c("l","t","s","d"),     initials="seasonal")# Automatic selection of ETS componentsvets(Y, model="PPP", h=10, holdout=TRUE, initials="seasonal")

legion classes checkers

Description

Functions to check if an object is of the specified class

Usage

is.legion(x)is.oves(x)is.legion.sim(x)

Arguments

x

The object to check.

Details

The list of methods includes:

Value

TRUE if this is the specified class andFALSE otherwise.

Author(s)

Ivan Svetunkov,ivan@svetunkov.com

Examples

ourModel <- ves(cbind(rnorm(100,100,10),rnorm(100,100,10)))is.legion(ourModel)

Occurrence part of Vector State Space

Description

Function calculates the probability for the occurrence part of vector state space model.This is needed in order to forecast intermittent demand using other functions.

Usage

oves(data, occurrence = c("logistic", "none", "fixed"), ic = c("AICc",  "AIC", "BIC", "BICc"), h = 10, holdout = FALSE,  probability = c("dependent", "independent"), model = "ANN",  persistence = NULL, transition = NULL, phi = NULL, initial = NULL,  initialSeason = NULL, xreg = NULL, ...)

Arguments

data

The matrix with data, where series are in columns andobservations are in rows.

occurrence

Type of method used in probability estimation. Can be"none" - none,"fixed" - constant probability or"logistic" - probability based on logit model.

ic

Information criteria to use in case of model selection.

h

Forecast horizon.

holdout

IfTRUE, holdout sample of sizeh is taken fromthe end of the data.

probability

Type of probability assumed in the model. If"dependent", then it is assumed that occurrence of one variable isconnected with the occurrence with another one. In case of"independent"the occurrence of the variables is assumed to happen independent of eachother.

model

Type of ETS model used for the estimation. Normally this shouldbe either"ANN" or"MNN". If you assume that there are sometendencies in occurrence, then you can use more complicated models. Modelselection is not yet available.

persistence

Persistence matrix type. IfNULL, then it is estimated.Seeves for the details.

transition

Transition matrix type. IfNULL, then it is estimated.Seeves for the details.

phi

Damping parameter type. IfNULL, then it is estimated.Seeves for the details.

initial

Initial vector type. IfNULL, then it is estimated.Seeves for the details.

initialSeason

Type of the initial vector of seasonal components.IfNULL, then it is estimated. Seeves for the details.

xreg

Vector of matrix of exogenous variables, explaining some partsof occurrence variable (probability).

...

Other parameters. This is not needed for now.

Details

The function estimates probability of demand occurrence, using one of the VESstate-space models.

Value

The object of class "oves" is returned. It contains following list ofvalues:

Author(s)

Ivan Svetunkov,ivan@svetunkov.com

See Also

oes,ves

Examples

Y <- cbind(c(rpois(25,0.1),rpois(25,0.5),rpois(25,1),rpois(25,5)),           c(rpois(25,0.1),rpois(25,0.5),rpois(25,1),rpois(25,5)))oves(Y, occurrence="l")oves(Y, occurrence="l", probability="i")

Plots for the fit and states

Description

The function produces diagnostics plots for alegion model

Usage

## S3 method for class 'legion'plot(x, which = c(1, 2, 4, 6), level = 0.95,  legend = FALSE, ask = prod(par("mfcol")) < length(which) * nvariate(x) &&  dev.interactive(), lowess = TRUE, ...)

Arguments

x

Estimated legion model.

which

Which of the plots to produce. The possible options (see details for explanations):

  1. Actuals vs Fitted values;

  2. Standardised residuals vs Fitted;

  3. Studentised residuals vs Fitted;

  4. Absolute residuals vs Fitted;

  5. Squared residuals vs Fitted;

  6. Q-Q plot with the specified distribution;

  7. Fitted over time;

  8. Standardised residuals vs Time;

  9. Studentised residuals vs Time;

  10. ACF of the residuals;

  11. PACF of the residuals.

  12. Plot of states of the model.

level

Confidence level. Defines width of confidence interval. Used in plots (2), (3), (7), (8),(9), (10) and (11).

legend

IfTRUE, then the legend is produced on plots (2), (3) and (7).

ask

Logical; ifTRUE, the user is asked to press Enter before each plot.

lowess

Logical; ifTRUE, LOWESS lines are drawn on scatterplots, seelowess.

...

The parameters passed to the plot functions. Recommended to use with separate plots.

Details

The list of produced plots includes:

  1. Actuals vs Fitted values. Allows analysing, whether there are any issues in the fit.Does the variability of actuals increase with the increase of fitted values? Is the relationwell captured? They grey line on the plot corresponds to the perfect fit of the model.

  2. Standardised residuals vs Fitted. Plots the points and the confidence bounds(red lines) for the specified confidencelevel. Useful for the analysis of outliers;

  3. Studentised residuals vs Fitted. This is similar to the previous plot, but with theresiduals divided by the scales with the leave-one-out approach. Should be more sensitiveto outliers;

  4. Absolute residuals vs Fitted. Useful for the analysis of heteroscedasticity;

  5. Squared residuals vs Fitted - similar to (3), but with squared values;

  6. Q-Q plot with the specified distribution. Can be used in order to see if theresiduals follow the assumed distribution. The type of distribution depends on the one usedin the estimation (seedistribution parameter inalm);

  7. ACF of the residuals. Are the residuals autocorrelated? Seeacf fordetails;

  8. Fitted over time. Plots actuals (black line), fitted values (purple line), point forecast(blue line) and prediction interval (grey lines). Can be used in order to make sure that the modeldid not miss any important events over time;

  9. Standardised residuals vs Time. Useful if you want to see, if there is autocorrelation orif there is heteroscedasticity in time. This also shows, when the outliers happen;

  10. Studentised residuals vs Time. Similar to previous, but with studentised residuals;

  11. PACF of the residuals. No, really, are they autocorrelated? See pacf function from statspackage for details;

  12. Plot of the states of the model. It is not recommended to produce this plot together withthe others, because there might be several states, which would cause the creation of a differentcanvas. In case of "msdecompose", this will produce the decomposition of the series into stateson a different canvas.

Which of the plots to produce, is specified via thewhich parameter.Currently onlywhich=c(1,4:7) are supported.

Value

The function produces the number of plots, specified in the parameterwhich.

Author(s)

Ivan Svetunkov,ivan@svetunkov.com

See Also

plot.greybox

Examples

ourModel <- es(c(rnorm(50,100,10),rnorm(50,120,10)), "ANN", h=10)plot(ourModel, c(1:11))plot(ourModel, 12)

Simulate Vector Exponential Smoothing

Description

Function generates data using VES model as a data generating process.

Usage

sim.ves(model = "ANN", obs = 10, nsim = 1, nvariate = 2,  frequency = 1, persistence = NULL, phi = 1, transition = NULL,  initial = NULL, initialSeason = NULL,  seasonal = c("individual, common"), weights = rep(1/nvariate, nvariate),  bounds = c("usual", "admissible", "restricted"), randomizer = c("rnorm",  "rt", "rlaplace", "rs"), ...)

Arguments

model

Type of ETS model. This can consist of 3 or 4 chars:ANN,AAN,AAdN,AAA,AAdA etc.Only pure additive models are supported. If you want to have multiplicativeone, then just take exponent of the generated data.

obs

Number of observations in each generated time series.

nsim

Number of series to generate (number of simulations to do).

nvariate

Number of series in each generated group of series.

frequency

Frequency of generated data. In cases of seasonal modelsmust be greater than 1.

persistence

Matrix of smoothing parameters for all the componentsof all the generated time series.

phi

Value of damping parameter. If trend is not chosen in the model,the parameter is ignored. If vector is provided, then several parametersare used for different series.

transition

Transition matrix. This should have the size appropriateto the selected model andnvariate. e.g. if ETS(A,A,N) is selectedandnvariate=3, then the transition matrix should be 6 x 6. In caseof damped trend, the phi parameter should be placed in the matrix manually.ifNULL, then the default transition matrix for the selected typeof model is used. If bothphi andtransition are provided,then the value ofphi is ignored.

initial

Vector of initial states of level and trend. The minimumlength is one (in case of ETS(A,N,N), the initial is used for all theseries), the maximum length is 2 x nvariate. IfNULL, values aregenerated for each series.

initialSeason

Vector or matrix of initial states for seasonalcoefficients. Should have number of rows equal tofrequencyparameter. IfNULL, values are generated for each series.

seasonal

The type of seasonal component across the series. Can be"individual", so that each series has its own component or"common",so that the component is shared across the series.

weights

The weights for the errors between the series with the commonseasonal component. Ignored ifseasonal="individual".

bounds

Type of bounds to use for persistence vector if values aregenerated."usual" - bounds from p.156 by Hyndman et. al., 2008."restricted" - similar to"usual" but with upper bound equalto 0.3."admissible" - bounds from tables 10.1 and 10.2 of Hyndmanet. al., 2008. Using first letter of the type of bounds also works.

randomizer

Type of random number generator function used for errorterm. Defaults are:rnorm,rt,rlaplace,rs. Butany function fromDistributions will do the trick if theappropriate parameters are passed.mvrnorm from MASS package can alsobe used.

...

Additional parameters passed to the chosen randomizer. All theparameters should be passed in the order they are used in chosen randomizer.For example, passing justsd=0.5 tornorm function will leadto the callrnorm(obs, mean=0.5, sd=1). ATTENTION! When generatingthe multiplicative errors some tuning might be needed to obtain meaningfuldata.sd=0.1 is usually already a high value for such models.

Value

List of the following values is returned:

Author(s)

Ivan Svetunkov,ivan@svetunkov.com

References

See Also

ves,Distributions

Examples

# Create 40 observations of quarterly data using AAA model with errors# from normal distributionVESAAA <- sim.ves(model="AAA",frequency=4,obs=40,nvariate=3,                   randomizer="rnorm",mean=0,sd=100)# You can also use mvrnorm function from MASS package as randomizer,# but you need to provide mu and Sigma explicitly## Not run: VESANN <- sim.ves(model="ANN",frequency=4,obs=40,nvariate=2,                   randomizer="mvrnorm",mu=c(100,50),sigma=matrix(c(40,20,20,30),2,2))## End(Not run)# When generating the data with multiplicative model a more diligent definitiion# of parameters is needed. Here's an example with MMM model:VESMMM <- sim.ves("AAA", obs=120, nvariate=2, frequency=12, initial=c(10,0),          initialSeason=runif(12,-1,1), persistence=c(0.06,0.05,0.2), mean=0, sd=0.03)VESMMM$data <- exp(VESMMM$data)# Note that smoothing parameters should be low and the standard diviation should# definitely be less than 0.1. Otherwise you might face the explosions.

Vector Exponential Smoothing in SSOE state space model

Description

Function constructs vector ETS model and returns forecast, fitted values, errorsand matrix of states along with other useful variables.

Usage

ves(data, model = "PPP", lags = c(frequency(data)),  persistence = c("common", "individual", "dependent"),  transition = c("common", "individual", "dependent"), phi = c("common",  "individual"), initial = c("individual", "common"),  initialSeason = c("common", "individual"), loss = c("likelihood",  "diagonal", "trace"), ic = c("AICc", "AIC", "BIC", "BICc"), h = 10,  holdout = FALSE, occurrence = c("none", "fixed", "logistic"),  bounds = c("admissible", "usual", "none"), silent = TRUE, ...)

Arguments

data

The matrix with the data, where series are in columns andobservations are in rows.

model

The type of ETS model. Can consist of 3 or 4 chars:ANN,AAN,AAdN,AAA,AAdA,MMdM etc.PPP means that the best pure model will be selected based on the choseninformation criteria type.ATTENTION! ONLY PURE ADDITIVE AND PURE MULTIPLICATIVE MODELS AREAVAILABLE!Pure multiplicative models are done as additive model applied to log(y).

Alsomodel can accept a previously estimated VES model and use all itsparameters.

lags

The lags of the model. Needed for seasonal models.

persistence

Persistence matrixG, containing smoothingparameters. Can be:

  • "independent" - each series has its own smoothing parametersand no interactions are modelled (all the other values in the matrix are setto zero);

  • "dependent" - each series has its own smoothing parameters, butinteractions between the series are modelled (the whole matrix is estimated);

  • "group" each series has the same smoothing parameters for respectivecomponents (the values of smoothing parameters are repeated, all the other valuesin the matrix are set to zero).

  • "seasonal" - each component has its own smoothing parameter, exceptfor the seasonal one, which is common across the time series.

  • provided by user as a vector or as a matrix. The value is used by the model.

You can also use the first letter instead of writing the full word.

transition

Transition matrixF. Can be:

  • "independent" - each series has its own preset transition matrixand no interactions are modelled (all the other values in the matrix are setto zero);

  • "dependent" - each series has its own transition matrix, butinteractions between the series are modelled (the whole matrix is estimated). Theestimated model behaves similar to VAR in this case;

  • "group" each series has the same transition matrix for respectivecomponents (the values are repeated, all the other values in the matrix are set tozero).

  • provided by user as a vector or as a matrix. The value is used by the model.

You can also use the first letter instead of writing the full word.

phi

In cases of damped trend this parameter defines whether thephishould be estimated separately for each series ("individual") or for the wholeset ("common"). If vector or a value is provided here, then it is used by themodel.

initial

Can be either character or a vector / matrix of initial states.If it is character, then it can be"individual", individual values ofthe initial non-seasonal components are used, or"common", meaning thatthe initials for all the time series are set to be equal to the same value.If vector of states is provided, then it is automatically transformed intoa matrix, assuming that these values are provided for the whole group.

initialSeason

Can be either character or a vector / matrix of initialstates. Treated the same way asinitial. This means that different timeseries may share the same initial seasonal component.

loss

Type of Loss Function used in optimization.loss canbe:

  • "likelihood" - which implies the maximisation of likelihood ofmultivariate normal distribution (or log Normal if the multiplicative modelis constructed);

  • "diagonal" - similar to"likelihood", but assumes thatcovariances between the error terms are zero.

  • "trace" - the trace of the covariance matrix of errors.The sum of variances is minimised in this case.

  • Provided by user as a custom function ofactual,fitted andB. Note that internally function transposes the data, so thatactualandfitted contain observations in columns and series in rows.

An example of the latter option is:lossFunction <- function(actual,fitted,B){return(mean(abs(actual - fitted)))}followed byloss=lossFunction.

ic

The information criterion used in the model selection procedure.

h

Length of forecasting horizon.

holdout

IfTRUE, holdout sample of sizeh is taken fromthe end of the data.

occurrence

Defines type of occurrence model used. Can be:

  • none, meaning that the data should be considered as non-intermittent;

  • fixed, taking into account constant Bernoulli distribution ofdemand occurrences;

  • logistic, based on logistic regression.

In this case, the ETS model inside the occurrence part will correspond tomodel andprobability="dependent".Alternatively, model estimated usingoves function can be providedhere.

bounds

What type of bounds to use in the model estimation. The firstletter can be used instead of the whole word."admissible" means that themodel stability is ensured, while"usual" means that the all the parametersare restricted by the (0, 1) region.

silent

Ifsilent="none", then nothing is silent, everything isprinted out and drawn.silent="all" means that nothing is produced ordrawn (except for warnings). In case ofsilent="graph", no graph isproduced. Ifsilent="legend", then legend of the graph is skipped.And finallysilent="output" means that nothing is printed out in theconsole, but the graph is produced.silent also acceptsTRUEandFALSE. In this casesilent=TRUE is equivalent tosilent="all", whilesilent=FALSE is equivalent tosilent="none". The parameter also accepts first letter of words ("n","a", "g", "l", "o").

...

Other non-documented parameters. For exampleFI=TRUE willmake the function also produce Fisher Information matrix, which then can beused to calculated variances of smoothing parameters and initial states ofthe model. The vector of initial parameter for the optimiser can be providedhere as the variableB. The upper bound for the optimiser is providedviaub, while the lower one islb. Also, the options for nloptr can bepassed here:

  • maxeval=40*k is the default number of iterations for both optimisersused in the function (k is the number of parameters to estimate).

  • algorithm1="NLOPT_LN_BOBYQA" is the algorithm used in the firstoptimiser, whilealgorithm2="NLOPT_LN_NELDERMEAD" is the second one.

  • xtol_rel1=1e-8 is the relative tolerance in the first optimiser,whilextol_rel2=1e-6 is for the second one. All of this can be amended andpassed in ellipsis for finer tuning.

  • print_level - the level of output for the optimiser (0 by default).If equal to 41, then the detailed results of the optimisation are returned.

Details

Function estimates vector ETS in a form of the Single Source of Error state spacemodel of the following type:

\mathbf{y}_{t} = (\mathbf{W} \mathbf{v}_{t-l} + \mathbf{x}_t\mathbf{a}_{t-1} + \mathbf{\epsilon}_{t})

\mathbf{v}_{t} = \mathbf{F} \mathbf{v}_{t-l} + \mathbf{G}\mathbf{\epsilon}_{t}

\mathbf{a}_{t} = \mathbf{F_{X}} \mathbf{a}_{t-1} + \mathbf{G_{X}}\mathbf{\epsilon}_{t} / \mathbf{x}_{t}

Wherey_{t} is the vector of time series on observationt,\mathbf{v}_{t} is the matrix ofstates andl is the matrix of lags,\mathbf{x}_t is the vector ofexogenous variables.\mathbf{W} is the measurement matrix,\mathbf{F}is the transition matrix and\mathbf{G} is the persistence matrix.Finally,\epsilon_{t} is the vector of error terms.

Conventionally we formulate values as:

\mathbf{y}'_t = (y_{1,t}, y_{2,t}, \dots, y_{m,t})

wherem is the number of series in the group.

\mathbf{v}'_t = (v_{1,t}, v_{2,t}, \dots, v_{m,t})

wherev_{i,t} is vector of components for i-th time series.

\mathbf{W}' = (w_{1}, \dots , 0;\vdots , \ddots , \vdots;0 , \vdots , w_{m})

is matrix of measurement vectors.

For the details on the additive model see Hyndman et al. (2008),chapter 17.

In case of multiplicative model, instead of the vector y_t we use its logarithms.As a result the multiplicative model is much easier to work with.

For some more information about the model and its implementation, see thevignette:vignette("ves","legion")

Value

Object of class "legion" is returned. It contains the following list ofvalues:

Author(s)

Ivan Svetunkov,ivan@svetunkov.com

References

See Also

vets,es,adam

Examples

Y <- ts(cbind(rnorm(100,100,10),rnorm(100,75,8)),frequency=12)# The simplest model applied to the data with the default valuesves(Y,model="ANN",h=10,holdout=TRUE)# Damped trend model with the dependent persistenceves(Y,model="AAdN",persistence="d",h=10,holdout=TRUE)# Multiplicative damped trend model with individual phives(Y,model="MMdM",persistence="i",h=10,holdout=TRUE,initialSeason="c")# Automatic selection between pure modelsves(Y,model="PPP",persistence="i",h=10,holdout=TRUE,initialSeason="c")# Intermittent demand vector modelY <- cbind(c(rpois(25,0.1),rpois(25,0.5),rpois(25,1),rpois(25,5)),           c(rpois(25,0.1),rpois(25,0.5),rpois(25,1),rpois(25,5)))ves(Y,model="MNN",h=10,holdout=TRUE,occurrence="l")

[8]ページ先頭

©2009-2025 Movatter.jp