MathWorks Machine Translation
The automated translation of this page is provided by a general purpose third party translator tool.
MathWorks does not warrant, and disclaims all liability for, the accuracy, suitability, or fitness for purpose of the translation.
Infer conditional variances of conditional variance models
Infer conditional variances from a GARCH(1,1) model with known coefficients. When you use, and then do not use presample data, compare the results from infer
.
Specify a GARCH(1,1) model with known parameters. Simulate 101 conditional variances and responses (innovations) from the model. Set aside the first observation from each series to use as presample data.
Mdl = garch('Constant',0.01,'GARCH',0.8,'ARCH',0.15); rng default; % For reproducibility [vS,yS] = simulate(Mdl,101); y0 = yS(1); v0 = vS(1); y = yS(2:end); v = vS(2:end); figure subplot(2,1,1) plot(v) title('Conditional Variances') subplot(2,1,2) plot(y) title('Innovations')
Infer the conditional variances of y
without using presample data. Compare them to the known (simulated) conditional variances.
vI = infer(Mdl,y); figure plot(1:100,v,'r','LineWidth',2) hold on plot(1:100,vI,'k:','LineWidth',1.5) legend('Simulated','Inferred','Location','NorthEast') title('Inferred Conditional Variances  No Presamples') hold off
Notice the transient response (discrepancy) in the early time periods due to the absence of presample data.
Infer conditional variances using the setaside presample innovation, y0
. Compare them to the known (simulated) conditional variances.
vE = infer(Mdl,y,'E0',y0); figure plot(1:100,v,'r','LineWidth',2) hold on plot(1:100,vE,'k:','LineWidth',1.5) legend('Simulated','Inferred','Location','NorthEast') title('Inferred Conditional Variances  Presample E') hold off
There is a slightly reduced transient response in the early time periods.
Infer conditional variances using the setaside presample conditional variance, v0
. Compare them to the known (simulated) conditional variances.
vO = infer(Mdl,y,'V0',v0); figure plot(v) plot(1:100,v,'r','LineWidth',2) hold on plot(1:100,vO,'k:','LineWidth',1.5) legend('Simulated','Inferred','Location','NorthEast') title('Inferred Conditional Variances  Presample V') hold off
There is a much smaller transient response in the early time periods.
Infer conditional variances using both the presample innovation and conditional variance. Compare them to the known (simulated) conditional variances.
vEO = infer(Mdl,y,'E0',y0,'V0',v0); figure plot(v) plot(1:100,v,'r','LineWidth',2) hold on plot(1:100,vEO,'k:','LineWidth',1.5) legend('Simulated','Inferred','Location','NorthEast') title('Inferred Conditional Variances  Presamples') hold off
When you use sufficient presample innovations and conditional variances, the inferred conditional variances are exact (there is no transient response).
Infer conditional variances from an EGARCH(1,1) model with known coefficients. When you use, and then do not use presample data, compare the results from infer
.
Specify an EGARCH(1,1) model with known parameters. Simulate 101 conditional variances and responses (innovations) from the model. Set aside the first observation from each series to use as presample data.
Mdl = egarch('Constant',0.001,'GARCH',0.8,... 'ARCH',0.15,'Leverage',0.1); rng default; % For reproducibility [vS,yS] = simulate(Mdl,101); y0 = yS(1); v0 = vS(1); y = yS(2:end); v = vS(2:end); figure subplot(2,1,1) plot(v) title('Conditional Variances') subplot(2,1,2) plot(y) title('Innovations')
Infer the conditional variances of y
without using any presample data. Compare them to the known (simulated) conditional variances.
vI = infer(Mdl,y); figure plot(1:100,v,'r','LineWidth',2) hold on plot(1:100,vI,'k:','LineWidth',1.5) legend('Simulated','Inferred','Location','NorthEast') title('Inferred Conditional Variances  No Presamples') hold off
Notice the transient response (discrepancy) in the early time periods due to the absence of presample data.
Infer conditional variances using the setaside presample innovation, y0
. Compare them to the known (simulated) conditional variances.
vE = infer(Mdl,y,'E0',y0); figure plot(1:100,v,'r','LineWidth',2) hold on plot(1:100,vE,'k:','LineWidth',1.5) legend('Simulated','Inferred','Location','NorthEast') title('Inferred Conditional Variances  Presample E') hold off
There is a slightly reduced transient response in the early time periods.
Infer conditional variances using the setaside presample variance, v0
. Compare them to the known (simulated) conditional variances.
vO = infer(Mdl,y,'V0',v0); figure plot(v) plot(1:100,v,'r','LineWidth',2) hold on plot(1:100,vO,'k:','LineWidth',1.5) legend('Simulated','Inferred','Location','NorthEast') title('Inferred Conditional Variances  Presample V') hold off
The transient response is almost eliminated.
Infer conditional variances using both the presample innovation and conditional variance. Compare them to the known (simulated) conditional variances.
vEO = infer(Mdl,y,'E0',y0,'V0',v0); figure plot(v) plot(1:100,v,'r','LineWidth',2) hold on plot(1:100,vEO,'k:','LineWidth',1.5) legend('Simulated','Inferred','Location','NorthEast') title('Inferred Conditional Variances  Presamples') hold off
When you use sufficient presample innovations and conditional variances, the inferred conditional variances are exact (there is no transient response).
Infer conditional variances from a GJR(1,1) model with known coefficients. When you use, and then do not use presample data, compare the results from infer
.
Specify a GJR(1,1) model with known parameters. Simulate 101 conditional variances and responses (innovations) from the model. Set aside the first observation from each series to use as presample data.
Mdl = gjr('Constant',0.01,'GARCH',0.8,'ARCH',0.14,... 'Leverage',0.1); rng default; % For reproducibility [vS,yS] = simulate(Mdl,101); y0 = yS(1); v0 = vS(1); y = yS(2:end); v = vS(2:end); figure subplot(2,1,1) plot(v) title('Conditional Variances') subplot(2,1,2) plot(y) title('Innovations')
Infer the conditional variances of y
without using any presample data. Compare them to the known (simulated) conditional variances.
vI = infer(Mdl,y); figure plot(1:100,v,'r','LineWidth',2) hold on plot(1:100,vI,'k:','LineWidth',1.5) legend('Simulated','Inferred','Location','NorthEast') title('Inferred Conditional Variances  No Presamples') hold off
Notice the transient response (discrepancy) in the early time periods due to the absence of presample data.
Infer conditional variances using the setaside presample innovation, y0
. Compare them to the known (simulated) conditional variances.
vE = infer(Mdl,y,'E0',y0); figure plot(1:100,v,'r','LineWidth',2) hold on plot(1:100,vE,'k:','LineWidth',1.5) legend('Simulated','Inferred','Location','NorthEast') title('Inferred Conditional Variances  Presample E') hold off
There is a slightly reduced transient response in the early time periods.
Infer conditional variances using the setaside presample conditional variance, vO
. Compare them to the known (simulated) conditional variances.
vO = infer(Mdl,y,'V0',v0); figure plot(v) plot(1:100,v,'r','LineWidth',2) hold on plot(1:100,vO,'k:','LineWidth',1.5) legend('Simulated','Inferred','Location','NorthEast') title('Inferred Conditional Variances  Presample V') hold off
There is a much smaller transient response in the early time periods.
Infer conditional variances using both the presample innovation and conditional variance. Compare them to the known (simulated) conditional variances.
vEO = infer(Mdl,y,'E0',y0,'V0',v0); figure plot(v) plot(1:100,v,'r','LineWidth',2) hold on plot(1:100,vEO,'k:','LineWidth',1.5) legend('Simulated','Inferred','Location','NorthEast') title('Inferred Conditional Variances  Presamples') hold off
When you use sufficient presample innovations and conditional variances, the inferred conditional variances are exact (there is no transient response).
Infer the loglikelihood objective function values for an EGARCH(1,1) and EGARCH(2,1) model fit to NASDAQ Composite Index returns. To identify which model is the more parsimonious, adequate fit, conduct a likelihood ratio test.
Load the NASDAQ data included with the toolbox, and convert the index to returns. Set aside the first two observations to use as presample data.
load Data_EquityIdx
nasdaq = DataTable.NASDAQ;
r = price2ret(nasdaq);
r0 = r(1:2);
rn = r(3:end);
Fit an EGARCH(1,1) model to the returns, and infer the loglikelihood objective function value.
Mdl1 = egarch(1,1); EstMdl1 = estimate(Mdl1,rn,'E0',r0); [~,logL1] = infer(EstMdl1,rn,'E0',r0);
EGARCH(1,1) Conditional Variance Model:  Conditional Probability Distribution: Gaussian Standard t Parameter Value Error Statistic     Constant 0.135178 0.0221337 6.10733 GARCH{1} 0.983864 0.00242681 405.415 ARCH{1} 0.199966 0.0139932 14.2902 Leverage{1} 0.0602436 0.0056558 10.6516
Fit an EGARCH(2,1) model to the returns, and infer the loglikelihood objective function value.
Mdl2 = egarch(2,1); EstMdl2 = estimate(Mdl2,rn,'E0',r0); [~,logL2] = infer(EstMdl2,rn,'E0',r0);
EGARCH(2,1) Conditional Variance Model:  Conditional Probability Distribution: Gaussian Standard t Parameter Value Error Statistic     Constant 0.145593 0.0284354 5.12013 GARCH{1} 0.853076 0.140184 6.08541 GARCH{2} 0.129513 0.138378 0.935938 ARCH{1} 0.219686 0.0294645 7.45593 Leverage{1} 0.067935 0.0108795 6.24432
Conduct a likelihood ratio test, with the more parsimonious EGARCH(1,1) model as the null model, and the EGARCH(2,1) model as the alternative. The degree of freedom for the test is 1, because the EGARCH(2,1) model has one more parameter than the EGARCH(1,1) model (an additional GARCH term).
[h,p] = lratiotest(logL2,logL1,1)
h = logical 0 p = 0.2256
The null hypothesis is not rejected (h = 0
). At the 0.05 significance level, the EGARCH(1,1) model is not rejected in favor of the EGARCH(2,1) model.
A GARCH(P, Q) model is nested within a GJR(P, Q) model. Therefore, you can perform a likelihood ratio test to compare GARCH(P, Q) and GJR(P, Q) model fits.
Infer the loglikelihood objective function values for a GARCH(1,1) and GJR(1,1) model fit to NASDAQ Composite Index returns. Conduct a likelihood ratio test to identify which model is the more parsimonious, adequate fit.
Load the NASDAQ data included with the toolbox, and convert the index to returns. Set aside the first two observations to use as presample data.
load Data_EquityIdx
nasdaq = DataTable.NASDAQ;
r = price2ret(nasdaq);
r0 = r(1:2);
rn = r(3:end);
Fit a GARCH(1,1) model to the returns, and infer the loglikelihood objective function value.
Mdl1 = garch(1,1); EstMdl1 = estimate(Mdl1,rn,'E0',r0); [~,logL1] = infer(EstMdl1,rn,'E0',r0);
GARCH(1,1) Conditional Variance Model:  Conditional Probability Distribution: Gaussian Standard t Parameter Value Error Statistic     Constant 2.00504e06 5.42984e07 3.69263 GARCH{1} 0.883326 0.00845372 104.49 ARCH{1} 0.109239 0.0076667 14.2486
Fit a GJR(1,1) model to the returns, and infer the loglikelihood objective function value.
Mdl2 = gjr(1,1); EstMdl2 = estimate(Mdl2,rn,'E0',r0); [~,logL2] = infer(EstMdl2,rn,'E0',r0);
GJR(1,1) Conditional Variance Model:  Conditional Probability Distribution: Gaussian Standard t Parameter Value Error Statistic     Constant 2.47543e06 5.69859e07 4.34393 GARCH{1} 0.881011 0.0095109 92.6317 ARCH{1} 0.064017 0.00918523 6.96956 Leverage{1} 0.0893017 0.00992159 9.00074
Conduct a likelihood ratio test, with the more parsimonious GARCH(1,1) model as the null model, and the GJR(1,1) model as the alternative. The degree of freedom for the test is 1, because the GJR(1,1) model has one more parameter than the GARCH(1,1) model (a leverage term).
[h,p] = lratiotest(logL2,logL1,1)
h = logical 1 p = 4.5815e10
The null hypothesis is rejected (h = 1
). At the 0.05 significance level, the GARCH(1,1) model is rejected in favor of the GJR(1,1) model.
Mdl
— Conditional variance modelgarch
model object  egarch
model object  gjr
model objectY
— Response dataResponse data, specified as a numeric column vector or matrix.
As a column vector, Y
represents a single
path of the underlying series.
As a matrix, the rows of Y
correspond to
periods and the columns correspond to separate paths. The observations
across any row occur simultaneously.
infer
infers the conditional variances of Y
. Y
usually
represents an innovation series with mean 0 and variances characterized
by Mdl
. It is the continuation of the presample
innovation series E0
. Y
can
also represent a time series of innovations with mean 0 plus an offset.
If Mdl
has a nonzero offset, then the software
stores its value in the Offset
property (Mdl.Offset
).
infer
assumes that observations across any
row occur simultaneously.
The last observation of any series is the latest observation.
Note:

Specify optional commaseparated pairs of Name,Value
arguments.
Name
is the argument
name and Value
is the corresponding
value. Name
must appear
inside single quotes (' '
).
You can specify several name and value pair
arguments in any order as Name1,Value1,...,NameN,ValueN
.
'E0',[1 1;0.5 0.5],'V0',[1 0.5;1 0.5]
specifies
two equivalent presample paths of innovations and two, different presample
paths of conditional variances.'E0'
— Presample innovationsPresample innovations, specified as the commaseparated pair
consisting of 'E0'
and a numeric column vector
or matrix. The presample innovations provide initial values for the
innovations process of the conditional variance model Mdl
,
and derive from a distribution with mean 0.
E0
must contain at least Mdl.Q
elements
or rows. If E0
contains extra rows, then infer
uses
the latest Mdl.Q
only.
The last element or row contains the latest presample innovation.
If E0
is a column vector, it represents
a single path of the underlying innovation series. infer
applies E0
to
each inferred path.
If E0
is a matrix, then each column
represents a presample path of the underlying innovation series. E0
must
have at least as many columns as Y
. If E0
has
more columns than necessary, infer
uses
the first size(Y,2)
columns only.
The defaults are:
For GARCH(P,Q)
and GJR(P,Q) models, infer
sets
any necessary presample innovations to the square root of the average
squared value of the offsetadjusted response series Y
.
For EGARCH(P,Q) models, infer
sets
any necessary presample innovations to zero.
Example: 'E0',[1 1;0.5 0.5]
Data Types: double
'V0'
— Presample conditional variancesPresample conditional variances, specified as the commaseparated
pair consisting of 'V0'
and a numeric column vector
or matrix with positive entries. V0
provides initial
values for the conditional variances in the model.
If V0
is a column vector, then infer
applies
it to each output path.
If V0
is a matrix, then each column
represents a presample path of conditional variances. V0
must
have at least as many columns as Y
. If V0
has
more columns than required, infer
uses
the first size(Y,2)
columns only.
For GARCH(P,Q)
and GJR(P,Q) models, V0
must
have at least Mdl.P
rows (or elements) to initialize
the variance equation.
For EGARCH(P,Q)
models, V0
must have at least max(Mdl.P,Mdl.Q)
rows
to initialize the variance equation.
If the number of rows in V0
exceeds the
necessary number, then infer
uses the latest,
required number of observations only.
The last element row contains the latest observation.
By default, infer
sets any necessary
observations to the average squared value of the offsetadjusted response
series Y
.
Example: 'V0',[1 0.5;1 0.5]
Data Types: double
Notes:

V
— Conditional variancesConditional variances inferred from the response data Y
,
returned as a numeric column vector or matrix.
The dimensions of V
and Y
are
equivalent. If Y
is a matrix, then the columns
of V
are the inferred conditional variance paths
corresponding to the columns of Y
.
Rows of V
are periods corresponding to the
periodicity of Y
.
logL
— Loglikelihood objective function values[1] Bollerslev, T. "Generalized Autoregressive Conditional Heteroskedasticity." Journal of Econometrics. Vol. 31, 1986, pp. 307–327.
[2] Bollerslev, T. "A Conditionally Heteroskedastic Time Series Model for Speculative Prices and Rates of Return." The Review of Economics and Statistics. Vol. 69, 1987, pp. 542–547.
[3] Box, G. E. P., G. M. Jenkins, and G. C. Reinsel. Time Series Analysis: Forecasting and Control. 3rd ed. Englewood Cliffs, NJ: Prentice Hall, 1994.
[4] Enders, W. Applied Econometric Time Series. Hoboken, NJ: John Wiley & Sons, 1995.
[5] Engle, R. F. "Autoregressive Conditional Heteroskedasticity with Estimates of the Variance of United Kingdom Inflation." Econometrica. Vol. 50, 1982, pp. 987–1007.
[6] Glosten, L. R., R. Jagannathan, and D. E. Runkle. "On the Relation between the Expected Value and the Volatility of the Nominal Excess Return on Stocks." The Journal of Finance. Vol. 48, No. 5, 1993, pp. 1779–1801.
[7] Hamilton, J. D. Time Series Analysis. Princeton, NJ: Princeton University Press, 1994.
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.
You can also select a location from the following list: