
- •Preface
- •Part IV. Basic Single Equation Analysis
- •Chapter 18. Basic Regression Analysis
- •Equation Objects
- •Specifying an Equation in EViews
- •Estimating an Equation in EViews
- •Equation Output
- •Working with Equations
- •Estimation Problems
- •References
- •Chapter 19. Additional Regression Tools
- •Special Equation Expressions
- •Robust Standard Errors
- •Weighted Least Squares
- •Nonlinear Least Squares
- •Stepwise Least Squares Regression
- •References
- •Chapter 20. Instrumental Variables and GMM
- •Background
- •Two-stage Least Squares
- •Nonlinear Two-stage Least Squares
- •Limited Information Maximum Likelihood and K-Class Estimation
- •Generalized Method of Moments
- •IV Diagnostics and Tests
- •References
- •Chapter 21. Time Series Regression
- •Serial Correlation Theory
- •Testing for Serial Correlation
- •Estimating AR Models
- •ARIMA Theory
- •Estimating ARIMA Models
- •ARMA Equation Diagnostics
- •References
- •Chapter 22. Forecasting from an Equation
- •Forecasting from Equations in EViews
- •An Illustration
- •Forecast Basics
- •Forecasts with Lagged Dependent Variables
- •Forecasting with ARMA Errors
- •Forecasting from Equations with Expressions
- •Forecasting with Nonlinear and PDL Specifications
- •References
- •Chapter 23. Specification and Diagnostic Tests
- •Background
- •Coefficient Diagnostics
- •Residual Diagnostics
- •Stability Diagnostics
- •Applications
- •References
- •Part V. Advanced Single Equation Analysis
- •Chapter 24. ARCH and GARCH Estimation
- •Basic ARCH Specifications
- •Estimating ARCH Models in EViews
- •Working with ARCH Models
- •Additional ARCH Models
- •Examples
- •References
- •Chapter 25. Cointegrating Regression
- •Background
- •Estimating a Cointegrating Regression
- •Testing for Cointegration
- •Working with an Equation
- •References
- •Binary Dependent Variable Models
- •Ordered Dependent Variable Models
- •Censored Regression Models
- •Truncated Regression Models
- •Count Models
- •Technical Notes
- •References
- •Chapter 27. Generalized Linear Models
- •Overview
- •How to Estimate a GLM in EViews
- •Examples
- •Working with a GLM Equation
- •Technical Details
- •References
- •Chapter 28. Quantile Regression
- •Estimating Quantile Regression in EViews
- •Views and Procedures
- •Background
- •References
- •Chapter 29. The Log Likelihood (LogL) Object
- •Overview
- •Specification
- •Estimation
- •LogL Views
- •LogL Procs
- •Troubleshooting
- •Limitations
- •Examples
- •References
- •Part VI. Advanced Univariate Analysis
- •Chapter 30. Univariate Time Series Analysis
- •Unit Root Testing
- •Panel Unit Root Test
- •Variance Ratio Test
- •BDS Independence Test
- •References
- •Part VII. Multiple Equation Analysis
- •Chapter 31. System Estimation
- •Background
- •System Estimation Methods
- •How to Create and Specify a System
- •Working With Systems
- •Technical Discussion
- •References
- •Vector Autoregressions (VARs)
- •Estimating a VAR in EViews
- •VAR Estimation Output
- •Views and Procs of a VAR
- •Structural (Identified) VARs
- •Vector Error Correction (VEC) Models
- •A Note on Version Compatibility
- •References
- •Chapter 33. State Space Models and the Kalman Filter
- •Background
- •Specifying a State Space Model in EViews
- •Working with the State Space
- •Converting from Version 3 Sspace
- •Technical Discussion
- •References
- •Chapter 34. Models
- •Overview
- •An Example Model
- •Building a Model
- •Working with the Model Structure
- •Specifying Scenarios
- •Using Add Factors
- •Solving the Model
- •Working with the Model Data
- •References
- •Part VIII. Panel and Pooled Data
- •Chapter 35. Pooled Time Series, Cross-Section Data
- •The Pool Workfile
- •The Pool Object
- •Pooled Data
- •Setting up a Pool Workfile
- •Working with Pooled Data
- •Pooled Estimation
- •References
- •Chapter 36. Working with Panel Data
- •Structuring a Panel Workfile
- •Panel Workfile Display
- •Panel Workfile Information
- •Working with Panel Data
- •Basic Panel Analysis
- •References
- •Chapter 37. Panel Estimation
- •Estimating a Panel Equation
- •Panel Estimation Examples
- •Panel Equation Testing
- •Estimation Background
- •References
- •Part IX. Advanced Multivariate Analysis
- •Chapter 38. Cointegration Testing
- •Johansen Cointegration Test
- •Single-Equation Cointegration Tests
- •Panel Cointegration Testing
- •References
- •Chapter 39. Factor Analysis
- •Creating a Factor Object
- •Rotating Factors
- •Estimating Scores
- •Factor Views
- •Factor Procedures
- •Factor Data Members
- •An Example
- •Background
- •References
- •Appendix B. Estimation and Solution Options
- •Setting Estimation Options
- •Optimization Algorithms
- •Nonlinear Equation Solution Methods
- •References
- •Appendix C. Gradients and Derivatives
- •Gradients
- •Derivatives
- •References
- •Appendix D. Information Criteria
- •Definitions
- •Using Information Criteria as a Guide to Model Selection
- •References
- •Appendix E. Long-run Covariance Estimation
- •Technical Discussion
- •Kernel Function Properties
- •References
- •Index
- •Symbols
- •Numerics

