100% found this document useful (5 votes)
28 views

MATLAB Econometrics Toolbox User S Guide The Mathworks All Chapter Instant Download

ebook

Uploaded by

bogoyamych
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (5 votes)
28 views

MATLAB Econometrics Toolbox User S Guide The Mathworks All Chapter Instant Download

ebook

Uploaded by

bogoyamych
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Full download test bank at ebook textbookfull.

com

MATLAB Econometrics Toolbox User s

CLICK LINK TO DOWLOAD

https://textbookfull.com/product/matlab-
econometrics-toolbox-user-s-guide-the-
mathworks/

textbookfull
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

MATLAB Bioinformatics Toolbox User s Guide The


Mathworks

https://textbookfull.com/product/matlab-bioinformatics-toolbox-
user-s-guide-the-mathworks/

MATLAB Mapping Toolbox User s Guide The Mathworks

https://textbookfull.com/product/matlab-mapping-toolbox-user-s-
guide-the-mathworks/

MATLAB Optimization Toolbox User s Guide The Mathworks

https://textbookfull.com/product/matlab-optimization-toolbox-
user-s-guide-the-mathworks/

MATLAB Trading Toolbox User s Guide The Mathworks

https://textbookfull.com/product/matlab-trading-toolbox-user-s-
guide-the-mathworks/
MATLAB Computer Vision Toolbox User s Guide The
Mathworks

https://textbookfull.com/product/matlab-computer-vision-toolbox-
user-s-guide-the-mathworks/

MATLAB Curve Fitting Toolbox User s Guide The Mathworks

https://textbookfull.com/product/matlab-curve-fitting-toolbox-
user-s-guide-the-mathworks/

MATLAB Fuzzy Logic Toolbox User s Guide The Mathworks

https://textbookfull.com/product/matlab-fuzzy-logic-toolbox-user-
s-guide-the-mathworks/

MATLAB Global Optimization Toolbox User s Guide The


Mathworks

https://textbookfull.com/product/matlab-global-optimization-
toolbox-user-s-guide-the-mathworks/

MATLAB Image Processing Toolbox User s Guide The


Mathworks

https://textbookfull.com/product/matlab-image-processing-toolbox-
user-s-guide-the-mathworks/
Econometrics Toolbox™
User's Guide

R2020a
How to Contact MathWorks

Latest news: www.mathworks.com

Sales and services: www.mathworks.com/sales_and_services

User community: www.mathworks.com/matlabcentral

Technical support: www.mathworks.com/support/contact_us

Phone: 508-647-7000

The MathWorks, Inc.


1 Apple Hill Drive
Natick, MA 01760-2098
Econometrics Toolbox™ User's Guide
© COPYRIGHT 1999–2020 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used or copied
only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form
without prior written consent from The MathWorks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by, for, or through
the federal government of the United States. By accepting delivery of the Program or Documentation, the government
hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer
software documentation as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014.
Accordingly, the terms and conditions of this Agreement and only those rights specified in this Agreement, shall pertain
to and govern the use, modification, reproduction, release, performance, display, and disclosure of the Program and
Documentation by the federal government (or other entity acquiring for or through the federal government) and shall
supersede any conflicting contractual terms or conditions. If this License fails to meet the government's needs or is
inconsistent in any respect with federal procurement law, the government agrees to return the Program and
Documentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be
trademarks or registered trademarks of their respective holders.
Patents
MathWorks products are protected by one or more U.S. patents. Please see www.mathworks.com/patents for
more information.
Revision History
October 2008 Online only Version 1.0 (Release 2008b)
March 2009 Online only Revised for Version 1.1 (Release 2009a)
September 2009 Online only Revised for Version 1.2 (Release 2009b)
March 2010 Online only Revised for Version 1.3 (Release 2010a)
September 2010 Online only Revised for Version 1.4 (Release 2010b)
April 2011 Online only Revised for Version 2.0 (Release 2011a)
September 2011 Online only Revised for Version 2.0.1 (Release 2011b)
March 2012 Online only Revised for Version 2.1 (Release 2012a)
September 2012 Online only Revised for Version 2.2 (Release 2012b)
March 2013 Online only Revised for Version 2.3 (Release 2013a)
September 2013 Online only Revised for Version 2.4 (Release 2013b)
March 2014 Online Only Revised for Version 3.0 (Release 2014a)
October 2014 Online Only Revised for Version 3.1 (Release 2014b)
March 2015 Online Only Revised for Version 3.2 (Release 2015a)
September 2015 Online Only Revised for Version 3.3 (Release 2015b)
March 2016 Online Only Revised for Version 3.4 (Release 2016a)
September 2016 Online Only Revised for Version 3.5 (Release 2016b)
March 2017 Online Only Revised for Version 4.0 (Release 2017a)
September 2017 Online Only Revised for Version 4.1 (Release 2017b)
March 2018 Online Only Revised for Version 5.0 (Release 2018a)
September 2018 Online Only Revised for Version 5.1 (Release 2018b)
March 2019 Online Only Revised for Version 5.2 (Release 2019a)
September 2019 Online Only Revised for Version 5.3 (Release 2019b)
March 2020 Online Only Revised for Version 5.4 (Release 2020a)
Contents

Getting Started
1
Econometrics Toolbox Product Description . . . . . . . . . . . . . . . . . . . . . . . . 1-2

Econometric Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3


Model Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
Econometrics Toolbox Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3

Econometrics Toolbox Model Objects, Properties, and Object Functions


.......................................................... 1-7
Model Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
Model Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8
Specify Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10
Retrieve Model Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
Modify Model Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
Object Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15

Stochastic Process Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16


What Is a Stochastic Process? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16
Stationary Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17
Linear Time Series Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17
Unit Root Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-18
Lag Operator Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19
Characteristic Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-20

Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-22

Data Preprocessing
2
Data Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Why Transform? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Common Data Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2

Trend-Stationary vs. Difference-Stationary Processes . . . . . . . . . . . . . . . . 2-6


Nonstationary Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
Trend Stationary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
Difference Stationary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7

Specify Lag Operator Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9


Lag Operator Polynomial of Coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
Difference Lag Operator Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11

iii
Nonseasonal Differencing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13

Nonseasonal and Seasonal Differencing . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16

Time Series Decomposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19

Moving Average Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21

Moving Average Trend Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22

Parametric Trend Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25

Hodrick-Prescott Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-30

Using the Hodrick-Prescott Filter to Reproduce Their Original Result


......................................................... 2-31

Seasonal Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-35


What Is a Seasonal Filter? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-35
Stable Seasonal Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-35
Sn × m seasonal filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-36

Seasonal Adjustment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38


What Is Seasonal Adjustment? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38
Deseasonalized Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38
Seasonal Adjustment Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38

Seasonal Adjustment Using a Stable Seasonal Filter . . . . . . . . . . . . . . . . 2-40

Seasonal Adjustment Using S(n,m) Seasonal Filters . . . . . . . . . . . . . . . . 2-46

Model Selection
3
Box-Jenkins Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2

Box-Jenkins Model Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4

Autocorrelation and Partial Autocorrelation . . . . . . . . . . . . . . . . . . . . . . 3-11


What Are Autocorrelation and Partial Autocorrelation? . . . . . . . . . . . . . . 3-11
Theoretical ACF and PACF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
Sample ACF and PACF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11

Ljung-Box Q-Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13

Detect Autocorrelation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15


Compute Sample ACF and PACF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
Conduct the Ljung-Box Q-Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17

Engle’s ARCH Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20

iv Contents
Detect ARCH Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
Test Autocorrelation of Squared Residuals . . . . . . . . . . . . . . . . . . . . . . . 3-22
Conduct Engle's ARCH Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24

Unit Root Nonstationarity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27


What Is a Unit Root Test? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
Modeling Unit Root Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
Available Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28
Testing for Unit Roots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-30

Unit Root Tests . . . . . . . . . . . . . . . . . . ............................ 3-32


Test Simulated Data for a Unit Root ............................ 3-32
Test Time Series Data for Unit Root ............................ 3-37
Test Stock Data for a Random Walk ............................ 3-39

Assess Stationarity of a Time Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-42

Information Criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-45

Model Comparison Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-46


Available Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-46
Likelihood Ratio Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-48
Lagrange Multiplier Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-48
Wald Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-48
Covariance Matrix Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-49

Conduct Lagrange Multiplier Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-50

Conduct Wald Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-53

Compare GARCH Models Using Likelihood Ratio Test . . . . . . . . . . . . . . . 3-55

Check Fit of Multiplicative ARIMA Model . . . . . . . . . . . . . . . . . . . . . . . . . 3-58

Goodness of Fit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-63

Residual Diagnostics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-64


Check Residuals for Normality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-64
Check Residuals for Autocorrelation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-64
Check Residuals for Conditional Heteroscedasticity . . . . . . . . . . . . . . . . 3-64

Assess Predictive Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-66

Nonspherical Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-67


What Are Nonspherical Models? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-67

Plot a Confidence Band Using HAC Estimates . . . . . . . . . . . . . . . . . . . . . 3-68

Change the Bandwidth of a HAC Estimator . . . . . . . . . . . . . . . . . . . . . . . 3-75

Check Model Assumptions for Chow Test . . . . . . . . . . . . . . . . . . . . . . . . . 3-80

Power of the Chow Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-87

v
Econometric Modeler
4
Econometric Modeler App Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
Prepare Data for Econometric Modeler App . . . . . . . . . . . . . . . . . . . . . . . 4-3
Import Time Series Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Perform Exploratory Data Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5
Fitting Models to Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-15
Conducting Goodness-of-Fit Checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-23
Finding Model with Best In-Sample Fit . . . . . . . . . . . . . . . . . . . . . . . . . . 4-29
Export Session Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-30

Specifying Lag Operator Polynomials Interactively . . . . . . . . . . . . . . . . . 4-37


Specify Lag Structure Using Lag Order Tab . . . . . . . . . . . . . . . . . . . . . . 4-38
Specify Lag Structure Using Lag Vector Tab . . . . . . . . . . . . . . . . . . . . . . 4-40

Prepare Time Series Data for Econometric Modeler App . . . . . . . . . . . . 4-43


Prepare Table of Multivariate Data for Import . . . . . . . . . . . . . . . . . . . . . 4-43
Prepare Numeric Vector for Import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-44

Import Time Series Data into Econometric Modeler App . . . . . . . . . . . . 4-46


Import Data from MATLAB Workspace . . . . . . . . . . . . . . . . . . . . . . . . . . 4-46
Import Data from MAT-File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-47

Plot Time Series Data Using Econometric Modeler App . . . . . . . . . . . . . 4-50


Plot Univariate Time Series Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-50
Plot Multivariate Time Series and Correlations . . . . . . . . . . . . . . . . . . . . 4-51

Detect Serial Correlation Using Econometric Modeler App . . . . . . . . . . 4-56


Plot ACF and PACF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-56
Conduct Ljung-Box Q-Test for Significant Autocorrelation . . . . . . . . . . . . 4-58

Detect ARCH Effects Using Econometric Modeler App . . . . . . . . . . . . . . 4-62


Inspect Correlograms of Squared Residuals for ARCH Effects . . . . . . . . . 4-62
Conduct Ljung-Box Q-Test on Squared Residuals . . . . . . . . . . . . . . . . . . 4-65
Conduct Engle's ARCH Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-67

Assess Stationarity of Time Series Using Econometric Modeler . . . . . . . 4-70


Test Assuming Unit Root Null Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-70
Test Assuming Stationary Null Model . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-73
Test Assuming Random Walk Null Model . . . . . . . . . . . . . . . . . . . . . . . . 4-77

Assess Collinearity Among Multiple Series Using Econometric Modeler


App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-81

Transform Time Series Using Econometric Modeler App . . . . . . . . . . . . 4-84


Apply Log Transformation to Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-84
Stabilize Time Series Using Nonseasonal Differencing . . . . . . . . . . . . . . 4-88
Convert Prices to Returns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-91
Remove Seasonal Trend from Time Series Using Seasonal Difference . . . 4-94
Remove Deterministic Trend from Time Series . . . . . . . . . . . . . . . . . . . . 4-97

Implement Box-Jenkins Model Selection and Estimation Using


Econometric Modeler App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-99

vi Contents
Select ARCH Lags for GARCH Model Using Econometric Modeler App
........................................................ 4-109

Estimate Multiplicative ARIMA Model Using Econometric Modeler App


........................................................ 4-118

Perform ARIMA Model Residual Diagnostics Using Econometric Modeler


App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-128

Specify t Innovation Distribution Using Econometric Modeler App . . . 4-137

Compare Predictive Performance After Creating Models Using


Econometric Modeler App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-141

Estimate ARIMAX Model Using Econometric Modeler App . . . . . . . . . . 4-148

Estimate Regression Model with ARMA Errors Using Econometric


Modeler App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-156

Compare Conditional Variance Model Fit Statistics Using Econometric


Modeler App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-170

Perform GARCH Model Residual Diagnostics Using Econometric Modeler


App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-179

Share Results of Econometric Modeler App Session . . . . . . . . . . . . . . . 4-186

Time Series Regression Models


5
Time Series Regression Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3

Regression Models with Time Series Errors . . . . . . . . . . . . . . . . . . . . . . . . 5-5


What Are Regression Models with Time Series Errors? . . . . . . . . . . . . . . . 5-5
Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5

Create Regression Models with ARIMA Errors . . . . . . . . . . . . . . . . . . . . . . 5-8


Default Regression Model with ARIMA Errors Specifications . . . . . . . . . . 5-8
Specify regARIMA Models Using Name-Value Pair Arguments . . . . . . . . . . 5-9
Specify Linear Regression Models Using Econometric Modeler App . . . . 5-15

Specify the Default Regression Model with ARIMA Errors . . . . . . . . . . . 5-19

Modify regARIMA Model Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21


Modify Properties Using Dot Notation . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21
Nonmodifiable Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23

Create Regression Models with AR Errors . . . . . . . . . . . . . . . . . . . . . . . . 5-26


Default Regression Model with AR Errors . . . . . . . . . . . . . . . . . . . . . . . . 5-26
AR Error Model Without an Intercept . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27
AR Error Model with Nonconsecutive Lags . . . . . . . . . . . . . . . . . . . . . . . 5-27

vii
Known Parameter Values for a Regression Model with AR Errors . . . . . . 5-28
Regression Model with AR Errors and t Innovations . . . . . . . . . . . . . . . . 5-29

Create Regression Models with MA Errors . . . . . . . . . . . . . . . . . . . . . . . . 5-31


Default Regression Model with MA Errors . . . . . . . . . . . . . . . . . . . . . . . 5-31
MA Error Model Without an Intercept . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-32
MA Error Model with Nonconsecutive Lags . . . . . . . . . . . . . . . . . . . . . . 5-32
Known Parameter Values for a Regression Model with MA Errors . . . . . . 5-33
Regression Model with MA Errors and t Innovations . . . . . . . . . . . . . . . . 5-34

Create Regression Models with ARMA Errors . . . . . . . . . . . . . . . . . . . . . . 5-36


Default Regression Model with ARMA Errors . . . . . . . . . . . . . . . . . . . . . 5-36
ARMA Error Model Without an Intercept . . . . . . . . . . . . . . . . . . . . . . . . 5-37
ARMA Error Model with Nonconsecutive Lags . . . . . . . . . . . . . . . . . . . . 5-37
Known Parameter Values for a Regression Model with ARMA Errors . . . . 5-38
Regression Model with ARMA Errors and t Innovations . . . . . . . . . . . . . 5-38
Specify Regression Model with ARMA Errors Using Econometric Modeler
App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-40

Create Regression Models with ARIMA Errors . . . . . . . . . . . . . . . . . . . . . 5-44


Default Regression Model with ARIMA Errors . . . . . . . . . . . . . . . . . . . . . 5-44
ARIMA Error Model Without an Intercept . . . . . . . . . . . . . . . . . . . . . . . . 5-45
ARIMA Error Model with Nonconsecutive Lags . . . . . . . . . . . . . . . . . . . . 5-45
Known Parameter Values for a Regression Model with ARIMA Errors . . . 5-46
Regression Model with ARIMA Errors and t Innovations . . . . . . . . . . . . . 5-47

Create Regression Models with SARIMA Errors . . . . . . . . . . . . . . . . . . . . 5-49


SARMA Error Model Without an Intercept . . . . . . . . . . . . . . . . . . . . . . . 5-49
Known Parameter Values for a Regression Model with SARIMA Errors . . 5-50
Regression Model with SARIMA Errors and t Innovations . . . . . . . . . . . . 5-50

Specify Regression Model with SARIMA Errors . . . . . . . . . . . . . . . . . . . . 5-53

Specify ARIMA Error Model Innovation Distribution . . . . . . . . . . . . . . . . 5-60


About the Innovation Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-60
Innovation Distribution Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-61
Specify Innovation Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-61

Impulse Response of Regression Models with ARIMA Errors . . . . . . . . . 5-65

Plot Impulse Response of Regression Model with ARIMA Errors . . . . . . 5-66


Regression Model with AR Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-66
Regression Model with MA Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-67
Regression Model with ARMA Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-68
Regression Model with ARIMA Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-70

Maximum Likelihood Estimation of regARIMA Models . . . . . . . . . . . . . . 5-73


Innovation Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-73
Loglikelihood Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-73

regARIMA Model Estimation Using Equality Constraints . . . . . . . . . . . . 5-75

Presample Values for regARIMA Model Estimation . . . . . . . . . . . . . . . . 5-109

Initial Values for regARIMA Model Estimation . . . . . . . . . . . . . . . . . . . . 5-111

viii Contents
Optimization Settings for regARIMA Model Estimation . . . . . . . . . . . . 5-113
Optimization Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-113
Constraints on Regression Models with ARIMA Errors . . . . . . . . . . . . . 5-115

Estimate a Regression Model with ARIMA Errors . . . . . . . . . . . . . . . . . 5-116

Estimate a Regression Model with Multiplicative ARIMA Errors . . . . . 5-123

Select Regression Model with ARIMA Errors . . . . . . . . . . . . . . . . . . . . . 5-131

Choose Lags for ARMA Error Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-133

Intercept Identifiability in Regression Models with ARIMA Errors . . . 5-137


Intercept Identifiability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-137
Intercept Identifiability Illustration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-138

Alternative ARIMA Model Representations . . . . . . . . . . . . . . . . . . . . . . . 5-141


regARIMA to ARIMAX Model Conversion . . . . . . . . . . . . . . . . . . . . . . . 5-141
Illustrate regARIMA to ARIMAX Model Conversion . . . . . . . . . . . . . . . . 5-142

Simulate Regression Models with ARMA Errors . . . . . . . . . . . . . . . . . . . 5-147


Simulate an AR Error Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-147
Simulate an MA Error Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-153
Simulate an ARMA Error Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-159

Simulate Regression Models with Nonstationary Errors . . . . . . . . . . . . 5-166


Simulate a Regression Model with Nonstationary Errors . . . . . . . . . . . 5-166
Simulate a Regression Model with Nonstationary Exponential Errors . . 5-169

Simulate Regression Models with Multiplicative Seasonal Errors . . . . 5-174


Simulate a Regression Model with Stationary Multiplicative Seasonal Errors
.................................................... 5-174
Untitled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-176

Monte Carlo Simulation of Regression Models with ARIMA Errors . . . 5-179


What Is Monte Carlo Simulation? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-179
Generate Monte Carlo Sample Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-179
Monte Carlo Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-180

Presample Data for regARIMA Model Simulation . . . . . . . . . . . . . . . . . 5-182

Transient Effects in regARIMA Model Simulations . . . . . . . . . . . . . . . . 5-183


What Are Transient Effects? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-183
Illustration of Transient Effects on Regression . . . . . . . . . . . . . . . . . . . 5-183

Forecast a Regression Model with ARIMA Errors . . . . . . . . . . . . . . . . . . 5-191

Forecast a Regression Model with Multiplicative Seasonal ARIMA Errors


........................................................ 5-194

Verify Predictive Ability Robustness of a regARIMA Model . . . . . . . . . . 5-198

MMSE Forecasting Regression Models with ARIMA Errors . . . . . . . . . 5-200


What Are MMSE Forecasts? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-200
How forecast Generates MMSE Forecasts . . . . . . . . . . . . . . . . . . . . . . 5-200

ix
Forecast Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-202

Monte Carlo Forecasting of regARIMA Models . . . . . . . . . . . . . . . . . . . . 5-203


Monte Carlo Forecasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-203
Advantage of Monte Carlo Forecasts . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-203

Bayesian Linear Regression


6
Bayesian Linear Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
Classical Versus Bayesian Analyses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
Main Bayesian Analysis Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
Posterior Estimation and Inference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4

Implement Bayesian Linear Regression . . . . . . . . . . . . . . . . . . . . . . . . . . 6-10


Workflow for Standard Bayesian Linear Regression Models . . . . . . . . . . 6-10
Workflow for Bayesian Predictor Selection . . . . . . . . . . . . . . . . . . . . . . . 6-13

Specify Gradient for HMC Sampler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-18

Posterior Estimation and Simulation Diagnostics . . . . . . . . . . . . . . . . . . 6-27


Diagnose MCMC Samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-27
Perform Sensitivity Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-34

Tune Slice Sampler For Posterior Estimation . . . . . . . . . . . . . . . . . . . . . . 6-36

Compare Robust Regression Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . 6-43

Bayesian Lasso Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-52

Bayesian Stochastic Search Variable Selection . . . . . . . . . . . . . . . . . . . . 6-63

Replacing Removed Syntaxes of estimate . . . . . . . . . . . . . . . . . . . . . . . . . 6-73


Replace Removed Syntax When Estimating Analytical Marginal Posterior
..................................................... 6-74
Replace Removed Syntax When Estimating Numerical Marginal Posterior
..................................................... 6-75
Replace Removed Syntax When Estimating Conditional Posterior . . . . . . 6-77

Conditional Mean Models


7
Conditional Mean Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3
Unconditional vs. Conditional Mean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3
Static vs. Dynamic Conditional Mean Models . . . . . . . . . . . . . . . . . . . . . . 7-3
Conditional Mean Models for Stationary Processes . . . . . . . . . . . . . . . . . . 7-3

Specify Conditional Mean Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-5


Default ARIMA Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-5

x Contents
Specify Nonseasonal Models Using Name-Value Pairs . . . . . . . . . . . . . . . . 7-7
Specify Multiplicative Models Using Name-Value Pairs . . . . . . . . . . . . . . 7-11
Specify Conditional Mean Model Using Econometric Modeler App . . . . . 7-14

Autoregressive Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-17


AR(p) Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-17
Stationarity of the AR Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-17

AR Model Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-19


Default AR Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-19
AR Model with No Constant Term . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-19
AR Model with Nonconsecutive Lags . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-20
ARMA Model with Known Parameter Values . . . . . . . . . . . . . . . . . . . . . . 7-21
AR Model with t Innovation Distribution . . . . . . . . . . . . . . . . . . . . . . . . . 7-22
Specify AR Model Using Econometric Modeler App . . . . . . . . . . . . . . . . 7-22

Moving Average Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-26


MA(q) Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-26
Invertibility of the MA Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-26

MA Model Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-28


Default MA Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-28
MA Model with No Constant Term . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-28
MA Model with Nonconsecutive Lags . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-29
MA Model with Known Parameter Values . . . . . . . . . . . . . . . . . . . . . . . . 7-30
MA Model with t Innovation Distribution . . . . . . . . . . . . . . . . . . . . . . . . 7-31
Specify MA Model Using Econometric Modeler App . . . . . . . . . . . . . . . . 7-31

Autoregressive Moving Average Model . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-35


ARMA(p,q) Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-35
Stationarity and Invertibility of the ARMA Model . . . . . . . . . . . . . . . . . . 7-35

ARMA Model Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-37


Default ARMA Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-37
ARMA Model with No Constant Term . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-37
ARMA Model with Known Parameter Values . . . . . . . . . . . . . . . . . . . . . . 7-38
Specify ARMA Model Using Econometric Modeler App . . . . . . . . . . . . . . 7-39

ARIMA Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-42

ARIMA Model Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-44


Default ARIMA Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-44
ARIMA Model with Known Parameter Values . . . . . . . . . . . . . . . . . . . . . 7-45
Specify ARIMA Model Using Econometric Modeler App . . . . . . . . . . . . . 7-45

Multiplicative ARIMA Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-49

Multiplicative ARIMA Model Specifications . . . . . . . . . . . . . . . . . . . . . . . 7-51


Seasonal ARIMA Model with No Constant Term . . . . . . . . . . . . . . . . . . . 7-51
Seasonal ARIMA Model with Known Parameter Values . . . . . . . . . . . . . . 7-52
Specify Multiplicative ARIMA Model Using Econometric Modeler App . . 7-53

Specify Multiplicative ARIMA Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-58

xi
ARIMA Model Including Exogenous Covariates . . . . . . . . . . . . . . . . . . . . 7-62
ARIMAX(p,D,q) Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-62
Conventions and Extensions of the ARIMAX Model . . . . . . . . . . . . . . . . . 7-62

ARIMAX Model Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-64


Create ARIMAX Model Using Name-Value Pairs . . . . . . . . . . . . . . . . . . . 7-64
Specify ARMAX Model Using Dot Notation . . . . . . . . . . . . . . . . . . . . . . . 7-65
Specify ARIMAX or SARIMAX Model Using Econometric Modeler App . . 7-66

Modify Properties of Conditional Mean Model Objects . . . . . . . . . . . . . . 7-70


Dot Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-70
Nonmodifiable Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-73

Specify Conditional Mean Model Innovation Distribution . . . . . . . . . . . . 7-75


About the Innovation Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-75
Choices for the Variance Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-75
Choices for the Innovation Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . 7-75
Specify the Innovation Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-76
Modify the Innovation Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-78

Specify Conditional Mean and Variance Models . . . . . . . . . . . . . . . . . . . . 7-80

Impulse Response Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-84

Plot the Impulse Response Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-85


Moving Average Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-85
Autoregressive Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-86
ARMA Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-87

Box-Jenkins Differencing vs. ARIMA Estimation . . . . . . . . . . . . . . . . . . . 7-89

Maximum Likelihood Estimation for Conditional Mean Models . . . . . . . 7-92


Innovation Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-92
Loglikelihood Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-92

Conditional Mean Model Estimation with Equality Constraints . . . . . . . 7-94

Presample Data for Conditional Mean Model Estimation . . . . . . . . . . . . 7-95

Initial Values for Conditional Mean Model Estimation . . . . . . . . . . . . . . 7-97

Optimization Settings for Conditional Mean Model Estimation . . . . . . . 7-99


Optimization Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-99
Conditional Mean Model Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . 7-101

Estimate Multiplicative ARIMA Model . . . . . . . . . . . . . . . . . . . . . . . . . . 7-102

Model Seasonal Lag Effects Using Indicator Variables . . . . . . . . . . . . . 7-105

Forecast IGD Rate from ARX Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-109

Estimate Conditional Mean and Variance Model . . . . . . . . . . . . . . . . . . 7-115

Choose ARMA Lags Using BIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-120

xii Contents
Infer Residuals for Diagnostic Checking . . . . . . . . . . . . . . . . . . . . . . . . . 7-123

Monte Carlo Simulation of Conditional Mean Models . . . . . . . . . . . . . . 7-128


What Is Monte Carlo Simulation? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-128
Generate Monte Carlo Sample Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-128
Monte Carlo Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-129

Presample Data for Conditional Mean Model Simulation . . . . . . . . . . . 7-130

Transient Effects in Conditional Mean Model Simulations . . . . . . . . . . 7-131

Simulate Stationary Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-132


Simulate AR Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-132
Simulate MA Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-136

Simulate Trend-Stationary and Difference-Stationary Processes . . . . . 7-140

Simulate Multiplicative ARIMA Models . . . . . . . . . . . . . . . . . . . . . . . . . 7-144

Simulate Conditional Mean and Variance Models . . . . . . . . . . . . . . . . . 7-147

Monte Carlo Forecasting of Conditional Mean Models . . . . . . . . . . . . . 7-151


Monte Carlo Forecasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-151
Advantage of Monte Carlo Forecasting . . . . . . . . . . . . . . . . . . . . . . . . . 7-151

MMSE Forecasting of Conditional Mean Models . . . . . . . . . . . . . . . . . . 7-152


What Are MMSE Forecasts? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-152
How forecast Generates MMSE Forecasts . . . . . . . . . . . . . . . . . . . . . . 7-152
Forecast Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-153

Convergence of AR Forecasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-155

Forecast Multiplicative ARIMA Model . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-159

Specify Presample and Forecast Period Data To Forecast ARIMAX Model


........................................................ 7-162

Forecast Conditional Mean and Variance Model . . . . . . . . . . . . . . . . . . . 7-166

Model and Simulate Electricity Spot Prices Using the Skew-Normal


Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-169

Conditional Variance Models


8
Conditional Variance Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
General Conditional Variance Model Definition . . . . . . . . . . . . . . . . . . . . . 8-2
GARCH Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
EGARCH Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
GJR Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4

xiii
Specify GARCH Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6
Default GARCH Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6
Specify Default GARCH Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-7
Using Name-Value Pair Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-8
Specify GARCH Model Using Econometric Modeler App . . . . . . . . . . . . . 8-11
Specify GARCH Model with Mean Offset . . . . . . . . . . . . . . . . . . . . . . . . . 8-13
Specify GARCH Model with Known Parameter Values . . . . . . . . . . . . . . . 8-14
Specify GARCH Model with t Innovation Distribution . . . . . . . . . . . . . . . 8-14
Specify GARCH Model with Nonconsecutive Lags . . . . . . . . . . . . . . . . . . 8-15

Specify EGARCH Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-17


Default EGARCH Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-17
Specify Default EGARCH Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-19
Using Name-Value Pair Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-19
Specify EGARCH Model Using Econometric Modeler App . . . . . . . . . . . . 8-22
Specify EGARCH Model with Mean Offset . . . . . . . . . . . . . . . . . . . . . . . . 8-24
Specify EGARCH Model with Nonconsecutive Lags . . . . . . . . . . . . . . . . . 8-24
Specify EGARCH Model with Known Parameter Values . . . . . . . . . . . . . . 8-25
Specify EGARCH Model with t Innovation Distribution . . . . . . . . . . . . . . 8-26

Specify GJR Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-28


Default GJR Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-28
Specify Default GJR Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-29
Using Name-Value Pair Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-30
Specify GJR Model Using Econometric Modeler App . . . . . . . . . . . . . . . . 8-33
Specify GJR Model with Mean Offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-35
Specify GJR Model with Nonconsecutive Lags . . . . . . . . . . . . . . . . . . . . . 8-35
Specify GJR Model with Known Parameter Values . . . . . . . . . . . . . . . . . . 8-36
Specify GJR Model with t Innovation Distribution . . . . . . . . . . . . . . . . . . 8-37

Modify Properties of Conditional Variance Models . . . . . . . . . . . . . . . . . 8-39


Dot Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-39
Nonmodifiable Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-41

Specify the Conditional Variance Model Innovation Distribution . . . . . . 8-44

Specify Conditional Variance Model For Exchange Rates . . . . . . . . . . . . 8-47

Maximum Likelihood Estimation for Conditional Variance Models . . . . 8-52


Innovation Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-52
Loglikelihood Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-52

Conditional Variance Model Estimation with Equality Constraints . . . . 8-54

Presample Data for Conditional Variance Model Estimation . . . . . . . . . . 8-55

Initial Values for Conditional Variance Model Estimation . . . . . . . . . . . . 8-57

Optimization Settings for Conditional Variance Model Estimation . . . . 8-58


Optimization Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-58
Conditional Variance Model Constraints . . . . . . . . . . . . . . . . . . . . . . . . . 8-60

Infer Conditional Variances and Residuals . . . . . . . . . . . . . . . . . . . . . . . . 8-62

Likelihood Ratio Test for Conditional Variance Models . . . . . . . . . . . . . . 8-66

xiv Contents
Compare Conditional Variance Models Using Information Criteria . . . . 8-69

Monte Carlo Simulation of Conditional Variance Models . . . . . . . . . . . . 8-72


What Is Monte Carlo Simulation? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-72
Generate Monte Carlo Sample Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-72
Monte Carlo Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-73

Presample Data for Conditional Variance Model Simulation . . . . . . . . . . 8-75

Simulate GARCH Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-76

Assess EGARCH Forecast Bias Using Simulations . . . . . . . . . . . . . . . . . . 8-81

Simulate Conditional Variance Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-86

Monte Carlo Forecasting of Conditional Variance Models . . . . . . . . . . . . 8-89


Monte Carlo Forecasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-89
Advantage of Monte Carlo Forecasting . . . . . . . . . . . . . . . . . . . . . . . . . . 8-89

MMSE Forecasting of Conditional Variance Models . . . . . . . . . . . . . . . . . 8-90


What Are MMSE Forecasts? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-90
EGARCH MMSE Forecasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-90
How forecast Generates MMSE Forecasts . . . . . . . . . . . . . . . . . . . . . . . 8-90

Forecast GJR Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-94

Forecast a Conditional Variance Model . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-97

Converting from GARCH Functions to Model Objects . . . . . . . . . . . . . . . 8-99

Multivariate Time Series Models


9
Vector Autoregression (VAR) Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3
Types of Stationary Multivariate Time Series Models . . . . . . . . . . . . . . . . 9-3
Lag Operator Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-5
Stable and Invertible Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6
Models with Regression Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6
VAR Model Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-7

Multivariate Time Series Data Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-10


Multivariate Time Series Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-10
Load Multivariate Economic Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-10
Multivariate Data Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-12
Preprocess Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-14
Time Base Partitions for Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-15
Partition Multivariate Time Series Data for Estimation . . . . . . . . . . . . . . 9-17

Vector Autoregression (VAR) Model Creation . . . . . . . . . . . . . . . . . . . . . . 9-19


Create VAR Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-19
Fully Specified Model Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-20
Model Template for Unrestricted Estimation . . . . . . . . . . . . . . . . . . . . . . 9-22

xv
Partially Specified Model Object for Restricted Estimation . . . . . . . . . . . 9-23
Display and Change Model Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-23
Select Appropriate Lag Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-26

Create and Adjust VAR Model Using Shorthand Syntax . . . . . . . . . . . . . . 9-29

Create and Adjust VAR Model Using Longhand Syntax . . . . . . . . . . . . . . 9-31

VAR Model Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-33


Preparing VAR Models for Fitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-33
Fitting Models to Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-33
Examining the Stability of a Fitted Model . . . . . . . . . . . . . . . . . . . . . . . . 9-34

Convert VARMA Model to VAR Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-36

Fit VAR Model of CPI and Unemployment Rate . . . . . . . . . . . . . . . . . . . . 9-37

Fit VAR Model to Simulated Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-41

VAR Model Forecasting, Simulation, and Analysis . . . . . . . . . . . . . . . . . . 9-43


VAR Model Forecasting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-43
Data Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-45
Calculating Impulse Responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-45

Generate VAR Model Impulse Responses . . . . . . . . . . . . . . . . . . . . . . . . . 9-47

Compare Generalized and Orthogonalized Impulse Response Functions


......................................................... 9-51

Forecast VAR Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-59

Forecast VAR Model Using Monte Carlo Simulation . . . . . . . . . . . . . . . . 9-62

Forecast VAR Model Conditional Responses . . . . . . . . . . . . . . . . . . . . . . . 9-65

Implement Seemingly Unrelated Regression . . . . . . . . . . . . . . . . . . . . . . 9-69

Estimate Capital Asset Pricing Model Using SUR . . . . . . . . . . . . . . . . . . 9-74

Simulate Responses of Estimated VARX Model . . . . . . . . . . . . . . . . . . . . 9-77

Simulate VAR Model Conditional Responses . . . . . . . . . . . . . . . . . . . . . . 9-84

Simulate Responses Using filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-88

VAR Model Case Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-90

Convert from vgx Functions to Model Objects . . . . . . . . . . . . . . . . . . . . 9-104

Cointegration and Error Correction Analysis . . . . . . . . . . . . . . . . . . . . . 9-107


Integration and Cointegration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-107
Cointegration and Error Correction . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-107
The Role of Deterministic Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-108
Cointegration Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-109

xvi Contents
Determine Cointegration Rank of VEC Model . . . . . . . . . . . . . . . . . . . . 9-111

Identifying Single Cointegrating Relations . . . . . . . . . . . . . . . . . . . . . . . 9-113


The Engle-Granger Test for Cointegration . . . . . . . . . . . . . . . . . . . . . . . 9-113
Limitations of the Engle-Granger Test . . . . . . . . . . . . . . . . . . . . . . . . . . 9-113

Test for Cointegration Using the Engle-Granger Test . . . . . . . . . . . . . . 9-116

Estimate VEC Model Parameters Using egcitest . . . . . . . . . . . . . . . . . . 9-120

VEC Model Monte Carlo Forecasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-123

Generate VEC Model Impulse Responses . . . . . . . . . . . . . . . . . . . . . . . . 9-131

Identifying Multiple Cointegrating Relations . . . . . . . . . . . . . . . . . . . . . 9-135

Test for Cointegration Using the Johansen Test . . . . . . . . . . . . . . . . . . . 9-136

Estimate VEC Model Parameters Using jcitest . . . . . . . . . . . . . . . . . . . . 9-138

Compare Approaches to Cointegration Analysis . . . . . . . . . . . . . . . . . . . 9-141

Testing Cointegrating Vectors and Adjustment Speeds . . . . . . . . . . . . . 9-144

Test Cointegrating Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-145

Test Adjustment Speeds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-147

Structural Change Models


10
Discrete-Time Markov Chains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2
What Are Discrete-Time Markov Chains? . . . . . . . . . . . . . . . . . . . . . . . . 10-2
Discrete-Time Markov Chain Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3

Markov Chain Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-8


Discrete-Time Markov Chain Object Framework Overview . . . . . . . . . . . 10-8
Markov Chain Analysis Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-11

Create and Modify Markov Chain Model Objects . . . . . . . . . . . . . . . . . . 10-17


Create Markov Chain from Stochastic Transition Matrix . . . . . . . . . . . . 10-17
Create Markov Chain from Random Transition Matrix . . . . . . . . . . . . . 10-19
Specify Structure for Random Markov Chain . . . . . . . . . . . . . . . . . . . . 10-20

Work with State Transitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-23

Visualize Markov Chain Structure and Evolution . . . . . . . . . . . . . . . . . . 10-27

Determine Asymptotic Behavior of Markov Chain . . . . . . . . . . . . . . . . . 10-39

Identify Classes in Markov Chain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-47

xvii
Compare Markov Chain Mixing Times . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-50

Simulate Random Walks Through Markov Chain . . . . . . . . . . . . . . . . . . 10-59

Compute State Distribution of Markov Chain at Each Time Step . . . . . 10-66

State-Space Models
11
What Are State-Space Models? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-3
Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-3
State-Space Model Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-5

What Is the Kalman Filter? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-7


Standard Kalman Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-7
State Forecasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-8
Filtered States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-8
Smoothed States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-9
Smoothed State Disturbances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-9
Forecasted Observations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-10
Smoothed Observation Innovations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-10
Kalman Gain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-11
Backward Recursion of the Kalman Filter . . . . . . . . . . . . . . . . . . . . . . . 11-11
Diffuse Kalman Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-12

Explicitly Create State-Space Model Containing Known Parameter Values


........................................................ 11-13

Create State-Space Model with Unknown Parameters . . . . . . . . . . . . . . 11-15


Explicitly Create State-Space Model Containing Unknown Parameters
.................................................... 11-15
Implicitly Create Time-Invariant State-Space Model . . . . . . . . . . . . . . . 11-16

Create State-Space Model Containing ARMA State . . . . . . . . . . . . . . . . 11-18

Implicitly Create State-Space Model Containing Regression Component


........................................................ 11-21

Implicitly Create Diffuse State-Space Model Containing Regression


Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-23

Implicitly Create Time-Varying State-Space Model . . . . . . . . . . . . . . . . 11-25

Implicitly Create Time-Varying Diffuse State-Space Model . . . . . . . . . . 11-27

Create State-Space Model with Random State Coefficient . . . . . . . . . . 11-30

Estimate Time-Invariant State-Space Model . . . . . . . . . . . . . . . . . . . . . . 11-32

Estimate Time-Varying State-Space Model . . . . . . . . . . . . . . . . . . . . . . . 11-35

xviii Contents
Estimate Time-Varying Diffuse State-Space Model . . . . . . . . . . . . . . . . . 11-39

Estimate State-Space Model Containing Regression Component . . . . . 11-43

Filter States of State-Space Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-45

Filter Time-Varying State-Space Model . . . . . . . . . . . . . . . . . . . . . . . . . . 11-48

Filter Time-Varying Diffuse State-Space Model . . . . . . . . . . . . . . . . . . . 11-53

Filter States of State-Space Model Containing Regression Component


........................................................ 11-59

Smooth States of State-Space Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-62

Smooth Time-Varying State-Space Model . . . . . . . . . . . . . . . . . . . . . . . . 11-65

Smooth Time-Varying Diffuse State-Space Model . . . . . . . . . . . . . . . . . . 11-71

Smooth States of State-Space Model Containing Regression Component


........................................................ 11-77

Simulate States and Observations of Time-Invariant State-Space Model


........................................................ 11-80

Simulate Time-Varying State-Space Model . . . . . . . . . . . . . . . . . . . . . . . 11-83

Simulate States of Time-Varying State-Space Model Using Simulation


Smoother . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-87

Estimate Random Parameter of State-Space Model . . . . . . . . . . . . . . . . 11-90

Forecast State-Space Model Using Monte-Carlo Methods . . . . . . . . . . . 11-97

Forecast State-Space Model Observations . . . . . . . . . . . . . . . . . . . . . . 11-103

Forecast Observations of State-Space Model Containing Regression


Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-106

Forecast Time-Varying State-Space Model . . . . . . . . . . . . . . . . . . . . . . 11-110

Forecast State-Space Model Containing Regime Change in the Forecast


Horizon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-114

Forecast Time-Varying Diffuse State-Space Model . . . . . . . . . . . . . . . . 11-119

Compare Simulation Smoother to Smoothed States . . . . . . . . . . . . . . 11-123

Rolling-Window Analysis of Time-Series Models . . . . . . . . . . . . . . . . . 11-128


Rolling-Window Analysis for Parameter Stability . . . . . . . . . . . . . . . . . 11-128
Rolling Window Analysis for Predictive Performance . . . . . . . . . . . . . . 11-128

Assess State-Space Model Stability Using Rolling Window Analysis . 11-131


Assess Model Stability Using Rolling Window Analysis . . . . . . . . . . . . 11-131

xix
Assess Stability of Implicitly Created State-Space Model . . . . . . . . . . 11-134

Choose State-Space Model Specification Using Backtesting . . . . . . . . 11-138

Functions
12

Appendices
A
Data Sets and Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-2

Glossary

xx Contents
1

Getting Started

• “Econometrics Toolbox Product Description” on page 1-2


• “Econometric Modeling” on page 1-3
• “Econometrics Toolbox Model Objects, Properties, and Object Functions” on page 1-7
• “Stochastic Process Characteristics” on page 1-16
• “Bibliography” on page 1-22
1 Getting Started

Econometrics Toolbox Product Description


Model and analyze financial and economic systems using statistical methods

Econometrics Toolbox provides functions for modeling and analyzing time series data. It offers a wide
range of diagnostic tests for model selection, including tests for impulse analysis, unit roots and
stationarity, cointegration, and structural change. You can estimate, simulate, and forecast economic
systems using a variety of models, including, regression, ARIMA, state space, GARCH, multivariate
VAR and VEC, and switching models representing dynamic shifts in data. The toolbox also provides
Bayesian and Markov-based tools for developing time-varying models that learn from new data.

1-2
Econometric Modeling

Econometric Modeling
In this section...
“Model Selection” on page 1-3
“Econometrics Toolbox Features” on page 1-3

Model Selection
A probabilistic time series model is necessary for a wide variety of analysis goals, including
regression inference, forecasting, and Monte Carlo simulation. When selecting a model, aim to find
the most parsimonious model that adequately describes your data. A simple model is easier to
estimate, forecast, and interpret.

• Specification tests help you identify one or more model families that could plausibly describe the
data generating process.
• Model comparisons help you compare the fit of competing models, with penalties for complexity.
• Goodness-of-fit checks help you assess the in-sample adequacy of your model, verify that all model
assumptions hold, and evaluate out-of-sample forecast performance.

Model selection is an iterative process. When goodness-of-fit checks suggest model assumptions are
not satisfied—or the predictive performance of the model is not satisfactory—consider making model
adjustments. Additional specification tests, model comparisons, and goodness-of-fit checks help guide
this process.

Econometrics Toolbox Features


Modeling Features Related Functions
Questions
What is the • The conditional mean and variance models, regression • arima
dimension of my models with ARIMA errors, and Bayesian linear regression • bayeslm
response variable? models in this toolbox are for modeling univariate,
discrete-time data. • egarch

• Separate models are available for multivariate, discrete- • egcitest


time data, such as VAR and VEC models. • dssm
• State-space models support univariate or multivariate • garch
response variables. • gjr
• jcontest
• regARIMA
• ssm
• varm
Is my time series • Stationarity tests are available. If your data is not • arima
stationary? stationary, consider transforming your data. Stationarity is • i10test
the foundation of many time series models.
• kpsstest
• Or, consider using a nonstationary ARIMA model if there
is evidence of a unit root in your data. • lmctest

1-3
1 Getting Started

Modeling Features Related Functions


Questions
Does my time series • Unit root tests are available. Evidence in favor of a unit • adftest
have a unit root? root suggests your data is difference stationary. • arima
• You can difference a series with a unit root until it is • i10test
stationary, or model it using a nonstationary ARIMA
model. • pptest
• vratiotest
How can I handle • You can deseasonalize (seasonally adjust) your data. Use • arima
seasonal effects? seasonal filters or regression models to estimate the • regARIMA
seasonal component.
• Seasonal ARIMA models use seasonal differencing to
remove seasonal effects. You can also include seasonal
lags to model seasonal autocorrelation (both additively
and multiplicatively).
Is my data • Sample autocorrelation and partial autocorrelation • arima
autocorrelated? functions help identify autocorrelation. • autocorr
• Conduct a Ljung-Box Q-test to test autocorrelations at • fgls
several lags jointly.
• hac
• If autocorrelation is present, consider using a conditional
mean model. • lbqtest

• For regression models with autocorrelated errors, • parcorr


consider using FGLS or HAC estimators. If the error • regARIMA
model structure is an ARIMA model, consider using a
regression model with ARIMA errors.
What if my data is • Looking for autocorrelation in the squared residual series • archtest
heteroscedastic is one way to detect conditional heteroscedasticity. • egarch
(exhibits volatility • Engle’s ARCH test evaluates evidence against the null of • fgls
clustering)? independent innovations in favor of an ARCH model
alternative. • garch

• To model conditional heteroscedasticity, consider using a • gjr


conditional variance model. • hac
• For regression models that exhibit heteroscedastic errors,
consider using FGLS or HAC estimators.
Is there an • You can use a Student’s t distribution to model fatter tails • arima
alternative to a than a Gaussian distribution (excess kurtosis). • egarch
Gaussian innovation • You can specify a t innovation distribution for all
distribution for • garch
conditional mean and variance models, and ARIMA error
leptokurtic data? models in Econometrics Toolbox. • gjr

• You can estimate the degrees of freedom of the t • regARIMA


distribution along with other model parameters.

1-4
Econometric Modeling

Modeling Features Related Functions


Questions
How do I decide • You can compare nested models using misspecification • aicbic
between several tests, such as the likelihood ratio test, Wald’s test, or • lmtest
model fits? Lagrange multiplier test.
• lratiotest
• Information criteria, such as AIC or BIC, compare model
fit with a penalty for complexity. • waldtest
Do I have two or • The Johansen and Engle-Granger cointegration tests • egcitest
more time series that assess evidence of cointegration. • jcitest
are cointegrated? • Consider using the VEC model for modeling multivariate, • jcontest
cointegrated series.
• Also consider cointegration when regressing time series.
If present, it can introduce spurious regression effects.
What if I want to • ARIMAX, VARX, regression models with ARIMA errors, • arima
include predictor and Bayesian linear regression models are available in • bayeslm
variables? this toolbox.
• dssm
• State-space models support predictor data.
• ssm
• regARIMA
• varm
What if I want to • Regression models with ARIMA errors are available in this • bayeslm
implement toolbox. • fgls
regression, but the • Regress robustly using FGLS or HAC estimators.
classical linear • hac
model assumptions • Use Bayesian linear regression. • mvregress
might not apply? • For a series of examples on time series regression • regARIMA
techniques that illustrate common principles and tasks in
time series regression modeling, see Econometrics
Toolbox Examples.
• For more regression options, see Statistics and Machine
Learning Toolbox™ documentation.
What if observations Standard, linear state-space modeling is available in this • dssm
of a dynamic process toolbox. • ssm
include
measurement error?

See Also

Related Examples
• “Box-Jenkins Model Selection” on page 3-4
• “Detect Autocorrelation” on page 3-15
• “Detect ARCH Effects” on page 3-22
• “Unit Root Tests” on page 3-32
• “Time Series Regression I: Linear Models”

1-5
1 Getting Started

• “Time Series Regression II: Collinearity and Estimator Variance”


• “Time Series Regression III: Influential Observations”
• “Time Series Regression IV: Spurious Regression”
• “Time Series Regression V: Predictor Selection”
• “Time Series Regression VI: Residual Diagnostics”
• “Time Series Regression VII: Forecasting”
• “Time Series Regression VIII: Lagged Variables and Estimator Bias”
• “Time Series Regression IX: Lag Order Selection”
• “Time Series Regression X: Generalized Least Squares and HAC Estimators”

More About
• “Trend-Stationary vs. Difference-Stationary Processes” on page 2-6
• “Box-Jenkins Methodology” on page 3-2
• “Goodness of Fit” on page 3-63
• “Regression Models with Time Series Errors” on page 5-5
• “Nonspherical Models” on page 3-67
• “Conditional Mean Models” on page 7-3
• “Conditional Variance Models” on page 8-2
• “Vector Autoregression (VAR) Models” on page 9-3
• “Cointegration and Error Correction Analysis” on page 9-107

1-6
Econometrics Toolbox Model Objects, Properties, and Object Functions

Econometrics Toolbox Model Objects, Properties, and Object


Functions
In this section...
“Model Objects” on page 1-7
“Model Properties” on page 1-8
“Specify Models” on page 1-10
“Retrieve Model Properties” on page 1-13
“Modify Model Properties” on page 1-14
“Object Functions” on page 1-15

Model Objects
After you have a potential model for your data, you must specify the model to MATLAB® to proceed
with your analysis. Econometrics Toolbox has model objects for storing discrete-time econometric
models.

For univariate series, the available model objects are:

• arima — for integrated, autoregressive, moving average (ARIMA) models optionally containing
exogenous predictor variables
• garch — for generalized autoregressive conditional heteroscedasticity models (GARCH)
• egarch — for exponential GARCH models
• gjr — for Glosten-Jagannathan-Runkle models
• regARIMA — for regression models with ARIMA errors

For multivariate series, the available model objects are:

• varm — for vector autoregression models optionally containing exogenous predictor variables
• vecm — for vector error-correction (cointegrated VARM) models optionally containing exogenous
predictor variables

Econometrics Toolbox supports univariate Bayesian linear regression analysis. Bayesian linear
regression model objects specify the joint prior distribution of the regression coefficients and
disturbance variance. The available prior model objects are:

• conjugateblm — for the normal-inverse-gamma conjugate prior model. The regression


coefficients and disturbance variance are dependent random variables.
• semiconjugateblm — for the normal-inverse-gamma semiconjugate prior model. The regression
coefficients and disturbance variance are independent random variables.
• diffuseblm — the joint prior distribution is proportional to the inverse of the disturbance
variance.
• empiricalblm — the joint prior distribution is specified by a random sample from the joint
posterior distribution.
• customblm — the joint prior distribution is specified in a custom function that you declare.

To perform Bayesian variable selection, available prior model objects are:

1-7
1 Getting Started

• mixconjugateblm — for performing stochastic search variable selection (SSVS). The regression
coefficients and disturbance variance are dependent random variables (the prior and posterior
distributions are conjugate).
• mixsemiconjugateblm — for performing SSVS. The regression coefficients and disturbance
variance are independent random variables (the prior and posterior distributions are
semiconjugate).
• lassoblm — for performing Bayesian lasso regression.

Econometrics Toolbox supports modelling and analyzing discrete or continuous state Markov models.
Available model objects are:

• dtmc — for discrete-time Markov chain models characterized by transition matrices.


• ssm — for continuous, multivariate state-space models optionally containing exogenous predictor
variables
• dssm — for continuous, multivariate state-space models with diffuse initial states optionally
containing exogenous predictor variables

To create a model object, specify the form of your model to one of the model functions (e.g., arima or
garch). The function creates the model object of the corresponding type in the MATLAB workspace,
as shown in the figure.

You can work with model objects as you would with any other variable in MATLAB. For example, you
can assign the object variable a name, view it in the MATLAB Workspace, and display its value in the
Command Window by typing its name.

This image shows a workspace containing an arima model named Mdl.

Model Properties
A model object holds all the information necessary to estimate, simulate, and forecast econometric
models. This information includes the:

• Parametric form of the model


• Number of model parameters (e.g., the degree of the model)

1-8
Econometrics Toolbox Model Objects, Properties, and Object Functions

• Innovation distribution (Gaussian or Student’s t)


• Amount of presample data needed to initialize the model

Such pieces of information are properties of the model, which are stored as fields within the model
object. In this way, a model object resembles a MATLAB data structure (struct array).

The five model types—arima, garch, egarch, gjr, and regARIMA—have properties according to the
econometric models they support. Each property has a predefined name, which you cannot change.

For example, arima supports conditional mean models (multiplicative and additive AR, MA, ARMA,
ARIMA, and ARIMAX processes). Every arima model object has these properties, shown with their
corresponding names.

Property Name Property Description


Constant Model constant
AR Nonseasonal AR coefficients
MA Nonseasonal MA coefficients
SAR Seasonal AR coefficients (in a multiplicative model)
SMA Seasonal MA coefficients (in a multiplicative model)
D Degree of nonseasonal differencing
Seasonality Degree of seasonal differencing
Variance Variance of the innovation distribution
Distribution Parametric family of the innovation distribution
P Amount of presample data needed to initialize the AR component of
the model
Q Amount of presample data needed to initialize the MA component of
the model

When a model object exists in the workspace, double-click its name in the Workspace window to open
the Variable Editor. The Variable Editor shows all model properties and their names.

1-9
Another random document with
no related content on Scribd:
CHAPTER XVII
A NEW HOME

“Look a-here, Dan Hardy!” sputtered Mr. Savage, “don’t ye talk that
way t’ me. I say ye’re goin’ back t’ th’ farm, an’ back ye shall go. Th’
idea! After all I done fer ye, now ye’re out on bail, an’ ye won’t come
an’ work fer me.”
“Why didn’t you offer to go his bond, if you are so anxious to have
him come and work for you?” asked Mr. Harrison.
“Wa’al, I—er—that is I was—What’s that your business, anyhow?”
burst out Mr. Savage, for the question confused him. “I say he’s
comin’ back with me. Come here, young man, step lively.”
“I’m not going with you, Mr. Savage,” answered Dan firmly.
“I say ye be! Squire, make him come. I’ve got a claim on him.”
“What sort of a claim?” inquired the blacksmith.
“Wa’al, its a good claim.”
“Are you his guardian, legally appointed by the court?”
“No, I ain’t his guardian, but I’ve got a claim on him.”
“Have you legally adopted him?”
“Course not. Think I’d adopt sech a lazy boy?”
“It’s rather strange that you should be so insistent on having a ‘lazy’
boy, as you call him, work for you. But can you produce any papers,
showing that you have a legal claim on him?”
“I ain’t got no papers, an’ I don’t want none. I’ve got a claim on him,
an’ I’m goin’ t’ have him. Didn’t I save him from goin’ t’ th’ poorhouse,
an’ ain’t I fed an’ clothed him since?”
“If you have, he has more than earned what he got. Dan,” went on
the aged veteran, “you need not go back to the farm unless you want
to. Squire Perkfell will tell you that Mr. Savage has no legal claim on
you.”
“I guess that’s right,” ventured the Justice though he rather disliked
to side with the boy who had been a prisoner before him.
“All right then!” exclaimed the angry farmer, “go t’ th’ poorhouse!
That’s th’ place fer ye! But mind ye, don’t ye come around me, askin’
t’ be took back. I’ll never let ye set foot in my place ag’in. Now who’s
goin’ t’ look after ye?”
“I am!” exclaimed Mr. Harrison. “Dan shall come and live with me. I
have enough for both of us.”
“Humph!” sneered Mr. Savage. “He’ll make a fine blacksmith.”
“I intend giving up the blacksmithing business,” said the old soldier.
“Fortunately this legacy of ten thousand dollars makes me
independent. But I do not intend to be idle. I am going into business,
and Dan can help. Come, Dan.”
There were more murmurs of surprise from the crowd in the
courtroom. So many surprises had never before occurred in one day.
There was enough to talk about for a month.
“Good riddance t’ ye!” exclaimed Peter Savage, giving Dan an ugly
look.
The boy stepped forward.
“I have a case of books at your house, Mr. Savage,” he said. “I want
to get them. May I?”
“No, ye can’t have ’em!”
“But they are mine. They were given to me by my father, and I want
them.”
“Wa’al, ye can’t have ’em.”
“What right have you to retain books belonging to Dan?” asked the
blacksmith.
“I’ll keep ’em t’ make up fer all th’ trouble he made me. I may have t’
pay damages fer what th’ bull done, an’ it was his fault.”
“It was not!” exclaimed Dan.
“Hush! Never mind,” advised Mr. Harrison. “Don’t dispute with him
now, Dan,” he added in a whisper. “I’ll find a way to get the books.”
Mr. Savage left the courtroom, with a leer on his hard looking face.
He felt that he had the best of Dan, though he was somewhat put out
that the boy was not coming back with him. It meant that the old
farmer would have to do more work himself, and he knew his wife
would miss Dan around the house.
“I can’t thank you enough for all you did for me, Mr. Harrison,” said
the boy, as he and his friend went out of the Justice’s room, part of
the crowd following them.
“Then don’t try, Dan. I only did my duty by you. I am glad I had the
opportunity of going on your bond. I could not have done it a week
ago.”
“And have you really fallen heir to ten thousand dollars?”
“Yes, strange as it may seem, I have. I was the most surprised man
in the world when the lawyer sent me the papers, and the deeds to
the property, which is located in the northern part of this township.”
“I’m afraid you have undertaken too big a contract, to take me home
with you,” went on Dan. “I don’t want to be a bother to you.”
“Never fear, you and I will get along nicely together. It is true I have
not a very fine home now, but I intend soon to have a better one. If
you will not mind putting up with a few inconveniences we shall do
very well.”
“I’m sure it is very kind of you. Nothing could be more inconvenient
than where I was. I slept in the attic, and in the winter the snow used
to come in on my bed through a crack in the roof. It was not so bad
in the summer time.”
“Well, there is nothing much at my house, but, as I say, we will soon
have a better one. I intend to sell out my business as soon as I can,
and start a small machine shop in the village. I think one is needed.
Part of the property I inherited is near the river, and I can build a
shop run by water power, which will be economical. I will hire several
men, and if you wish, you can work for me.”
“I should not ask anything better,” said Dan. “I did not like farm work,
but I did it because there was nothing else to do. I am fond of
machinery.”
“Perhaps we shall make an engineer of you.”
“That would be fine. But I wish I had my books from the farm house. I
want to keep on with my studies.”
“Never mind. I’ll find a way to secure them for you.”
Thus Dan found a new home, and a much better one than he had
had since his mother died.
CHAPTER XVIII
DAN’S MIDNIGHT VISIT

Next door to the blacksmith shop was a small house where Mr.
Harrison lived alone. He did his own cooking, and, once or twice a
week, he hired a woman from the village to come in and do some
cleaning. It was to this rather humble home that the old soldier took
Dan.
“The first thing we’ll do will be to have dinner,” said Mr. Harrison. “I
suppose you are hungry.”
“Yes, for I had very little breakfast, and I have been kept pretty busy
since.”
“Well, I’ll cook something, and then we can discuss some plans.”
The blacksmith proved that he knew how to get a meal, for he had
often served as camp cook in the army.
“Can’t I wash up the dishes for you?” asked Dan, when they were
through eating. “I often did for Mrs. Savage.”
“Yes, if you like. Then you can come to the smithy. I have some work
I promised to finish for a man, and it is rather a difficult job.”
“I’m afraid you were delayed by coming to my trial,” said Dan.
“It was a delay I was glad of, since I could be of service to you.”
When Dan went into the smithy, after washing and drying the dishes,
he found Mr. Harrison hard at work.
“No one would think you had just fallen heir to a large sum,” said the
boy, for to him ten thousand dollars was a great deal of money.
“I do not intend to let the money make any difference to me, except
that I shall do work on a larger scale,” remarked the blacksmith. “I
intend to keep the shop going until I can sell it, for I have several
contracts to complete, and it would not be right to drop them. There
is no other blacksmith in the village to whom people can go. Besides,
I like to work.”
It would seem so, from the way the sturdy old man rained blow after
blow on a glowing piece of iron, hammering it into shape, while the
red sparks flew all around.
When the iron cooled he thrust it into the forge fire, and, with bared
arms he worked the bellows handle causing the flames and sparks
to shoot up the chimney, and lighting the smithy with a yellow glow.
“Can’t I help at something?” asked Dan.
“Yes, if you like. There is a box of nails and screws that are all mixed
up. I wish you would sort them according to sizes, and put them into
small boxes. It is something I have often tried in vain to get time to
do.”
Dan set to work with a will. Even in the smithy, which naturally was
not a very clean place, he liked it better than on the farm.
Dan and the blacksmith continued to live together, the boy helping
with odd jobs around the shop, and learning much that was
afterward to prove useful to him. The excitement caused by the trial
had somewhat died away, and during the next two weeks though the
two constables spent part of every day looking for clues to the
robbers, they found none.
“The town ought to hire a detective from the city,” said Mr. Harrison
one evening, when, after the day’s work was done, he and Dan were
talking the matter over.
“Yes, I wish they would find out who robbed the place. My trial will
come off in the fall, and unless there is some evidence discovered
they may find me guilty.”
“No jury would ever convict you on such flimsy testimony.”
“Perhaps not, but I don’t even want to go to trial. I want the real
robbers discovered.”
“I hope they will be. By the way, did Mr. Savage answer your letter
which you wrote him, making a formal demand for your books?”
“Yes. He said he would not give them up.”
“Then I shall compel him to by legal means. The books are yours,
and you shall have them.”
It was several days after this that Dan was thinking over the matter
of the books. He did not want his friend, the blacksmith, to have to
go to the expense of a lawsuit to recover the volumes.
“I’ve been bother enough to him,” thought Dan. “I believe I can get
those books myself. I have a right to them, and I’m going to get
them.”
He was alone in the smithy, doing a simple job of repairing with
which Mr. Harrison had entrusted him. The blacksmith was away
from home, having gone to a distant town to see a man in reference
to selling him the shop. After finishing the work Dan sat down and
did some thinking.
“I believe I’ll do it,” he said to himself, coming to a sudden decision.
“Mr. Harrison will not be at home to-night, and, if there is any trouble
over it, he will not be involved. I can stay out as late as I like and he
will ask no questions. I’ll do it to-night.”
What Dan had resolved upon was rather a rash thing, but he did not
think so at the time. Boys, when they feel that they are in the right,
often go ahead regardless of consequences. It was so in Dan’s case.
He had decided to get the books that belonged to him, and this was
how he was going to do it. He knew they were in the attic room, and
he also knew, from experience, that he could get into the room from
the old apple tree, as he had done that day when the constables
caught him as he was coming down.
About ten o’clock that night Dan left the little cottage where he and
Mr. Harrison lived. He wore an old coat, and had his cap pulled down
over his face. Though he was doing what he felt he had a right to,
still he did not want any one to see him.
By a roundabout way Dan reached the apple orchard back of Peter
Savage’s home. The house was all in darkness, as he knew it would
be, for the family went to bed early, to save kerosene oil. Still Dan
waited until midnight, to be sure every one was sound asleep.
Then the boy cautiously climbed the tree. He went slowly, made no
noise, and soon reached the limb which was outside the window of
his former room.
Making his way along this he found the window open and stepped
inside. Even in the dark he knew where to find his books. He took
them from the case and began to tie them up in two bundles with
some strong cord he had bought. He intended lowering them from
the window with a rope, and then climb down the tree.
Just as he was ready to lower the books, the door of the room
suddenly opened and standing there, with a lamp in his hand, was
Mr. Savage. Behind him was his wife. They were in their night
dresses and Mrs. Savage held a poker.
“So, Dan Hardy, we’ve caught ye!” she exclaimed. “Not content with
robbin’ th’ doctor’s house, ye’ve turned regular burglar, an’ are tryin’
t’ rob us! Catch him, Peter, he’ll not git off so easy this time!”
CHAPTER XIX
THE FALLING CHIMNEY

For a moment Dan did not know what to do. He was too surprised
to speak, and, though he had been caught, almost like a burglar, he
knew he morally had the right to do what he had done.
“So it was you, makin’ th’ noise that woke us up, was it, Dan Hardy?”
asked Mr. Savage, advancing into the room. “Ye’re goin’ t’ th’ bad
fast. Now ye’ll have t’ deliver up whatever ye stole from my house,
an’ then I’ll send fer th’ constables.”
“I haven’t stolen anything from your house, Mr. Savage!”
“Then what did ye come sneakin’ in here fer, like a thief in th’ night?”
“I came after my books, which you refused to let me have. Now that I
have them I am going to leave.”
“Ye be, eh? Wa’al, I guess I’ll have suthin’ t’ say about that. Likely
story! Come here t’ git a few wuthless books! More like ye come here
t’ git th’ money ye heard I drawed out th’ bank!”
“I didn’t know you drew any money out of the bank.”
“Ye’re a thief, Dan Hardy, an’ ye know it!” exclaimed Mrs. Savage.
“Catch him, Peter. I’ll hold him while ye’ go over t’ Mr. Lane’s an’
telephone fer th’ constables.”
“I tell you I only came here for my books, and you have no right to
molest me,” declared Dan.
“We’ll see how much of that th’ judge will believe,” sneered Mr.
Savage. “Ye’d better come along with me, an’ make no trouble.”
“I’ll not come with you.”
Dan formed a sudden resolution. With a quick motion he threw his
books from the window. Then he turned and made for it himself. It
did not take long to get out on the limb, and, a few seconds later he
was climbing down to the ground.
“Catch him! Stop him! Hold him!” cried Mrs. Savage. “Why don’t ye
hold him, Peter?”
“Hold him, Susan? Might as well try t’ hold an eel after it’s got away
from ye. Can’t ye see he’s gone?”
“Thieves! Robbers!” cried the woman. “Dan Hardy tried to rob th’
house!”
Her cries awakened the hired men, but, by the time they had slipped
on their trousers and come out, Dan was far away. He had grabbed
up his books and run across the fields to the road. Then he walked
to Mr. Harrison’s house.
“Well, I got my books,” said the boy as he undressed and went to
bed, “but I suppose there’ll be a row over it.”
The blacksmith came back early the next day, and Dan told him all
about it.
“I am a little sorry you did that,” said Mr. Harrison, “yet I don’t know
as I blame you. Mr. Savage was a mean man to retain the books,
and, though you were not proceeding strictly according to law, you
were morally in the right. I think whatever violation of law there was,
is so slight that it need cause you no worry. Still I will go and see
Squire Perkfell, as Mr. Savage will probably try to have a warrant
issued for your arrest.”
Nor was the old soldier mistaken in his surmise. When he got to the
Squire’s office he found the angry farmer there.
“Ah, good morning,” remarked the Justice pleasantly, when he saw
the blacksmith. It was quite a different greeting than the one he had
given when Mr. Harrison wanted to represent Dan at the trial. But
then matters were different now. Mr. Harrison was quite wealthy,
according to the Hayden standard, and the justice thought perhaps
he might be given some legal work to do for the rich blacksmith.
“Good morning,” returned Mr. Harrison. “I came in to see you about a
certain matter, when you have finished with Mr. Savage.”
“Wa’al, my business has got t’ be attended to, an’ I don’t care who
knows it,” said the farmer. “I want a warrant fer th’ arrest of that
Hardy boy.”
“Then my business is the same as yours,” said the blacksmith. “We
will discuss it together.”
“No, we won’t discuss nothin’. I want him arrested, that’s all.”
“Yes, yes. Of course,” said the Squire. “Certainly. I will attend to it.
Now what do you charge him with Mr. Savage?”
The truth was Squire Perkfell was between two fires. He wanted to
please the blacksmith, because he knew he had money, and he
wanted to keep on friendly terms with Mr. Savage, who was also
wealthy and a power in the community, and who was to be reckoned
with on election day.
“I charge him with bein’ a burglar, an’ with comin’ inter my house at
midnight t’ rob an’ steal,” declared Mr. Savage.
“Perhaps we can simplify matters” interposed Mr. Harrison. “Did he
break into your house, Mr. Savage?”
“No, he come in a winder that was left open.”
“Then I think I am right, Squire, in saying there can be no charge of
breaking entered against Dan.”
“No, no. You’re right. If he didn’t break any doors or windows to get
in, he can’t be charged with breaking,” agreed the Justice. “To arrest
a burglar, charged with breaking, entering and stealing, he must be
guilty of all three things.”
“So, then, Dan broke nothing,” resumed the blacksmith. “Did he steal
anything, Mr. Savage?”
“He took some books.”
“Whose were they?”
“Wa’al, his own, I s’pose, but I was holdin’ em.”
“Which you had no legal right to do. Then Dan did not steal
anything.”
“Guess you’re right,” agreed the Justice. “You can’t properly charge
him with stealing, Mr. Savage.”
“Wa’al, he entered, didn’t he?” asked the farmer, satisfied that he
could have Dan arrested on this charge.
“He entered, through a window, which was not fastened, and took
property that belonged to him, which you unlawfully retained,” said
Mr. Harrison. “I admit there might have been a technical violation of
the law on Dan’s part, but there was also a violation on the part of
Mr. Savage. If he insists on having a warrant for Dan on the charge
of entering, I shall ask for one, on Dan’s behalf, for the arrest of Mr.
Savage.”
“On what charge?” asked the Justice nervously, for he did not want
to have to arrest such an influential and rich man as Mr. Savage.
“On the charge of unlawfully converting to his own use the property
of another,” answered the blacksmith. “Now you can take your
choice, Mr. Savage. Either drop this silly charge, or I will make one
against you.”
“I—I think Mr. Harrison is right,” said Squire Perkfell, nervously
rubbing his hands together.
“Humph! I’ll git even with him, an’ Dan too,” growled the farmer as he
left the office of the Justice. He had decided that discretion was the
better part of valor, and he was not sure but that he had acted
unlawfully, as indeed he had, in keeping Dan’s books.
“Well, it’s all settled,” said the blacksmith to Dan, when he came
back home. “Now you can rest easy.”
“No, not exactly,” answered Dan. “I have still to find the rascals who
robbed the doctor’s house.”
“Perhaps we may in time. Don’t worry.”
But Dan did, though it did no good. The weeks passed, and there
was no clue to those who had burglarized the doctor’s house. Of
course Dan had, with the aid of Mr. Harrison, made a search in the
woods, where he had seen the mysterious men, but nothing was
found. Either it was well hidden, or the robbers, if such they were,
had taken their booty away again.
The summer began to wane. Mr. Harrison had not yet found a
purchaser for his smithy, and he continued to work there, as the
machine shop he had started to build was not ready for operations. It
might seem queer for a man with ten thousand dollars to be working
at the forge, like a common blacksmith, but Mr. Harrison liked the
exercise, and he knew if he stopped, the people in the neighborhood
would have to go a long distance to get any work of that nature
done. Besides he had some special machinery to put in his new
shop, and part of it he could build better himself than he could hire
done.
So he and Dan continued to live together, working in the smithy from
day to day. The boy was acquiring valuable information, and he had
plenty of time to study.
One day, Dan and his friend were working on a large iron frame that
needed welding. It was so large that Mr. Harrison had to stand inside
it, while it rested on the anvil. Dan stood in front to steady it.
It had just been taken from the fire, where one part was heated white
hot, for welding, and Mr. Harrison was raining blows on it with a
small sledge hammer when Dan, looking up, uttered an exclamation
of fear.
The big brick chimney, in which the forge was constructed was
cracking, for it was quite old. As Dan watched he saw it start to
topple over, right on Mr. Harrison, who could not get out of the way
because he was inside the frame, which was like a big cage.
“Look out!” cried Dan. “The chimney is falling!”
Nearer and nearer to Mr. Harrison, who was trying in vain to extricate
himself from the framework, came the heavy mass of bricks and
mortar. He was in danger of being crushed to death.
Then Dan did a risky thing. Dropping his end of the frame he ran
around in behind the anvil, and, exerting all his strength, he raised
the mass of iron rods, holding the frame up so Mr. Harrison could
crawl to one side.
“Quick! Come out!” cried the boy.
The blacksmith saw his opportunity and made a rapid move to
safety. Then Dan leaped out of the way, and not an instant too soon,
for, a second later the bricks toppled down, burying the anvil and
frame out of sight.
“QUICK—COME OUT!” CRIED THE BOY.—Page 156.
CHAPTER XX
ANOTHER ROBBERY

When the dust cleared away the blacksmith, who was rather pale,
stepped forward and clasped Dan by the hand.
“I owe my life to you,” he said, his voice trembling in spite of himself.
“I could not have gotten out of the way if you had not helped me.”
“Oh, I guess you might have managed somehow,” replied Dan, for
he did not like to hear himself praised so highly.
“No, I could not. The frame would have held me, and I would now be
lying dead under those bricks, Dan.”
“I am glad I was here to help you.”
“I meant to have the forge chimney repaired some time ago,” went
on the blacksmith. “I noticed a large crack in it, but I kept putting it off
from time to time. This has taught me a lesson, that delay is
dangerous.”
“It will need quite some repairing now.”
“Yes, it will have to be rebuilt. And this decides me. I shall now give
up the blacksmith work for ever. I have finished all the contracts I
had, except this frame, and that can be done elsewhere.”
“What are you going to do then, Mr. Harrison?”
“I shall close up the shop until I find a purchaser for it. Then I will
repair the chimney. In the meanwhile I shall proceed with the work of
erecting my little machine shop. I have the arrangements all made,
and there is no need of delaying further. How would you like to learn
to be a machinist?”
“Very much, I think. Would I get a chance to study?”
“That would be part of your work. I should expect you to devote
some of your time to your books. My plans are not all made yet, and
I may have something to say to you, later, on this point. But the more
you can study, the better machinist you will make, and, in time, you
may become a mechanical engineer, which, I believe, you told me
you would like to be.”
“Indeed I would.”
“Very well then, now we’ll close up this shop. It seems strange to do
so, for I have made my living out of it for a number of years, and I
feel attached to it.”
“You are not going to move out of the house, are you?”
“Not at present. It is rather small, but, if you do not complain about
the cramped quarters, I’m sure I shall not.”
“I am only too glad to live there with you,” said Dan. “It is very good
of you to keep me.”
“I am not going to lose sight of you after this,” remarked Mr. Harrison
with a smile. “I may want you to save my life again,” and, though he
smiled, there was a serious note in his voice, for his escape had
been a narrow one.
“I am going to build a house near my machine shop,” the blacksmith
went on, “but it will be some time before it is done. Meanwhile we will
continue to live in the cottage. Now, Dan, come on, we will lock up
the old shop, and I do not expect to enter it again until I bring a
purchaser for it.”
The door was locked, not without a feeling of regret on the part of the
old soldier, for in spite of his hard work, there were many pleasant
associations connected with the forge that now lay in ruins.
As the two were closing up the blacksmith shop, Silas Martin, the
hired man of Dr. Maxwell’s, drove past.
“What’s th’ matter?” he asked. “Takin’ a holiday an’ goin’ fishin’, Mr.
Harrison?”
“Well, we’re taking a holiday because we have to. The forge has
fallen apart.”
“Bless my pitchfork!” exclaimed Silas, who was given to odd
expressions. “Ye don’t say so! Why that forge was built nearly fifty
years ago, I’ve heard my father say.”
“Yes, it was quite an old shop when I bought it, and that is twenty
years ago. It has seen its best days, like some of us, Silas. I suppose
you haven’t had any more robbers out your way?”
“No, an’ we don’t want ’em.”
“Have they discovered any more clues?” asked Dan anxiously, for as
the weeks went by, without any new evidence being brought out, he
began to worry about the results of his trial.
“No more clues,” replied Silas. “Doc was talkin’ th’ other day of hirin’
a city detective, ef them constables didn’t do suthin’ pretty soon.
Between you an’ me an’ the hitchin’ post,” he went on in a whisper, “I
don’t believe them constables know beans about catchin’ burglars.”
“I agree with you,” said Mr. Harrison with a laugh.
“G’lang!” exclaimed Silas to his horse. “Got t’ hurry back,” he added,
as he drove off. “Doc’s waitin’ fer me.”
“I wonder if those robbers will ever be caught, so that I will be
cleared of suspicion?” spoke Dan, with something of a sigh.
“Don’t you worry,” advised the old soldier. “It will all come right in
time.”
Dan and his friend went to the small cottage where they lived. It was
a humble home, but neat and clean, for Dan took pride in keeping it
in order. Mr. Harrison said it was more like a home to him than it had
ever been before, for Dan had learned many housekeeping ways
from Mrs. Savage, mean as she had been to him.
Mr. Harrison lost no time in arranging to have his machine shop
finished. This necessitated him going away from home quite often
during the next few weeks, and Dan was left alone. He did not mind
this as it gave him time for studying, which he had to neglect while
he was working for Mr. Savage.
One morning as the two were at the partly completed shop, watching
the workmen, Constable Wolff came along.
“Wa’al, I s’pose ye heard th’ news?” he said in a questioning tone.
“No. What news?” asked Mr. Harrison.
“Why, Hank Lee’s store was robbed last night.”
“Mr. Lee’s store robbed!” exclaimed Dan.
“Yep,” went on the constable, as if he was delighted at it, as, indeed,
he was secretly, as it gave him a chance to do something, even if it
was not very much. “They bursted open a winder, same as they
done at Dr. Maxwell’s an’ cleaned out th’ cash drawer, besides takin’
a lot of cigars.”
“Have you any clues?” asked the old soldier. “Do you suspect Dan of
this crime?” and he smiled a little bitterly.
“No, sir, Dan ain’t suspicioned of this. We know he didn’t have
nothin’ t’ do with it, ’cause Dr. Maxwell seen th’ two men what did th’
robbing!”
“He did? Then maybe they are the same persons who robbed his
place!” exclaimed Dan. “Tell me about it, Mr. Wolff.”
CHAPTER XXI
EXCITEMENT IN TOWN

The constable liked nothing better than a chance to talk about


something he was concerned in. He sat down on a pile of lumber
and leisurely related the story of the robbery. As he took quite a long
time at it, perhaps it will be better if I condense his story into a few
words.
In brief, then, Mr. Lee had come down as usual that morning to open
his store. He noticed nothing strange until he reached the cigar case,
which he found almost emptied of its contents. That made him
suspicious, and he hurried to the money drawer where he had left
about fifty dollars. It was all gone. Next an opened window attracted
his attention, and he saw that it had been pried up with some
instrument, allowing the thieves to enter.
“But I thought you said Dr. Maxwell saw the two thieves,” spoke Dan,
when the constable had told that much, and had not mentioned the
more important part of the story.
“So I did. I’m comin’ t’ that ef ye give me time. It was this way. Th’
Doc was out on a late call—I think it was t’ Mrs. Tillman’s daughter,
Nancy; she’s quite sick. He was comin’ back along th’ road about
one o’clock this mornin’, all alone, fer Si Martin run a rusty nail in his
hand, an’ can’t drive.
“Wa’al, th’ way Doc tells it, jest as he got near Hank’s store he seen
a light in it. He thought it was sort of queer fer Hank t’ be keepin’
open, but he figered that mebby he were balancin’ his books.
Anyhow th’ Doc got a notion he’d like a cigar, an’ he saw a chance t’
go in an’ buy one. So he stopped his hoss in front of th’ store an’
started up th’ steps.
“He must a’ scared th’ burglars, fer, th’ next minute two men jumped
out of th’ side winder they’d busted open, an’ they set off lickity-split

You might also like