simulate
Monte Carlo simulation of univariate ARIMA or ARIMAX models
Syntax
Description
uses additional options specified by one or more name-value arguments.
Y = simulate(Mdl,numobs,Name=Value)simulate returns numeric arrays when all optional input data are
numeric arrays. For example, simulate(Mdl,100,NumPaths=1000,Y0=PS)
returns a numeric array of 1000, 100-period simulated response paths from
Mdl and specifies the numeric array of presample response data
PS.
[
uses any input-argument combination in the previous syntaxes to return numeric arrays of
one or more independent series of model innovations Y,E,V] = simulate(___)E and, when
Mdl represents a composite conditional mean and variance model,
conditional variances V, resulting from simulating the ARIMA
model.
returns the table or timetable Tbl = simulate(Mdl,numobs,Presample=Presample,PresampleResponseVariable=PresampleResponseVariable)Tbl containing a variable for each of
the random paths of response, innovation, and conditional variance series resulting from
simulating the ARIMA model Mdl. simulate uses
the response variable PresampleResponseVariable in the table or
timetable of presample data Presample to initialize the response
series. (since R2023b)
To initialize the model using presample innovation or conditional variance data,
replace the PresampleResponseVariable name-value argument with
PresampleInnovationVariable or
PresampleVarianceVariable name-value argument.
specifies the variables Tbl = simulate(Mdl,numobs,InSample=InSample,PredictorVariables=PredictorVariables)PredictorVariables in the in-sample table or
timetable of data InSample containing the predictor data for the
exogenous regression component in the ARIMA model Mdl. (since R2023b)
specifies presample response data to initialize the model and in-sample predictor data for
the exogenous regression component. (since R2023b)Tbl = simulate(Mdl,numobs,Presample=Presample,PresampleResponseVariable=PresampleResponseVariable,InSample=InSample,PredictorVariables=PredictorVariables)
uses additional options specified by one or more name-value arguments, using any input
argument combination in the previous three syntaxes. (since R2023b)Tbl = simulate(___,Name=Value)
For example,
simulate(Mdl,100,NumPaths=1000,Presample=PSTbl,PresampleResponseVariables="GDP")
returns a timetable containing a variable for each of the response, innovations, and
conditional variance series. Each variable is a 100-by-1000 matrix representing 1000,
100-period paths simulated from the ARIMA model. simulate
initializes the model by using the presample data in the GDP variable
of the timetable PSTbl.
Examples
Simulate a response path from an ARIMA model. Return the path in a vector.
Consider the ARIMA(4,1,1) model
where is a Gaussian innovations series with a mean of 0 and a variance of 1.
Create the ARIMA(4,1,1) model.
Mdl = arima(AR=-0.75,ARLags=4,MA=0.1,Constant=2,Variance=1)
Mdl =
arima with properties:
Description: "ARIMA(4,0,1) Model (Gaussian Distribution)"
SeriesName: "Y"
Distribution: Name = "Gaussian"
P: 4
D: 0
Q: 1
Constant: 2
AR: {-0.75} at lag [4]
SAR: {}
MA: {0.1} at lag [1]
SMA: {}
Seasonality: 0
Beta: [1×0]
Variance: 1
Mdl is a fully specified arima object representing the ARIMA(4,1,1) model.
Simulate a 100-period random response path from the ARIMA(4,1,1) model.
rng(1,"twister") % For reproducibility y = simulate(Mdl,100);
y is a 100-by-1 vector containing the random response path.
Plot the simulated path.
plot(y) ylabel("y") xlabel("Time")

Simulate three predictor series and a response series.
Specify and simulate a path of length 20 for each of the three predictor series modeled by
where follows a Gaussian distribution with mean 0 and variance 0.01, and = {1,2,3}.
[MdlX1,MdlX2,MdlX3] = deal(arima(AR=0.2,MA={0.5 -0.3}, ...
Constant=2,Variance=0.01));
rng(4,"twister"); % For reproducibility
simX1 = simulate(MdlX1,20);
simX2 = simulate(MdlX2,20);
simX3 = simulate(MdlX3,20);
SimX = [simX1 simX2 simX3];Specify and simulate a path of length 20 for the response series modeled by
where follows a Gaussian distribution with mean 0 and variance 1.
MdlY = arima(AR={0.05 -0.02 0.01},MA={0.04 0.01}, ...
D=1,Constant=0.5,Variance=1,Beta=[0.5 -0.03 -0.7]);
simY = simulate(MdlY,20,X=SimX);Plot the series together.
figure plot([SimX simY]) title("Simulated Series") legend("x_1","x_2","x_3","y")

Forecast the daily NASDAQ Composite Index using Monte Carlo simulations. Supply presample observations to initialize the model.
Load the NASDAQ data included with the toolbox. Extract the first 1500 observations for fitting.
load Data_EquityIdx
nasdaq = DataTable.NASDAQ(1:1500);
T = length(nasdaq);Fit an ARIMA(1,1,1) model.
NasdaqModel = arima(1,1,1); NasdaqFit = estimate(NasdaqModel,nasdaq);
ARIMA(1,1,1) Model (Gaussian Distribution):
Value StandardError TStatistic PValue
_________ _____________ __________ __________
Constant 0.43031 0.18555 2.319 0.020393
AR{1} -0.074391 0.081985 -0.90737 0.36421
MA{1} 0.31126 0.077266 4.0284 5.6158e-05
Variance 27.826 0.63625 43.735 0
Simulate 1000 paths with 500 observations each. Use the observed data as presample data.
rng(1,"twister");
Y = simulate(NasdaqFit,500,NumPaths=1000,Y0=nasdaq);Plot the simulation mean forecast and approximate 95% forecast intervals.
lower = prctile(Y,2.5,2); upper = prctile(Y,97.5,2); mn = mean(Y,2); x = T + (1:500); figure plot(nasdaq,Color=[.7,.7,.7]) hold on h1 = plot(x,lower,"r:",LineWidth=2); plot(x,upper,"r:",LineWidth=2) h2 = plot(x,mn,"k",LineWidth=2); legend([h1 h2],"95% confidence interval","Simulation mean", ... Location="NorthWest") title("NASDAQ Composite Index Forecast") hold off

Simulate response and innovation paths from a multiplicative seasonal model.
Specify the model
where follows a Gaussian distribution with mean 0 and variance 0.1.
Mdl = arima(MA=-0.5,SMA=0.3,SMALags=12,D=1, ...
Seasonality=12,Variance=0.1,Constant=0);Simulate 500 paths with 100 observations each.
rng(1,"twister") % For reproducibility [Y,E] = simulate(Mdl,100,NumPaths=500); figure tiledlayout(2,1) nexttile plot(Y) title("Simulated Response") nexttile plot(E) title("Simulated Innovations")

Plot the 2.5th, 50th (median), and 97.5th percentiles of the simulated response paths.
lower = prctile(Y,2.5,2); middle = median(Y,2); upper = prctile(Y,97.5,2); figure plot(1:100,lower,"r:",1:100,middle,"k", ... 1:100,upper,"r:") legend("95% confidence interval","Median")

Compute statistics across the second dimension (across paths) to summarize the sample paths.
Plot a histogram of the simulated paths at time 100.
figure
histogram(Y(100,:),10)
title("Response Distribution at Time 100")
Fit an ARIMA(1,1,1) model to the weekly average NYSE closing prices. Supply a timetable of presample responses to initialize the model and return a timetable of simulated values from the model.
Load Data
Load the US equity index data set Data_EquityIdx.
load Data_EquityIdx
T = height(DataTimeTable)T = 3028
The timetable DataTimeTable includes the time series variable NYSE, which contains daily NYSE composite closing prices from January 1990 through December 2001.
Plot the daily NYSE price series.
figure
plot(DataTimeTable.Time,DataTimeTable.NYSE)
title("NYSE Daily Closing Prices: 1990 - 2001")
Prepare Timetable for Estimation
When you plan to supply a timetable, you must ensure it has all the following characteristics:
The selected response variable is numeric and does not contain any missing values.
The timestamps in the
Timevariable are regular, and they are ascending or descending.
Remove all missing values from the timetable, relative to the NYSE price series.
DTT = rmmissing(DataTimeTable,DataVariables="NYSE");
T_DTT = height(DTT)T_DTT = 3028
Because all sample times have observed NYSE prices, rmmissing does not remove any observations.
Determine whether the sampling timestamps have a regular frequency and are sorted.
areTimestampsRegular = isregular(DTT,"days")areTimestampsRegular = logical
0
areTimestampsSorted = issorted(DTT.Time)
areTimestampsSorted = logical
1
areTimestampsRegular = 0 indicates that the timestamps of DTT are irregular. areTimestampsSorted = 1 indicates that the timestamps are sorted. Business day rules make daily macroeconomic measurements irregular.
Remedy the time irregularity by computing the weekly average closing price series of all timetable variables.
DTTW = convert2weekly(DTT,Aggregation="mean"); areTimestampsRegular = isregular(DTTW,"weeks")
areTimestampsRegular = logical
1
T_DTTW = height(DTTW)
T_DTTW = 627
DTTW is regular.
figure
plot(DTTW.Time,DTTW.NYSE)
title("NYSE Daily Closing Prices: 1990 - 2001")
Create Model Template for Estimation
Suppose that an ARIMA(1,1,1) model is appropriate to model NYSE composite series during the sample period.
Create an ARIMA(1,1,1) model template for estimation.
Mdl = arima(1,1,1);
Mdl is a partially specified arima model object.
Fit Model to Data
infer requires Mdl.P presample observations to initialize the model. infer backcasts for necessary presample responses, but you can provide a presample.
Partition the data into presample and in-sample, or estimation sample, observations.
T0 = Mdl.P; DTTW0 = DTTW(1:T0,:); DTTW1 = DTTW((T0+1):end,:);
Fit an ARIMA(1,1,1) model to the in-sample weekly average NYSE closing prices. Specify the response variable name, presample timetable, and the presample response variable name.
EstMdl = estimate(Mdl,DTTW1,ResponseVariable="NYSE", ... Presample=DTTW0,PresampleResponseVariable="NYSE");
ARIMA(1,1,1) Model (Gaussian Distribution):
Value StandardError TStatistic PValue
________ _____________ __________ ___________
Constant 0.83623 0.453 1.846 0.064892
AR{1} -0.32862 0.23526 -1.3968 0.16246
MA{1} 0.42703 0.22613 1.8885 0.058964
Variance 56.065 1.8433 30.416 3.3806e-203
EstMdl is a fully specified, estimated arima model object.
Simulate Model
Simulate the fitted model 20 weeks beyond the final period. Specify the entire in-sample data as a presample and the presample response variable name in the in-sample timetable.
rng(1,"twister") % For reproducibility numobs = 20; Tbl = simulate(EstMdl,numobs,Presample=DTTW1, ... PresampleResponseVariable="NYSE"); tail(Tbl)
Time Y_Response Y_Innovation Y_Variance
___________ __________ ____________ __________
05-Apr-2002 564.68 -11.302 56.065
12-Apr-2002 570.47 6.5582 56.065
19-Apr-2002 570.39 -1.8179 56.065
26-Apr-2002 571.72 1.249 56.065
03-May-2002 557.94 -14.716 56.065
10-May-2002 547.51 -9.5098 56.065
17-May-2002 556.51 8.7992 56.065
24-May-2002 573.34 15.194 56.065
size(Tbl)
ans = 1×2
20 3
Tbl is a 20-by-3 timetable containing the simulated response path NYSE_Response, the corresponding simulated innovation path NYSE_Innovation, and the constant variance path NYSE_Variance (Mdl.Variance = 56.065).
Plot the simulated responses.
figure plot(DTTW1.Time((end-50):end),DTTW1.NYSE((end-50):end), ... Color=[0.7 0.7 0.7],LineWidth=2); hold on plot(Tbl.Time,Tbl.Y_Response,LineWidth=2); legend("Observed","Simulated responses") title("Weekly Average NYSE CLosing Prices") hold off

Fit an ARIMAX(1,1,1) model to the weekly average NYSE closing prices. Include an exogenous regression term identifying whether a measurement observation occurs during a recession. Supply timetables of presample and in-sample exogenous data. Simulate the weekly average closing prices over a 10-week horizon, and compare the forecasts to held out data.
Load the US equity index data set Data_EquityIdx.
load Data_EquityIdx
T = height(DataTimeTable)T = 3028
Remedy the time irregularity by computing the weekly average closing price series of all timetable variables.
DTTW = convert2weekly(DataTimeTable,Aggregation="mean");
T_DTTW = height(DTTW)T_DTTW = 627
Load the US recessions data set.
load Data_Recessions RDT = datetime(Recessions,ConvertFrom="datenum", ... Format="yyyy-MM-dd");
Determine whether each sampling time in the data occurs during a US recession.
isrecession = @(x)any(isbetween(x,RDT(:,1),RDT(:,2))); DTTW.IsRecession = arrayfun(isrecession,DTTW.Time)*1;
DTTW contains a variable IsRecession, which represents the exogenous variable in the ARIMAX model.
Create an ARIMA(1,1,1) model template for estimation. Set the response series name to NYSE.
Mdl = arima(1,1,1);
Mdl.SeriesName = "NYSE";Partition the data into required presample, in-sample (estimation sample), and 10 holdout sample observations.
T0 = Mdl.P; T2 = 10; DTTW0 = DTTW(1:T0,:); DTTW1 = DTTW((T0+1):(end-T2),:); DTTW2 = DTTW((end-T2+1):end,:);
Fit an ARIMA(1,1,1) model to the in-sample weekly average NYSE closing prices. Specify the presample timetable, the presample response variable name, and the in-sample predictor variable name.
EstMdl = estimate(Mdl,DTTW1,Presample=DTTW0,PresampleResponseVariable="NYSE", ... PredictorVariables="IsRecession");
ARIMAX(1,1,1) Model (Gaussian Distribution):
Value StandardError TStatistic PValue
________ _____________ __________ ___________
Constant 1.0635 0.50013 2.1264 0.033468
AR{1} -0.33828 0.2088 -1.6201 0.1052
MA{1} 0.43879 0.20045 2.189 0.028593
Beta(1) -2.425 1.0861 -2.2327 0.02557
Variance 55.527 1.9255 28.838 7.0988e-183
Simulate 1000 paths of responses from the fitted model into a 10-week horizon. Specify the in-sample data as a presample, the presample response variable name, the predictor data in the forecast horizon, and the predictor variable name.
rng(1,"twister") Tbl = simulate(EstMdl,T2,Presample=DTTW1,PresampleResponseVariable="NYSE", ... InSample=DTTW2,PredictorVariables="IsRecession",NumPaths=1000);
Tbl is a 10-by-6 timetable containing all variables in InSample, and the following variables:
NYSE_Response: a 10-by-1000 matrix of 1000 random response paths simulated from the model.NYSE_Innovation: a 10-by-1000 matrix of 1000 random innovation paths filtered through the model to product the response pathsNYSE_Variance: a 10-by-1000 matrix containing only the constantMdl.Variance = 55.527.
Plot the observed responses, median of the simulated responses, a 95% percentile intervals of the simulated values.
SimStats = quantile(Tbl.NYSE_Response,[0.025 0.5 0.975],2); figure h1 = plot(DTTW.Time((end-50):end),DTTW.NYSE((end-50):end),"k",LineWidth=2); hold on plot(Tbl.Time,Tbl.NYSE_Response,Color=[0.8 0.8 0.8]) h2 = plot(Tbl.Time,SimStats(:,2),'r--'); h3 = plot(Tbl.Time,SimStats(:,[1 3]),'b--'); legend([h1 h2 h3(1)],["Observations" "Sim. medians" "95% percentile intervals"]) title("NYSE Weekly Average Price Series and Monte Carlo Forecasts")

Input Arguments
Sample path length, specified as a positive integer. numobs is the number of random observations to generate per output path.
Data Types: double
Since R2023b
Presample data containing paths of responses
yt, innovations
εt, or conditional variances
σt2 to
initialize the model, specified as a table or timetable with
numprevars variables and numpreobs rows.
simulate returns the simulated variables in the output table
or timetable Tbl, which is the same type as
Presample. If Presample is a timetable,
Tbl is a timetable that immediately follows
Presample in time with respect to the sampling frequency.
Each selected variable is a single path (numpreobs-by-1 vector)
or multiple paths (numpreobs-by-numprepaths
matrix) of numpreobs observations representing the presample of
numpreobs observations of responses, innovations, or conditional
variances.
Each row is a presample observation, and measurements in each row occur
simultaneously. The last row contains the latest presample observation.
numpreobs must be one of the following values:
At least
Mdl.PwhenPresampleprovides only presample responsesAt least
Mdl.QwhenPresampleprovides only presample disturbances or conditional variancesAt least
max([Mdl.P Mdl.Q])otherwise
When Mdl.Variance is a conditional variance model,
simulate can require more than the minimum required number of
presample values.
If numpreobs exceeds the minimum number,
simulate uses the latest required number of observations
only.
If numprepaths > NumPaths,
simulate uses only the first NumPaths
columns.
If Presample is a timetable, all the following conditions must
be true:
If Presample is a table, the last row contains the latest
presample observation.
By default, simulate sets the following values:
For necessary presample responses:
The unconditional mean of the model when
Mdlrepresents a stationary AR process without a regression componentZero when
Mdlrepresents a nonstationary process or when it contains a regression component.
For necessary presample disturbances, zero.
For necessary presample conditional variances, the unconditional variance of the conditional variance model n
Mdl.Variance.
If you specify the Presample, you must specify the presample
response, innovation, or conditional variance variable name by using the
PresampleResponseVariable,
PresampleInnovationVariable, or
PresampleVarianceVariable name-value argument.
Since R2023b
Response variable yt to select from
Presample containing presample response data, specified as one of
the following data types:
String scalar or character vector containing a variable name in
Presample.Properties.VariableNamesVariable index (positive integer) to select from
Presample.Properties.VariableNamesA logical vector, where
PresampleResponseVariable(selects variablej) = truefromjPresample.Properties.VariableNames
The selected variable must be a numeric matrix and cannot contain missing values
(NaNs).
If you specify presample response data by using the Presample
name-value argument, you must specify
PresampleResponseVariable.
Example: PresampleResponseVariable="Stock0"
Example: PresampleResponseVariable=[false false true false] or
PresampleResponseVariable=3 selects the third table variable as
the presample response variable.
Data Types: double | logical | char | cell | string
Since R2023b
In-sample predictor data for the exogenous regression component of the model,
specified as a table or timetable. InSample contains
numvars variables, including numpreds predictor
variables xt.
simulate returns the simulated variables in the output table
or timetable Tbl, which is commensurate with
InSample.
Each row corresponds to an observation in the simulation horizon, the first row is
the earliest observation, and measurements in each row, among all paths, occur
simultaneously. InSample must have at least
numobs rows to cover the simulation horizon. If you supply more
rows than necessary, simulate uses only the first
numobs rows.
Each selected predictor variable is a numeric vector without missing values
(NaNs). All predictor variables are present in the regression
component of each response equation and apply to all response paths.
If InSample is a timetable, the following conditions apply:
If InSample is a table, the last row contains the latest
observation.
By default, simulate does not include the regression
component in the model, regardless of the value of Mdl.Beta.
Exogenous predictor variables xt to select
from InSample containing predictor data for the regression component,
specified as one of the following data types:
String vector or cell vector of character vectors containing
numpredsvariable names inInSample.Properties.VariableNamesA vector of unique indices (positive integers) of variables to select from
InSample.Properties.VariableNamesA logical vector, where
PredictorVariables(selects variablej) = truefromjInSample.Properties.VariableNames
The selected variables must be numeric vectors and cannot contain missing values
(NaNs).
By default, simulate excludes the regression component,
regardless of its presence in Mdl.
Example: PredictorVariables=["M1SL" "TB3MS"
"UNRATE"]
Example: PredictorVariables=[true false true false] or
PredictorVariable=[1 3] selects the first and third table variables
to supply the predictor data.
Data Types: double | logical | char | cell | string
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name in quotes.
Example: simulate(Mdl,10,NumPaths=1000,Y0=y0) simulates
1000 sample paths of length 10 from the ARIMA model
Mdl, and uses the observations in y0 as a presample
to initialize each generated path.
Number of independent sample paths to generate, specified as a positive integer.
Example: NumPaths=1000
Data Types: double
Presample response data yt used as
initial values for the model, specified as a numpreobs-by-1 numeric
column vector or a numpreobs-by-numprepaths
numeric matrix. Use Y0 only when you supply optional data inputs as
numeric arrays.
numpreobs is the number of presample observations.
numprepaths is the number of presample response paths.
Each row is a presample observation (sampling time), and measurements in each row
occur simultaneously. The last row contains the latest presample observation.
numpreobs must be at least Mdl.P to initialize
the AR model component. If numpreobs > Mdl.P,
simulate uses the latest required number of observations
only.
Columns of Y0 are separate, independent presample paths. The
following conditions apply:
If
Y0is a column vector, it represents a single response path.simulateapplies it to each output path.If
Y0is a matrix,simulateappliesY0(:,to initialize pathj)j.Y0must have at leastNumPathscolumns;simulateuses only the firstNumPathscolumns ofY0.
By default, simulate sets any necessary presample
responses to one of the following values:
The unconditional mean of the model when
Mdlrepresents a stationary AR process without a regression componentZero when
Mdlrepresents a nonstationary process or when it contains a regression component
Data Types: double
Presample innovation data εt used to
initialize either the moving average (MA) component of the ARIMA model or the
conditional variance model, specified as a numpreobs-by-1 numeric
column vector or a numpreobs-by-numprepaths
matrix. Use E0 only when you supply optional data inputs as numeric
arrays.
Each row is a presample observation (sampling time), and measurements in each row
occur simultaneously. The last row contains the latest presample observation.
numpreobs must be at least Mdl.Q to initialize
the MA model component. If Mdl.Variance is a conditional variance
model (for example, a garch model object),
simulate can require more rows than
Mdl.Q. If numpreobs is larger than required,
simulate uses the latest required number of observations
only.
Columns of E0 are separate, independent presample paths. The
following conditions apply:
If
E0is a column vector, it represents a single residual path.simulateapplies it to each output path.If
E0is a matrix,simulateappliesE0(:,to initialize simulating pathj)j.E0must have at leastNumPathscolumns;simulateuses only the firstNumPathscolumns ofE0.
By default, simulate sets the necessary presample
disturbances to zero.
Data Types: double
Presample conditional variance data
σt2 used to
initialize the conditional variance model, specified as a
numpreobs-by-1 positive numeric column vector or a
numpreobs-by-numprepaths positive numeric
matrix. If the conditional variance Mdl.Variance is constant,
simulate ignores V0. Use
V0 only when you supply optional data inputs as numeric
arrays.
Each row is a presample observation (sampling time), and measurements in each row
occur simultaneously. The last row contains the latest presample observation.
numpreobs must be at least Mdl.Q to initialize
the conditional variance model in Mdl.Variance. For details, see
the simulate function of conditional variance
models. If numpreobs is larger than required,
simulate uses the latest required number of observations
only.
Columns of V0 are separate, independent presample paths. The
following conditions apply:
If
V0is a column vector, it represents a single path of conditional variances.simulateapplies it to each output path.If
V0is a matrix,simulateappliesV0(:,to initialize simulating pathj)j.V0must have at leastNumPathscolumns;simulateuses only the firstNumPathscolumns ofV0.
By default, simulate sets all necessary presample
observations to the unconditional variance of the conditional variance process.
Data Types: double
Since R2023b
Residual variable et to select from
Presample containing the presample residual data, specified as
one of the following data types:
String scalar or character vector containing a variable name in
Presample.Properties.VariableNamesVariable index (positive integer) to select from
Presample.Properties.VariableNamesA logical vector, where
PresampleInnovationVariable(selects variablej) = truefromjPresample.Properties.VariableNames
The selected variable must be a numeric matrix and cannot contain missing values
(NaNs).
If you specify presample residual data by using the Presample
name-value argument, you must specify
PresampleInnovationVariable.
Example: PresampleInnovationVariable="StockRateDist0"
Example: PresampleInnovationVariable=[false false true false] or
PresampleInnovationVariable=3 selects the third table variable as
the presample innovation variable.
Data Types: double | logical | char | cell | string
Since R2023b
Conditional variance variable
σt2 to select
from Presample containing presample conditional variance data,
specified as one of the following data types:
String scalar or character vector containing a variable name in
Presample.Properties.VariableNamesVariable index (positive integer) to select from
Presample.Properties.VariableNamesA logical vector, where
PresampleVarianceVariable(selects variablej) = truefromjPresample.Properties.VariableNames
The selected variable must be a numeric vector and cannot contain missing values
(NaNs).
If you specify presample conditional variance data by using the
Presample name-value argument, you must specify
PresampleVarianceVariable.
Example: PresampleVarianceVariable="StockRateVar0"
Example: PresampleVarianceVariable=[false false true false] or
PresampleVarianceVariable=3 selects the third table variable as
the presample conditional variance variable.
Data Types: double | logical | char | cell | string
Exogenous predictor data for the regression component in the model, specified as a
numeric matrix with numpreds columns. numpreds
is the number of predictor variables (numel(Mdl.Beta)). Use
X only when you supply optional data inputs as numeric
arrays.
Each row of X corresponds to a period in the length
numobs simulation sample (period for which
simulate simulates observations; the period after the
presample). X must have at least numobs rows.
The last row contains the latest predictor data. If X has more than
numobs rows, simulate uses only the
latest numobs rows.
simulate does not use the regression component in the
presample period.
Columns of X are separate predictor variables.
simulate applies X to each simulated
path; that is, X represents one path of observed predictors.
By default, simulate excludes the regression component,
regardless of its presence in Mdl.
Data Types: double
Note
NaNvalues inX,Y0,E0, andV0indicate missing values.simulateremoves missing values from specified data by list-wise deletion.For the presample,
simulatehorizontally concatenates the possibly jagged arraysY0,E0, andV0with respect to the last rows, and then it removes any row of the concatenated matrix containing at least oneNaN.For in-sample data,
simulateremoves any row ofXcontaining at least oneNaN.
This type of data reduction reduces the effective sample size and can create an irregular time series.
For numeric data inputs,
simulateassumes that you synchronize the presample data such that the latest observations occur simultaneously.simulateissues an error when any table or timetable input contains missing values.
Output Arguments
Simulated response paths yt, returned as a numobs-by-1 numeric column vector or a numobs-by-NumPaths numeric matrix. simulate returns Y by default and when you supply optional data in numeric arrays.
Y represents the continuation of the presample responses in Y0.
Each row corresponds to a period in the simulated series; the simulated series has the periodicity of Mdl. Each column is a separate simulated path.
Simulated conditional variance paths
σt2 of the
mean-zero innovations associated with Y, returned as a
numobs-by-1 numeric column vector or a
numobs-by-NumPaths numeric matrix.
simulate returns V by default and when
you supply optional data in numeric arrays
The dimensions of V correspond to the dimensions of
Y.
Since R2023b
Simulated response yt, innovation
εt, and conditional variance
σt2 paths,
returned as a table or timetable, the same data type as Presample
or InSample. simulate returns
Tbl only when you supply at least one of the inputs
Presample and InSample.
Tbl contains the following variables:
The simulated response paths, which are in a
numobs-by-NumPathsnumeric matrix, with rows representing observations and columns representing independent paths. Each path represents the continuation of the corresponding presample path inPresample, or each path corresponds, in time, with the rows ofInSample.simulatenames the simulated response variable inTbl, whereresponseName_ResponseisresponseNameMdl.SeriesName. For example, ifMdl.SeriesNameisStockReturns,Tblcontains a variable for the corresponding simulated response paths with the nameStockReturns_Response.The simulated innovation paths, which are in a
numobs-by-NumPathsnumeric matrix, with rows representing observations and columns representing independent paths. Each path represents the continuation of the corresponding presample path inPresample, or each path corresponds, in time, with the rows ofInSample.simulatenames the simulated innovation variable inTbl, whereresponseName_InnovationisresponseNameMdl.SeriesName. For example, ifMdl.SeriesNameisStockReturns,Tblcontains a variable for the corresponding simulated innovation paths with the nameStockReturns_Innovation.The simulated conditional variance paths, which are in a
numobs-by-NumPathsnumeric matrix, with rows representing observations and columns representing independent paths. Each path represents the continuation of the corresponding presample path inPresample, or each path corresponds, in time, with the rows ofInSample.simulatenames the simulated conditional variance variable inTbl, whereresponseName_VarianceisresponseNameMdl.SeriesName. For example, ifMdl.SeriesNameisStockReturns,Tblcontains a variable for the corresponding simulated conditional variance paths with the nameStockReturns_Variance.When you supply
InSample,Tblcontains all variables inInSample.
If Tbl is a timetable, the following conditions hold:
The row order of
Tbl, either ascending or descending, matches the row order ofPreample.If you specify
InSample, row timesTbl.TimeareInSample.Time(1:numobs). Otherwise,Tbl.Time(1)is the next time afterPresample(end)relative to the sampling frequency, andTbl.Time(2:numobs)are the following times relative to the sampling frequency.
References
[1] Box, George E. P., Gwilym M. Jenkins, and Gregory C. Reinsel. Time Series Analysis: Forecasting and Control. 3rd ed. Englewood Cliffs, NJ: Prentice Hall, 1994.
[2] Enders, Walter. Applied Econometric Time Series. Hoboken, NJ: John Wiley & Sons, Inc., 1995.
[3] Hamilton, James D. Time Series Analysis. Princeton, NJ: Princeton University Press, 1994.
Version History
Introduced in R2012aIn addition to accepting presample and in-sample predictor data in numeric arrays,
simulate accepts input data in tables or regular timetables. When
you supply input data in a table or timetable, the following conditions apply:
If you specify optional presample response, innovation, or conditional variance data to initialize the model, you must also specify corresponding variable names containing the data to use.
If you specify optional in-sample predictor data for the exogenous regression component of the model, you must also specify corresponding predictor variable names containing the data to use.
simulatereturns results in a table or timetable.
Name-value arguments to support tabular workflows include:
Presamplespecifies the input table or regular timetable of presample innovations and conditional variance data.PresampleResponseVariablespecifies the variable name of the response paths to select fromPresample.PresampleInnovationVariablespecifies the variable name of the innovation paths to select fromPresample.PresampleVarianceVariablespecifies the variable name of the conditional variance paths to select fromPresample.InSamplespecifies the input table or regular timetable of in-sample predictor data.PredictorVariablesspecifies the names of the predictor series to select fromInSamplefor a model regression component.
See Also
Objects
Functions
Topics
- Simulate Stationary Processes
- Simulate Trend-Stationary and Difference-Stationary Processes
- Simulate Multiplicative ARIMA Models
- Simulate Conditional Mean and Variance Models
- Monte Carlo Simulation of Conditional Mean Models
- Presample Data for Conditional Mean Model Simulation
- Transient Effects in Conditional Mean Model Simulations
- Monte Carlo Forecasting of Conditional Mean Models
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)