Appendix C. Gradients and Derivatives
Many EViews estimation objects provide built-in routines for examining the gradients and derivatives of your specifications. You can, for example, use these tools to examine the analytic derivatives of your nonlinear regression specification in numeric or graphical form, or you can save the gradients from your estimation routine for specification tests.
The gradient and derivative views may be accessed from most estimation objects by selecting View/Gradients and Derivatives or, in some cases, View/Gradients, and then selecting the appropriate view.
If you wish to save the numeric values of your gradients and derivatives, you will need to use the gradient and derivative procedures. These procs may be accessed from the main Proc menu.
Note that all views and procs are not available for every estimation object or every estimation technique.
Gradients
EViews provides you with the ability to examine and work with the gradients of the objective function for a variety of estimation objects. Examining these gradients can provide useful information for evaluating the behavior of your nonlinear estimation routine, or can be used as the basis of various tests of specification.
Since EViews provides a variety of estimation methods and techniques, the notion of a gradient is a bit difficult to describe in casual terms. EViews will generally report the values of the first-order conditions used in estimation. To take the simplest example, ordinary least squares minimizes the sum-of-squared residuals:
S(b) = Â(yt – Xt¢b)2 |
(C.1) |
t |
|
The first-order conditions for this objective function are obtained by differentiating with respect to b , yielding
–2(yt – Xt¢b)Xt |
(C.2) |
t |
|
EViews allows you to examine both the sum and the corresponding average, as well as the value for each of the individual observations. Furthermore, you can save the individual values in series for subsequent analysis.
The individual gradient computations are summarized in the following table:

764—Appendix C. Gradients and Derivatives
Least squares |
|
= –2(yt |
– ft(Xt, b)) |
∂ft(Xt, b) |
||||
gt |
|
------------------------ |
||||||
|
|
|||||||
|
|
|
|
|
|
∂b |
|
|
Weighted least squares |
|
|
|
2 ∂ft(Xt, b) |
||||
|
gt |
= –2(yt – ft(Xt, b))wt |
|
∂b |
|
|||
|
|
|
|
|
|
------------------------ |
||
|
|
|
|
|
|
|||
Two-stage least squares |
|
|
|
|
∂ft(Xt, b) |
|||
|
gt |
= –2(yt – ft(Xt, b))Pt |
|
∂b |
|
|||
|
|
|
|
|
|
------------------------ |
||
|
|
|
|
|
|
|
||
Weighted two-stage least |
|
|
˜ |
|
|
∂ft(Xt, b) |
||
squares |
gt = |
–2(yt – ft(Xt, b))wtPtwt |
------------------------ |
|||||
∂b |
|
|||||||
Maximum likelihood |
|
gt |
∂lt(Xt, b) |
|
|
|
||
|
|
= ------------------------ |
|
|
|
|||
|
|
|
∂b |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
where and ˜ are the projection matrices corresponding to the expressions for the esti-
P P
mators in Chapter 20. “Instrumental Variables and GMM,” beginning on page 55, and l is the log likelihood contribution function.
Note that the expressions for the regression gradients are adjusted accordingly in the presence of ARMA error terms.
Gradient Summary
To view the summary of the gradients, select View/Gradients and Derivatives/Gradient Summary, or View/Gradients/Summary. EViews will display a summary table showing the sum, mean, and Newton direction associated with the gradients. Here is an example table from a nonlinear least squares estimation equation:
Gradients of the Objective Function
Gradients evaluated at estimated parameters
Equation: EQ01
Method: Least Squares
Specification: LOG(CS) = C(1) +C(2)*(GDP^C(3)-1)/C(3)
Computed using analytic derivatives
Coefficient |
Sum |
Mean |
Newton Dir. |
|
|
|
|
|
|
|
|
C(1) |
5.21E-10 |
2.71E-12 |
1.41E-14 |
C(2) |
9.53E-09 |
4.96E-11 |
-3.11E-18 |
C(3) |
3.81E-08 |
1.98E-10 |
2.47E-18 |
|
|
|
|
|
|
|
|
There are several things to note about this table. The first line of the table indicates that the gradients have been computed at estimated parameters. If you ask for a gradient view for an

Gradients—765
estimation object that has not been successfully estimated, EViews will compute the gradients at the current parameter values and will note this in the table. This behavior allows you to diagnose unsuccessful estimation problems using the gradient values.
Second, you will note that EViews informs you that the gradients were computed using analytic derivatives. EViews will also inform you if the specification is linear, if the derivatives were computed numerically, or if EViews used a mixture of analytic and numeric techniques. We remind you that all MA coefficient derivatives are computed numerically.
Lastly, there is a table showing the sum and mean of the gradients as well as a column labeled “Newton Dir.”. The column reports the non-Marquardt adjusted Newton direction used in first-derivative iterative estimation procedures (see “First Derivative Methods” on page 757).
In the example above, all of the values are “close” to zero. While one might expect these values always to be close to zero when
evaluated at the estimated parameters, there are a number of reasons why this will not always be the case. First, note that the sum and mean values are highly scale variant so that changes in the scale of the dependent and independent variables may lead to marked changes in these values. Second, you should bear in mind that while the Newton direction is related to the terms used in the optimization procedures, EViews’ test for convergence does not directly use the Newton direction. Third, some of the iteration options for system estimation do not iterate coefficients or weights fully to convergence. Lastly, you should note that the values of these gradients are sensitive to the accuracy of any numeric differentiation.
Gradient Table and Graph
There are a number of situations in which
you may wish to examine the individual contributions to the gra-
dient vector. For example, one common source of singularity in nonlinear estimation is the presence of very small combined with very large gradients at a given set of coefficient values.
EViews allows you to examine your gradients in two ways: as a spreadsheet of values, or as line graphs, with each set of coefficient gradients plotted in a separate graph. Using these tools, you can examine your data for observations with outlier values for the gradients.

766—Appendix C. Gradients and Derivatives
Gradient Series
You can save the individual gradient values in series using the Make Gradient Group procedure. EViews will create a new group containing series with names of the form GRAD## where ## is the next available name.
Note that when you store the gradients, EViews will fill the series for the full workfile range. If you view the series, make sure to set the workfile sample to the sample used in estimation if you want to reproduce the table displayed in the gradient views.
Application to LM Tests
The gradient series are perhaps most useful for carrying out Lagrange multiplier tests for nonlinear models by running what is known as artificial regressions (Davidson and MacKinnon 1993, Chapter 6). A generic artificial regression for hypothesis testing takes the form of regressing:
|
|
∂ft(Xt, b) |
|
|
ut on |
∂b |
˜ |
(C.3) |
|
and Zt |
||||
˜ |
|
------------------------ |
|
˜ |
˜ |
|
b are the esti- |
||
where u are the estimated residuals under the restricted (null) model, and |
mated coefficients. The Z are a set of “misspecification indicators” which correspond to departures from the null hypothesis.
An example program (“GALLANT2.PRG”) for performing an LM auxiliary regression test is provided in your EViews installation directory.
Gradient Availability
The gradient views are currently available for the equation, logl, sspace and system objects. The views are not, however, currently available for equations estimated by GMM or ARMA equations specified by expression.
Derivatives
EViews employs a variety of rules for computing the derivatives used by iterative estimation procedures. These rules, and the user-defined settings that control derivative taking, are described in detail in “Derivative Computation Options” on page 754.
In addition, EViews provides both object views and object procedures which allow you to examine the effects of those choices, and the results of derivative taking. These views and procedures provide you with quick and easy access to derivatives of your user-specified functions.
It is worth noting that these views and procedures are not available for all estimation techniques. For example, the derivative views are currently not available for binary models since only a limited set of specifications are allowed.

Derivatives—767
Derivative Description
The Derivative Description view provides a quick summary of the derivatives used in estimation.
For example, consider the simple nonlinear regression model: |
|
yt = c(1)(1 – exp(–c(2)xt)) + et |
(C.4) |
Following estimation of this single equation, we can display the description view by selecting View/Gradients and Derivatives.../Derivative Description.
Derivatives of the Equation Specification
Equation: EQ02
Method: Least Squares
Specification: RESID = Y - ((C(1)*(1-EXP(-C(2)*X))))
Computed using analytic derivatives
Variable |
Derivative of Specification |
|
|
|
|
C(1) |
-1 + exp(-c(2) * x) |
C(2) |
-c(1) * x * exp(-c(2) * x) |
|
|
|
|
There are three parts to the output from this view. First, the line labeled “Specification:” describes the equation specification that we are estimating. You will note that we have written the specification in terms of the implied residual from our specification.
The next line describes the method used to compute the derivatives used in estimation. Here, EViews reports that the derivatives were computed analytically.
Lastly, the bottom portion of the table displays the expressions for the derivatives of the regression function with respect to each coefficient. Note that the derivatives are in terms of the implied residual so that the signs of the expressions have been adjusted accordingly.
In this example, all of the derivatives were computed analytically. In some cases, however, EViews will not know how to take analytic derivatives of your expression with respect to one or more of the coefficient. In this situation, EViews will use analytic expressions where possible, and numeric where necessary, and will report which type of derivative was used for each coefficient.
Suppose, for example, that we estimate: |
|
yt = c(1)(1 – exp(–f(c(2)xt))) + et |
(C.5) |
where f is the standard normal density function. The derivative view of this equation is

768—Appendix C. Gradients and Derivatives
Derivatives of the Equation Specification
Equation: EQ02
Method: Least Squares
Specification: RESID = Y - ((C(1)*(1-EXP(-@DNORM(C(2)*X)))))
Computed using analytic derivatives
Use accurate numeric derivatives where necessary
Variable |
Derivative of Specification |
|
|
|
|
C(1) |
-1 + exp(-@dnorm(c(2) * x)) |
C(2) |
--- accurate numeric --- |
|
|
|
|
Here, EViews reports that it attempted to use analytic derivatives, but that it was forced to use a numeric derivative for C(2) (since it has not yet been taught the derivative of the @dnorm function).
If we set the estimation option so that we only compute fast numeric derivatives, the view would change to
Derivatives of the Equation Specification
Equation: EQ02
Method: Least Squares
Specification: RESID = Y - ((C(1)*(1-EXP(-C(2)*X))))
Computed using fast numeric derivatives
Variable |
Derivative of Specification |
|
|
|
|
C(1) |
--- fast numeric --- |
C(2) |
--- fast numeric --- |
|
|
|
|
to reflect the different method of taking derivatives.
If your specification contains autoregressive terms, EViews will only compute the derivatives with respect to the regression part of the equation. The presence of the AR components is, however, noted in the description view.

Derivatives—769
Derivatives of the Equation Specification
Equation: EQ02
Method: Least Squares
Specification: [AR(1)=C(3)] = Y - (C(1)-EXP(-C(2)*X))
Computed using analytic derivatives
Variable |
Derivative of Specification* |
|
|
|
|
C(1) |
-1 |
C(2) |
-x * exp(-c(2) * x) |
|
|
|
|
*Note: derivative expressions do not account for ARMA components
Recall that the derivatives of the objective function with respect to the AR components are always computed analytically using the derivatives of the regression specification, and the lags of these values.
One word of caution about derivative expressions. For many equation specifications, analytic derivative expressions will be quite long. In some cases, the analytic derivatives will be longer than the space allotted to them in the table output. You will be able to identify these cases by the trailing “...” in the expression.
To see the entire expression, you will have to create a table object and then resize the appropriate column. Simply click on the Freeze button on the toolbar to create a table object, and then highlight the column of interest. Click on Width on the table toolbar and enter in a larger number.
Derivative Table and Graph
Once we obtain estimates of the parameters of our nonlinear regression model, we can examine the values of the derivatives at the estimated parameter values. Simply select View/Gradients and Derivatives... to see a spreadsheet view or line graph of the values of the derivatives for each coefficient: