Eviews Ref
Eviews Ref
Eviews Ref
Programming Reference
EViews 4.0 Command and Programming Reference
Copyright © 19942000 Quantitative Micro Software, LLC
All Rights Reserved
Printed in the United States of America
ISBN 1-880411-29-6
This software product, including program code and manual, is copyrighted, and all rights
are reserved by Quantitative Micro Software, LLC. The distribution and sale of this product
are intended for the use of the original purchaser only. Except as permitted under the
United States Copyright Act of 1976, no part of this product may be reproduced or distrib-
uted in any form or by any means, or stored in a database or retrieval system, without the
prior written permission of Quantitative Micro Software.
Disclaimer
The authors and Quantitative Micro Software assume no responsibility for any errors that
may appear in this manual or the EViews program. The user assumes all responsibility for
the selection of the program to achieve intended results, and for the installation, use, and
results obtained from the program.
Trademarks
Windows, Windows 95/98/2000/NT/Me, and Microsoft Excel are trademarks of Microsoft
Corporation. PostScript is a trademark of Adobe Corporation. X11.2 and X12-ARIMA Ver-
sion 0.2.7 are seasonal adjustment programs developed by the U. S. Census Bureau.
Tramo/Seats is copyright by Agustin Maravall and Victor Gomez. All other product names
mentioned in this manual may be trademarks or registered trademarks of their respective
companies.
CHAPTER 1. INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Using Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Batch Program Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
How to Use this Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .431
iv
iv Table of Contents
Chapter 1. Introduction
EViews provides you with both a Windows and a command line interface for working with
your data. Almost every operation that can be accomplished using menus may also be
entered into the command window, or placed in programs for batch processing. You are
free to choose the mixture of techniques which best fits your particular style of work.
The Command and Programming Reference (CPR) documents the use of commands and
programs to perform various tasks in EViewsthe companion Users Guide describes in
greater detail the general features of EViews, with an emphasis on the interactive Windows
interface.
In addition to providing a basic command reference, the Command and Programming Ref-
erence documents the use of EViews powerful batch processing language and advanced
programming features. With EViews, you can create and store commands in programs that
automate repetitive tasks, or generate a record of your research project.
Using Commands
Commands may be used interactively, or executed in batch mode.
Interactive Use
To work interactively, you should type a command into the command window, then press
ENTER to execute the command immediately. If you enter an incomplete command,
EViews will open a dialog box prompting you for additional information.
The command window is located just below the main menu bar at the top of the EViews
window. Unless you are editing an object or have a dialog box open, EViews will assume
that anything you type on the keyboard belongs in the command window. The blinking
vertical insertion bar at the left end of the command window indicates that EViews is
expecting a command.
A command that you enter in the window will be executed as soon as you press ENTER.
The insertion point need not be at the end of the command line when you press ENTER.
EViews will execute the entire line containing the insertion point.
As you enter commands, EViews will create a list in the command window. You can scroll
up to an earlier command, edit it, and hit ENTER. The modified command will be executed
again. You may also use standard Windows copy-and-paste between the command win-
dow and any other window.
The contents of the command area may also be saved directly into a text file for later use:
make certain that the command window is active by clicking anywhere in the window, and
then select File/Save As
from the main menu.
You can resize the command window so that a larger number of previously executed com-
mands are visible. Use the mouse to move the cursor to the bottom of the window, hold
down the mouse button, and drag the bottom of the window downwards.
Alternatively, you can use your favorite text (ASCII) editor to create a program file contain-
ing your commands. The commands in this program may then be executed from within
EViews.
Chapter 2, Object and Command Basics, on page 5 explains the basics of using
commands to work with EViews objects, and provides a cross-referenced listing of
basic EViews commands associated with various tasks.
Chapter 5, Working with Tables, on page 77 documents the table object and
describes the basics of working with strings in EViews.
Chapter 7, Sample Programs, on page 115 contains annotated sample EViews pro-
grams to perform a variety of common tasks.
The remaining sections contain dictionary-style reference material for all of the EViews
commands, functions, and operators:
While this reference manual is not designed to be read from cover-to-cover, we recommend
that before beginning extensive work using commands, you spend some time reading
through Chapter 2, Object and Command Basics, which describes the basics of using
commands to work with objects. A solid understanding of this material is important for
getting the most out of EViews.
If you wish to use programs in EViews, you should, at the very least, examine the first part
of Chapter 6, EViews Programming, which describes the basics of creating, loading, and
running a batch program.
4Chapter 1. Introduction
Chapter 2. Object and Command Basics
This chapter provides an overview of the command method of working with EViews and
EViews objects. If you are new to EViews, you may find it useful to consult the Users
Guide (especially Chapters 1 and 3) for a more detailed introduction to EViews and a dis-
cussion of objects, their views, and procedures.
The command line interface of EViews is comprised of a set of single line commands, each
of which may be classified as one of the following:
object declarations.
object commands.
auxiliary commands.
An EViews program is composed of a sequence of these commands, and may also contain
the following:
The use of control variables and program control statements is discussed in detail in the
programming guide in Chapter 6, EViews Programming, on page 83. The following sec-
tions provide an overview of the first four types of commands.
Object Declaration
The first step is to create or declare an object. A simple declaration has the form:
object_type object_name
where object_name is the name you would like to give to the new object and
object_type is one of the following type identifiers:
equation eq1
Matrix objects are typically declared with their dimension in parentheses after the object
type. For example
matrix(5,5) x
coef(10) results
Note that in order to create an object you must have a workfile currently open in EViews.
You can open or create a workfile interactively from the File Menu, or you can use the
load or workfile commands to perform the same operations inside a program. See
Workfile Basics on page 33 of the Users Guide for details.
Object Commands7
7
Object Commands
An object command is a command which accesses an objects views and procedures
(procs). Object commands have two main parts, a display action followed by a view speci-
fication. The view specification describes the view or procedure of the object to be acted
upon. The display action determines what is to be done with the output from the view or
procedure.
where
action ...............is one of four verbs (do, freeze, print, show)
act_opt .................an option that modifies the default behavior of the action
object ................the name of the object to be acted upon
view_proc .........the object view or procedure to be acted upon
view_proc_opt .......an option that modifies the default behavior of the view or proce-
dure
arg_list .................a list of view or procedure arguments, generally separated by
spaces
In most cases, some of the components of the general object command are not necessary
since some views and procs do not require an argument list or options.
Furthermore, you need not explicitly specify an action. If no action is provided, the show
action is assumed for views and the do action is assumed for procedures. For example,
when using the command to display the series view for a line graph:
gdp.line
show gdp.line
In some cases, you may wish to modify the default behavior by explicitly describing the
action. For example,
print eq1.ls cons c gdp
both performs the implicit do action and then sends the output from the proc to the
printer.
Examples:
show gdp.line
print(l) group1.stats
freeze(output1) eq1.ls cons c gdp
do eq1.forecast eq1f
The first example opens a window displaying a line graph of the series GDP. The second
example prints (in landscape mode) descriptive statistics for the series in GROUP1. The
third example creates a table named OUTPUT1 from the estimation results of EQ1 for a
least squares regression of CONS on GDP. The final example executes the forecast proce-
dure of EQ1, putting the forecasted values into the series EQ1F and suppressing any proce-
dure output.
Of these four examples, only the first opens a window and displays output on the screen.
Output Control
As discussed above, the display action determines the destination for view and procedure
output. Here we note in passing a few extensions to these general rules.
You may specify that a view be simultaneously printed and displayed on your screen by
the letter p as an option to the object command. For example, the expression
gdp.correl(24,p)
since correl is a series view. The p option can be combined with other options, sepa-
rated by commas. So as not to interfere with other option processing, we strongly recom-
mend that the p option should always be specified after any required options.
Note that the print command accepts the l or p option to indicate landscape or por-
trait orientation. For example,
print(l) gdp.correl(24)
Printer output can be redirected to a text file or frozen output. See the output command
in Chapter 8, and the discussion in Appendix A, Global Options, beginning on page 633
of the Users Guide, for details.
The freeze command used without options creates an untitled graph or table from a view
specification:
freeze gdp.line
You also may provide a name for the frozen object in parentheses after the word freeze.
For example,
freeze(figure1) gdp.bar
object_name = expression
where object_name identifies the object whose data is to be modified and expression
is an expression which evaluates to an object of an appropriate type.
The nature of the assignment varies depending on what type of object is on the left hand
side of the equal sign. To take a simple example, consider the assignment statement:
x = 5 * log(y) + z
where X, Y and Z are series. This assignment statement will take the log of each element of
Y, multiply each value by 5, add the corresponding element of Z, and, finally, assign the
result into the appropriate element of X.
creates a new series called LGDP and initializes its elements with the log of the series GDP.
Similarly, the command
equation eq1.ls y c x1 x2
creates a new equation object called EQ1 and initializes it with the results from regressing
the series Y against a constant term, the series X1 and the series X2.
Additional examples,
scalar elas = 2
series tr58 = @trend(1958)
group nipa gdp cons inv g x
equation cnsfnc2.ls log(cons)=c(1)+c(2)*yd
vector beta = @inverse(x*x)*(x*y)
An object can be declared multiple times so long as it is always declared to be of the same
type. The first declaration will create the object, subsequent declarations will have no
effect unless the subsequent declaration also specifies how the object is to be initialized.
For example,
smpl @first 1979
series dummy = 1
smpl 1980 @last
series dummy=0
creates a series named DUMMY that has the value 1 prior to 1980 and the value 0 thereaf-
ter.
Redeclaration of an object to a different type is not allowed and will generate an error.
Auxiliary Commands
Auxiliary commands are commands which are either unrelated to a particular object (i.e.,
not views or procs), or which act on an object in a way that is generally independent of the
type or contents of the object (often acting symmetrically across objects of all types). Aux-
iliary commands typically follow the syntax:
command(option_list) argument_list
where command is the name of the view or procedure to be executed, option_list is a list of
options separated by commas, and argument_list is a list of arguments generally sepa-
rated by spaces.
Managing Workfiles and Databases11
11
which will store the three objects GDP, M and X in the database named DB1 in the direc-
tory C:\NEWDATA.
There is also a set of auxiliary commands which performs operations that create new unti-
tled or unnamed objects. For example, the command:
ls y c x1 x2
will regress the series Y against a constant term, the series X1 and the series X2, and create
a new untitled equation object to hold the results.
Although this latter set of auxiliary commands can sometimes be useful for carrying out
simple tasks, their overuse will tend to make it difficult to manage your work. Unnamed
objects cannot be referenced by name from within a program, cannot be saved to disk, and
cannot be deleted except through the graphical Windows interface. Wherever possible, you
should favor using named rather than untitled objects for your work. For example, we may
replace the above auxiliary command with:
equation eq1.ls y c x1 x2
Managing Workfiles
To declare and create a new workfile, follow the workfile command with a name for the
workfile, an option for the frequency of the workfile, and the start and end dates. The
workfile frequency type options are:
a annual.
s semi-annual.
q quarterly.
m monthly.
12Chapter
12 2. Object and Command Basics
w weekly.
d daily (5 day week).
7 daily (7 day week).
u undated.
For example,
creates a new quarterly workfile named MACRO1 from the first quarter of 1965 to the
fourth quarter of 1995.
Note that if you have multiple workfiles open, the workfile command may be used to
change the active workfile.
To save your workfile, type save followed by a workfile name. If any part of the path or
workfile name has spaces, you should enclose the entire expression in quotation marks.
The active workfile will be saved in the default path under the given name. You may
optionally provide a path to save the workfile in a different directory:
save a:\mywork
If necessary, enclose the path name in quotations. To close the workfile, type close fol-
lowed by the workfile name. For example,
close mywork
To open a previously saved workfile, follow the load keyword with the name of the work-
file. You can optionally include a path designation to open workfiles that are not saved in
the default path. For example,
load "c:\mywork\proj1"
You may also use the open command to open a previously saved workfile. To use open,
you have to type the full workfile name including the extension .WK1:
Managing Workfiles and Databases13
13
open proj2.wk1
Managing Databases
To create a new database, follow the dbcreate keyword with a name for the new data-
base. Alternatively, you could use the db keyword followed by a name for the new data-
base. The two commands differ only when the named database already exists. If you use
dbcreate and the named database already exists on disk, EViews will error indicating
that the database already exits. If you use db and the named database already exists on
disk, EViews will simply open the existing database. Note that the newly opened database
(either by dbcreate or db) will become the default database.
For example,
dbcreate mydata1
creates a new database named MYDATA1 in the default path, opens a new database win-
dow, and makes MYDATA1 the default database.
db c:\evdata\usdb
opens the USDB database in the specified directory if it already exists. If it does not,
EViews creates a new database named USDB, opens its window, and makes it the default
database.
You can also use dbopen to open an existing database and to make it the default database.
For example,
dbopen findat
opens the database named FINDAT in the default directory. If the database does not exist,
EViews will error indicating that the specified database cannot be found. You can also use
open to open an existing database. To use open, you must provide the full name of the
database, including the file extension .EDB:
open findat.edb
You may use dbrename to rename an existing database. Follow the dbrename keyword by
the current (old) name and a new name.
dbrename temp1 newmacro
To delete an existing database, use the dbdelete command. Follow dbdelete by the
name of the database to delete.
dbdelete c:\data\usmacro
dbcopy makes a copy of the existing database. Follow dbcopy by the name of the source
file and the name of the destination file.
14Chapter
14 2. Object and Command Basics
dbpack, dbrepair, and dbrebuild are database maintenance commands. See also
Chapter 6, EViews Databases, beginning on page 107 of the Users Guide for a detailed
description.
Managing Objects
In the course of a program you will often need to manage the objects in a workfile by copy-
ing, renaming, deleting and storing them to disk. EViews provides a number of auxiliary
commands which perform these operations. The following discussion introduces you to
the use of these commands; a full description of each command is provided in Chapter 8,
Command Reference, beginning on page 133.
Copying Objects
You can create a duplicate copy of an object using the copy command. The copy com-
mand is an auxiliary command with the format:
where source_name is the name of the object you wish to duplicate, and dest_name is
the name you want attached to the new copy of the object.
The copy command may also be used to copy objects in databases and to move objects
between workfiles and databases.
A destination wildcard pattern can be used only when a wildcard pattern has been pro-
vided for the source, and the destination pattern must always conform to the source pat-
tern in that the number and order of wildcard characters must be exactly the same
between the two. For example, the following patterns
When using wildcards, the destination name is formed by replacing each wildcard in the
destination pattern by the characters from the source name that matched the correspond-
ing wildcard in the source pattern. Some examples should make this principle clear:
Note, as shown in the second example, that a simple asterisk for the destination pattern
does not mean to use the unaltered source name as the destination name. To copy objects
between containers preserving the existing name, either repeat the source pattern as the
destination pattern
copy x* db1::x*
copy x* db1::
If you use wildcard characters in the source name and give a destination name without a
wildcard character, EViews will keep overwriting all objects which match the source pat-
tern to the name given as destination.
For additional discussion of wildcards, see Appendix C, Wildcards, on page 639 of the
Users Guide.
Renaming Objects
You can give an object a different name using the rename command. The rename com-
mand has the format:
16Chapter
16 2. Object and Command Basics
where source_name is the original name of the object and dest_name is the new name you
would like to give to the object.
You may use wildcards when renaming series. The name substitution rules are identical to
those described above for copy.
Deleting Objects
Objects may be removed from the workfile using the delete command. The delete
command has the format:
delete name_pattern
where name_pattern can either be a simple name such as XYZ, or a pattern containing
the wildcard characters ? and *, where ? means to match any one character, and
* means to match zero or more characters. When a pattern is provided, all objects in the
workfile with names matching the pattern will be deleted. Appendix C, Wildcards, on
page 639 of the Users Guide describes further the use of wildcards.
Saving Objects
All named objects will be saved automatically in the workfile when the workfile is saved to
disk. You can store and retrieve the current workfile to and from disk using the save and
load commands. Unnamed objects will not be saved as part of the workfile.
You can also save objects for later use by storing them in a database. The store command
has the format:
store(option_list) object1 object2 …
where object1, object2, ..., are the names of the objects you would like to store in the data-
base. If no options are provided, the series will be stored in the current default database
(see Chapter 6 of the Users Guide for a discussion of the default database). You can store
objects into a particular database by using the option d=db_name or by prepending the
object name with a database name followed by a double colon ::, such as:
Fetch Objects
You can retrieve objects from a database using the fetch command. The fetch command
has the same format as the store command:
Basic Command Summary17
17
To specify a particular database use the d= option or the :: extension as for store.
A list of views and procedures available for each object may be found in the next chapter.
Commands for working with matrix objects are listed in Chapter 4, Matrix Language, on
page 53, and EViews programming expressions are described in Chapter 6, EViews Pro-
gramming, beginning on page 83.
Object Declarations
You may define EViews objects using the following commands/declarations (see the corre-
sponding entries in Chapter 8, Command Reference, beginning on page 133 for syntax
details and additional discussion): coef, equation, graph, group, logl, matrix,
model, pool, rowvector, sample, scalar, series, sspace, sym, system, table,
text, var, vector.
Command Actions
do.........................execute procedures (p. 190).
freeze ...................create view object (p. 211).
print .....................print view (p. 278).
show ....................display objects (p. 317).
Global Commands
exit ...................... exit the EViews program (p. 199).
param .................. set parameter values (p. 274).
rndseed................ set the seed of the random number generator (p. 295).
smpl .................... set current workfile sample (p. 322).
setconvert ............ set default frequency conversion methods (p. 311).
tic ........................ reset the timer (p. 353).
toc ....................... display elapsed time (since timer reset) in seconds (p. 354).
Table Commands
setcell .................. format and fill in a table cell (p. 309).
setcolwidth .......... set width of a table column (p. 310).
setline.................. place a horizontal line in table (p. 316).
Basic Command Summary19
19
20Chapter
20 2. Object and Command Basics
Chapter 3. Object, View and Procedure Reference
The following is a reference guide to the views, procedures, and data members for each of
the objects found in EViews:
To use these views, procedures, and data members you should list the name of the object
followed by a period, and then enter the name of the view, procedure, or data member,
along with any options or arguments:
object_name.view_name(options) arguments
object_name.proc_name(options) arguments
object_name.data_member
For example, to display the line graph view of the series object CONS, you can enter the
command:
cons.line
To perform a dynamic forecast using the estimates in the equation object EQ1, you may
enter:
eq1.forecast y_f
To save the coefficient covariance matrix from EQ1, you can enter:
sym cov1=eq1.@coefcov
Each of the views and procedures is documented more fully in the alphabetical listing
found in Chapter 8, Command Reference, on page 133.
22Chapter
22 3. Object, View and Procedure Reference
Coef
Coefficient vector. Coefficients are used to represent the parameters of equations and sys-
tems.
There are two ways to create a coef. First, enter the coef keyword, followed by a name to
be given to the coefficient vector. The dimension of the coef may be provided in parenthe-
ses after the keyword:
coef alpha
coef(10) beta
You may also combine a declaration with an assignment statement. If you do not provide
an explicit assignment statement, new coefs are initialized to zero.
See also param (page 182) for information on initializing coefficients, and the entries for
each of the estimation objects (equation, pool, sspace, system, and var) for additional
methods of accessing coefficients.
Coef Views
bar....................... bar graph of coefficient vector plotted against the coefficient index
(p. 149).
label .................... label view (p. 149).
line ...................... line graph of coefficient vector plotted against the coefficient index
(p. 234).
sheet.................... spreadsheet (p. 316).
spike.................... spike graph (p. 327).
stats ..................... descriptive statistics (p. 334).
Coef Procs
displayname......... set display name (p. 189).
read ..................... import data into coefficient vector (p. 283).
write.................... export data from coefficient vector (p. 367).
Coef Examples
The coefficient vector declaration
Equation23
23
coef(10) coef1=3
create, size, and initialize the coefficient vectors MYCOEF1, MYCOEF2 and MYCOEF3.
fills the vector MM with the value of the 10th element of BETA, and assigns the 7th value
of BETA to the scalar SHAPE.
Equation
Equation object. Equations are used for single equation estimation, testing, and forecast-
ing.
equation eq01
Equation Methods
arch......................autoregressive conditional heteroskedasticity (ARCH and GARCH)
(p. 143).
binary...................binary dependent variable models (includes probit, logit, gompit)
models (p. 151).
censored ...............censored and truncated regression (includes tobit) models
(p. 156).
count ....................count data modeling (includes poisson, negative binomial and
quasi-maximum likelihood count models) (p. 171).
gmm.....................generalized method of moments (p. 216).
ls ..........................linear and nonlinear least squares regression (includes weighted
least squares and ARMAX) models (p. 239).
24Chapter
24 3. Object, View and Procedure Reference
Equation Views
archtest................ LM test for the presence of ARCH in the residuals (p. 145).
auto ..................... Breusch-Godfrey serial correlation Lagrange Multiplier (LM) test
(p. 148).
chow ................... Chow breakpoint and forecast tests for structural change (p. 159).
coefcov ................ coefficient covariance matrix (p. 163).
correl ................... correlogram of the residuals (p. 170).
correlsq................ correlogram of the squared residuals (p. 171).
derivs .................. derivatives of the equation specification (p. 187).
garch ................... conditional standard deviation graph (only for equations estimated
using ARCH) (p. 214).
grads ................... examine the gradients of the objective function (p. 218).
hist ...................... histogram and descriptive statistics of the residuals (p. 224).
label .................... label information for the equation (p. 231).
means .................. descriptive statistics by category of the dependent variable (only
for binary, ordered, censored and count equations) (p. 259).
predict ................. prediction (fit) evaluation table (only for binary and ordered equa-
tions) (p. 277).
representations..... text showing specification of the equation (p. 286).
reset .................... Ramseys RESET test for functional form (p. 289).
resids ................... display, in tabular form, the actual and fitted values for the depen-
dent variable, along with the residuals (p. 291).
results.................. table of estimation results (p. 292).
rls........................ recursive residuals least squares (only for equations estimated by
ordinary least squares, without ARMA terms) (p. 292).
testadd ................. likelihood ratio test for adding variables to equation (p. 345).
testdrop ............... likelihood ratio test for dropping variables from equation (p. 348).
testfit ................... performs Hosmer and Lemeshow and Andrews goodness-of-fit
tests (only for equations estimated using binary) (p. 350).
wald .................... Wald test for coefficient restrictions (p. 362).
white ................... White test for heteroskedasticity (p. 363).
Equation25
25
Equation Procs
displayname .........set display name (p. 189).
fit .........................static forecast (p. 207).
forecast.................dynamic forecast (p. 209).
makederivs ...........make group containing derivatives of the equation specification
(p. 244).
makegarch ............create conditional variance series (only for ARCH
equations)(p. 245).
makegrads ............make group containing gradients of the objective function
(p. 246).
makelimits............create vector of estimated limit points (only for ordered models)
(p. 250).
makemodel ...........create model from estimated equation (p. 250).
makeregs ..............make group containing the regressors (p. 251).
makeresids ...........make series containing residuals from equation (p. 251).
updatecoefs...........update coefficient vector(s) from equation (p. 358).
Equation Examples
To apply an estimation method (proc) to an existing equation object:
equation ifunc
ifunc.ls r c r(-1) div
To declare and estimate an equation in one step, combine the two commands:
equation value.tsls log(p) c d(x) @ x(-1) x(-2)
equation drive.logit ifdr c owncar dist income
equation countmod.count patents c rdd
You can save the t-statistics and covariance matrix for your parameter estimates:
vector eqstats=eq01.@tstats
Graph27
27
matrix eqcov=eq01.@coefcov
Graph
Graph view object.
Graphs may be created by declaring a graph using one of the graph methods described
below, or by freezing the graphical view of an object. For example:
graph myline.line ser1
graph myscat.scat ser1 ser2
graph myxy.xyline grp1
declare and create the graph objects MYLINE, MYSCAT and MYXY. Alternatively, you can
use the freeze command to create graph objects:
freeze(myline) ser1.line
group grp2 ser1 ser2
freeze(myscat) grp2.scat
freeze(myxy) grp1.xyline
which are equivalent to the declarations above. For details, see freeze (p. 211).
Graph View
label .....................label information for the graph (p. 231).
Graph Procs
addtext .................place arbitrary text on the graph (p. 139).
align .....................align the placement of multiple graphs (p. 140).
dates.....................controls labeling of the bottom date/time axis in time plots
(p. 176).
28Chapter
28 3. Object, View and Procedure Reference
Graph Examples
You can declare your graph
graph abc.xyline(m) unemp gnp inf
graph bargraph.bar(d,l)unemp gnp
freeze(mykernel) ser1.kdensity
Group
Group of series. Groups are used for working with collections of series objects.
To declare a group, enter the keyword group, followed by a name, and optionally, a list of
series or expressions:
group salesvrs
group nipa cons(-1) log(inv) g x
Group Views
bar....................... single or multiple bar graph view of all series (p. 149).
Group29
29
Group Procs
add .......................add one or more series to the group (p. 135).
displayname .........set display name (p. 189).
resample ...............resample from rows of group (p. 287).
30Chapter
30 3. Object, View and Procedure Reference
Group Examples
To create a group G1, you can enter
group g1 gdp income
To change the contents of an existing group, you can repeat the declaration, or use the add
and drop commands:
group g1 x y
g1.add w z
g1.drop y
The following commands produce a cross-tabulation of the series in the group, display the
covariance matrix, and test for equality of variance:
g1.freq
g1.cov
g1.testbtw(var,c)
scalar nsers=g1.@count
Logl
Likelihood object. Used for performing maximum likelihood estimation of user-specified
likelihood functions.
To declare a logl object, use the logl keyword, followed by a name to be given to the
object.
Logl Method
ml........................ maximum likelihood estimation (p. 261).
Logl31
31
Logl Views
append .................add line to the specification (p. 141).
checkderivs...........compare user supplied and numeric derivatives (p. 158).
coefcov .................coefficient covariance matrix (p. 163).
grads ....................examine the gradients of the log likelihood (p. 218).
label .....................label view of likelihood object (p. 231).
results ..................estimation results (p. 292).
spec......................likelihood specification (p. 327).
wald .....................Wald coefficient restriction test (p. 362).
Logl Procs
displayname .........set display name (p. 189).
makegrads ............make group containing gradients of the log likelihood (p. 246).
makemodel ...........make model (p. 250).
updatecoefs...........update coefficient vector(s) from likelihood (p. 358).
Logl Statements
The following statements can be included in the specification of the likelihood object.
These statements are optional, except for @logl which is required. See Chapter 18, The
Log Likelihood (LogL) Object, on page 455 of the Users Guide for further discussion.
@byeqn ................evaluate specification by equation.
@byobs ................evaluate specification by observation (default).
@deriv .................specify an analytic derivative series.
@derivstep ...........set parameters to control step size.
@logl ...................specify the likelihood contribution series.
@param ...............set starting values.
@temp .................remove temporary working series.
Logl Examples
To declare a likelihood named LL1:
logl ll1
To estimate LL1 by maximum likelihood (the showstart option displays the starting val-
ues):
ll1.ml(showstart)
To save the estimated covariance matrix of the parameters from LL1 as a named matrix
COV1:
matrix cov1=ll1.@coefcov
Matrix
Matrix (two-dimensional array).
There are several ways to create a matrix object. You can enter the matrix keyword (with
an optional row and column dimension) followed by a name:
matrix scalarmat
matrix(10,3) results
Alternatively, you can combine a declaration with an assignment statement, in which case
the new matrix will be sized accordingly.
Matrix Views
bar .......................single or multiple bar graph of each column against the row index
(p. 149).
cor........................correlation matrix by columns (p. 169).
cov .......................covariance matrix by columns(p. 173).
errbar ...................error bar graph view (p. 197).
hilo ......................high-low(-open-close) chart (p. 223).
label .....................label information for the matrix (p. 231).
line.......................single or multiple line graph of each column by the row index
(p. 234).
pie........................pie chart view (p. 275).
scat ......................scatter diagrams of the columns of the matrix (p. 302).
sheet ....................spreadsheet view of the matrix (p. 316).
spike ....................spike graph (p. 327).
stats......................descriptive statistics by column (p. 334).
xyline ...................XY line graph with one or more X columns plotted against one or
more Y (p. 377).
Matrix Procs
displayname .........set display name (p. 189).
fill ........................fill the elements of the matrix (p. 203).
read ......................import data from disk (p. 283).
write ....................export data to disk (p. 367).
Matrix Examples
The following assignment statements create and initialize matrix objects:
matrix copymat=results
matrix covmat1=eq1.@coefcov
matrix(5,2) count
count.fill 1,2,3,4,5,6,7,8,9,10
matrix(10,30) results=3
matrix(5,5) other=results1
Graphs and covariances may be generated for the columns of the matrix:
copymat.line
copymat.cov
Model
Set of simultaneous equations used for forecasting and simulation.
declares an empty model named MYMOD. To fill MYMOD, open the model and edit the
specification view, or use the append view. Note that models are not used for estimation
of unknown parameters.
Model Views
block ................... display model block structure (p. 152).
eqs....................... view of model organized by equation (p. 197).
label .................... view or set label information for the model (p. 231).
msg ..................... display model solution messages (p. 263).
text ...................... show text showing equations in the model (p. 353).
trace .................... view of trace output from model solution (p. 355).
vars ..................... view of model organized by variable(p. 361).
Model Procs
addassign............. assign add factors to equations (p. 136).
addinit ................. initialize add factors (p. 137)
append................. append a line of text to a model (p. 141).
control ................. solve for values of control variable so that target matches trajec-
tory (p. 166).
displayname......... set display name (p. 189).
Pool35
35
Model Examples
The commands
model mod1
mod1.append y=324.35+x
mod1.append x=-234+7.3*z
mod1.solve(m=100,c=.008)
mod1(g).makegraph gr1 x y z
plots the endogenous series X, Y, and Z, in the active scenario for model MOD1.
Pool
Pooled time series, cross-section object. Used when working with data with both time
series and cross-section structure.
To declare a pool object, use the pool keyword, followed by a pool name, and optionally,
a list of pool members. Pool members are short text identifiers for the cross section units:
pool mypool
pool g7 _can _fr _ger _ita _jpn _us _uk
Pool Methods
ls ..........................estimate linear regression models including cross-section weighted
least squares, and fixed and random effects models (p. 239).
36Chapter
36 3. Object, View and Procedure Reference
Pool Views
add ...................... add cross section members to pool (p. 135).
coefcov ................ coefficient covariance matrix (p. 163).
define .................. define cross section identifiers (p. 185).
describe ............... calculate pool descriptive statistics (p. 188).
drop..................... drop cross section members from pool (p. 193).
label .................... label information for the pool object (p. 231).
representations..... text showing equations in the model (p. 286).
residcor................ residual correlation matrix (p. 289).
residcov ............... residual covariance matrix (p. 290).
resids ................... table or graph of residuals for each pool member (p. 291).
results.................. table of estimation results (p. 292).
sheet.................... spreadsheet view of series in pool (p. 316).
wald .................... Wald coefficient restriction test (p. 362).
Pool Procs
delete................... delete pool series (p. 186).
displayname......... set display name (p. 189).
fetch .................... fetch series into workfile using a pool (p. 201).
genr ..................... generate pool series using the ? (p. 215).
makegroup........... create a group of series from a pool (p. 248).
makemodel .......... creates a model object from the estimated pool (p. 250).
makeresids........... make series containing residuals from pool (p. 251).
makestats............. make descriptive statistic series (p. 256).
makesystem ......... creates a system object from the pool for other estimation methods
(p. 257).
read ..................... import pool data from disk (p. 283).
store .................... store pool series in database/bank files (p. 337).
updatecoefs .......... update coefficient vector(s) from pool (p. 358).
write.................... export pool data to disk (p. 367).
Pool Examples
To read data using the pool object
mypool1.read(b2) data.xls x? y? z?
mypool1.describe(m) z?
To estimate a pool equation using least squares and to access the t-statistics, enter
mypool1.ls y? c z? @ w?
vector mypool1.tstats
Rowvector
Row vector. (One dimensional array of numbers).
There are several ways to create a rowvector object. First, you can enter the rowvector
keyword (with an optional dimension) followed by a name:
rowvector scalarmat
rowvector(10) results
Alternatively, you may combine a declaration with an assignment statement. The new vec-
tor will be sized and initialized accordingly:
rowvector(10) y=3
rowvector z=results
Rowvector Views
bar....................... bar graph of each column (element) of the data against the row
index (p. 149).
fill ....................... fill elements of the vector (p. 203).
label .................... label information for the rowvector (p. 231).
line ...................... line graph of each column (element) of the data against the row
index (p. 234).
sheet.................... spreadsheet view of the vector (p. 316).
spike.................... spike graph (p. 327).
stats ..................... descriptive statistics (p. 334).
Rowvector Procs
displayname......... set display name (p. 189).
read ..................... import data from disk (p. 283).
write.................... export data to disk (p. 367).
Rowvector Examples
To declare a rowvector and to fill it with data read from an Excel file:
rowvector(10) mydata
mydata.read(b2) thedata.xls
scalar result1=mydata(2)
Sample
Sample of observations. Description of a set of observations to be used in operations.
To declare a sample object, use the keyword sample, followed by a name and a sample
string:
sample mysample 1960:1 1990:4
sample altsample 120 170 300 1000 if x>0
Sample Procs
set ........................reset the sample range (p. 308).
Sample Example
To change the observations in a sample object, you can use the set proc:
mysample.set 1960:1 1980:4 if y>0
sample thesamp 1 10 20 30 40 60 if x>0
thesamp.set @all
To set the current sample to use a sample, enter a smpl statement, followed by the name
of the sample object:
smpl mysample
equation eq1.ls y x c
40Chapter
40 3. Object, View and Procedure Reference
Scalar
Scalar (single number). A scalar holds a single numeric value. Scalar values may be used
in standard EViews expressions in place of numeric values.
To declare a scalar object, use the keyword scalar, followed by a name, an = sign and
a scalar expression or value.
Scalar objects have no views or procedures, and do not open windows. The value of the
scalar may be displayed in the status line at the bottom of the EViews window.
Scalar Examples
You can declare a scalar and examine its contents in the status line:
scalar pi=3.14159
scalar shape=beta(7)
show shape
Series
Series of observations. An EViews series contains a set of observations on a variable.
To declare a series, use the keyword series, followed by a name, and optionally, by an
= sign and a valid series expression:
series y
series x=3*z
Series Views
bar....................... bar graph of the series (p. 149).
bdstest ................. BDS independence test (p. 150).
cdfplot ................. distribution (cumulative, survivor, quantile) functions (p. 155).
correl ................... correlogram, autocorrelation and partial autocorrelation functions
(p. 170).
freq...................... one-way tabulation (p. 212).
hist ...................... descriptive statistics and histogram (p. 224).
kdensity ............... kernel density estimate (p. 229).
label .................... label information for the series (p. 231).
Series41
41
Series Procs
displayname .........set display name (p. 189).
hpf .......................Hodrick-Prescott filter (p. 226).
seas ......................seasonal adjustment only for quarterly and monthly time series
(p. 305).
resample ...............resample from the observations in the series (p. 287).
smooth .................exponential smoothing (p. 320).
x11 .......................seasonal adjustment by Census X11 method only for quarterly and
monthly time series (p. 371).
x12 .......................seasonal adjustment by Census X12 method only for quarterly and
monthly time series (p. 372).
Series Examples
You can declare a series in the usual fashion:
series b=income*@mean(z)
series blag=b(1)
Note that the last example, above, involves a series expression so that B(1) is treated as a
one-period lead of the entire series, not as an element operator. In contrast,
42Chapter
42 3. Object, View and Procedure Reference
scalar blag1=b(1)
Sspace
State space object. Estimation and evaluation of state space models using the Kalman fil-
ter.
To declare a sspace object, use the sspace keyword, followed by a valid name.
Sspace Method
ml........................ maximum likelihood estimation or filter initialization (p. 261).
Sspace Views
append................. add line to the specification (p. 141).
coefcov ................ coefficient covariance matrix (p. 163).
endog .................. table or graph of actual signal variables (p. 195).
grads ................... examine the gradients of the log likelihood (p. 218).
label .................... label information for the state space object (p. 231).
residcor................ standardized one-step ahead residual correlation matrix (p. 289).
residcov ............... standardized one-step ahead residual covariance matrix (p. 290).
resids ................... one-step ahead actual, fitted, residual graph (p. 291).
results.................. table of estimation and filter results (p. 292).
signalgraphs......... display graphs of signal variables (p. 318).
spec ..................... text representation of state space specification (p. 327).
statefinal .............. display the final values of the states or state covariance (p. 332).
stategraphs........... display graphs of state variables (p. 331).
stateinit................ display the initial values of the states or state covariance (p. 333).
structure .............. examine coefficient or variance structure of the specification
(p. 339).
wald .................... Wald coefficient restriction test (p. 362).
Sspace43
43
Sspace Procs
displayname .........set display name (p. 189).
forecast.................perform state and signal forecasting (p. 209).
makeendog ...........make group containing actual values for signal variables (p. 244).
makefilter .............make new Kalman Filter (p. 245).
makegrads ............make group containing the gradients of the log likelihood (p. 246).
makemodel ...........make a model object containing equations in sspace (p. 250).
makesignals ..........make group containing signal and residual series (p. 253).
makestates ............make group containing state series (p. 254).
sspace...................declare sspace object (p. 329).
updatecoefs...........update coefficient vector(s) from sspace (p. 358).
Sym
Symmetric matrix (symmetric two-dimensional array).
Declare by providing a name after the sym keyword, with the optionally specified dimen-
sion in parentheses:
sym(10) symmatrix
You may optionally assign a scalar, a square matrix or another sym in the declaration. If
the square matrix is not symmetric, the sym will contain the lower triangle. The sym will
be sized and initialized accordingly.
Sym Views
bar....................... single or multiple bar graph of each column against the row index
(p. 149).
cor ....................... correlation matrix by columns (p. 169).
cov ...................... covariance matrix by columns(p. 173).
errbar .................. error bar graph view (p. 197).
hilo...................... high-low(-open-close) chart (p. 223).
label .................... label information for the symmetric matrix (p. 231).
line ...................... single or multiple line graph of each column against the row index
(p. 234).
pie ....................... pie chart view (p. 275).
scat...................... scatter diagrams of the columns of the matrix (p. 302).
sheet.................... spreadsheet view of the matrix (p. 316).
spike.................... spike graph (p. 327).
stats ..................... descriptive statistics by column (p. 334).
xyline .................. XY line graph with one or more X columns plotted against one or
more Y (p. 377).
Sym Procs
displayname......... set display name (p. 189).
fill ....................... fill the elements of the matrix (p. 203).
read ..................... import data from disk (p. 283).
write.................... export data to disk (p. 367).
Sym Examples
The declaration
sym results(10)
results=3
creates the 10 ´ 10 matrix RESULTS and initializes each value to be 3. The following
assignment statements also create and initialize sym objects:
sym copymat=results
sym covmat1=eq1.@coefcov
sym(3,3) count
count.fill 1,2,3,4,5,6,7,8,9,10
Graphs, covariances, and statistics may be generated for the columns of the matrix:
copymat.line
copymat.cov
copymat.stats
scalar diagsum=cov1(1,1)+cov1(2,2)+cov(3,3)
System
System of equations for estimation.
system mysys
To fill a system, open the system and edit the specification view, or use append. Note that
systems are not used for simulation. See Model (p. 34).
System Methods
3sls.......................three-stage least squares (p. 134).
fiml ......................full information maximum likelihood (p. 205).
gmm.....................generalized method of moments (p. 216).
ls ..........................ordinary least squares (p. 239).
sur .......................seemingly unrelated regression (p. 340).
tsls .......................two-stage least squares (p. 355).
wls .......................weighted least squares (p. 364).
wtsls.....................weighted two-stage least squares (p. 369).
46Chapter
46 3. Object, View and Procedure Reference
System Views
coefcov ................ coefficient covariance matrix (p. 163).
endog .................. table or graph of endogenous variables (p. 195).
label .................... label information for the system object (p. 231).
residcor................ residual correlation matrix (p. 289).
residcov ............... residual covariance matrix (p. 290).
resids ................... residual graphs (p. 291).
results.................. table of estimation results (p. 292).
spec ..................... text representation of system specification (p. 327).
wald .................... Wald coefficient restriction test (p. 362).
System Procs
append................. add a line of text to the system specification (p. 141).
displayname......... set display name (p. 189).
makeendog .......... make group of endogenous series (p. 244).
makemodel .......... create a model from the estimated system (p. 250).
makeresids........... make series containing residuals from system (p. 251).
updatecoefs .......... update coefficient vector(s) from system (p. 358).
System Examples
To estimate a system using GMM and to create residual series for the estimated system:
sys1.gmm(i,m=7,c=.01,b=v)
sys1.makeresids consres incres saveres
sys1.wald c(1)=c(4)
sym covs=sys1.@coefcov
Table
Table object. Formatted two-dimensional table for output display.
To declare a table object, use the keyword table, followed by an optional row and column
dimension, and then the object name:
table onelement
48Chapter
48 3. Object, View and Procedure Reference
table(10,5) outtable
Alternatively, you may declare a table using an assignment statement. The new table will
be sized and initialized, accordingly:
table newtable=outtable
Lastly, you may use the freeze command to create tables from tabular views of other
objects (p. 211).
Table Views
label .................... label information for the table object (p. 231).
sheet.................... view table (p. 316).
Table Procs
displayname......... set display name (p. 189).
Table Commands
setcell .................. format and fill in a table cell (p. 309).
setcolwidth .......... set width of a table column (p. 310).
setline.................. place a horizontal line in table (p. 316).
Table Examples
table(5,5) mytable
%strval = mytable(2,3)
mytable(4,4) = "R2"
mytable(4,5) = @str(eq1.@r2)
Var
Vector autoregression and error correction object.
To declare a var use the keyword var, followed by a name and, optionally, by an estima-
tion specification:
var finvar
var empvar.ls 1 4 payroll hhold gdp
var finec.ec(e,2) 1 6 cp div r
Var49
49
Var Methods
ec .........................estimate a vector error correction model (p. 194).
ls ..........................estimate an unrestricted VAR (p. 239).
Var Views
arlm .....................serial correlation LM test (p. 146).
arroots ..................inverse roots of the AR polynomial (p. 147).
coint .....................Johansen cointegration test (p. 164).
correl....................residual autocorrelations (p. 170).
decomp.................variance decomposition (p. 184).
endog ...................table or graph of endogenous variables (p. 195).
impulse ................impulse response functions (p. 227).
jbera .....................residual normality test (p. 228).
label .....................label information for the var object (p. 231).
laglen ...................lag order selection criteria (p. 232).
qstats....................residual portmanteau tests (p. 281).
representations .....text describing var specification (p. 286).
residcor ................residual correlation matrix (p. 289).
residcov ................residual covariance matrix (p. 290).
resids....................residual graphs (p. 291).
results ..................table of estimation results (p. 292).
testexog ................exogeneity (Granger causality) tests (p. 349).
testlags .................lag exclusion tests (p. 351).
white ....................White heteroskedasticity test (p. 363).
Var Procs
append .................append restriction text (p. 141).
cleartext................clear restriction text (p. 161).
displayname .........set display name (p. 189).
makecoint.............make group of cointegrating relations (p. 243).
makeendog ...........make group of endogenous series (p. 244).
makemodel ...........make model from the estimated var (p. 250).
makeresid .............make residual series (p. 251).
makesystem ..........make system from var (p. 257).
svar ......................estimate structural factorization (p. 341).
50Chapter
50 3. Object, View and Procedure Reference
Var Examples
To declare a var estimate a VEC specification and make a residual series:
var finec.ec(e,2) 1 6 cp div r
finec.makeresids
To estimate an ordinary var, to create series containing residuals, and to form a model
based upon the estimated var:
var empvar.ls 1 4 payroll hhold gdp
empvar.makeresids payres hholdres gdpres
empvar.makemodel(inmdl) cp fcp div fdiv r fr
Vector
Vector. (One dimensional array of numbers).
There are several ways to create a vector object. Enter the vector keyword (with an
optional dimension) followed by a name:
vector scalarmat
vector(10) results
Alternatively, you may declare a vector using an assignment statement. The vector will be
sized and initialized, accordingly:
vector(10) myvec=3.14159
vector results=vec1
Vector Views
bar .......................bar graph of data against the row index (p. 149).
label .....................label information for the vector object (p. 231).
line.......................line graph of the data against the row index (p. 234).
52Chapter
52 3. Object, View and Procedure Reference
Vector Procs
displayname......... set display name (p. 189).
fill ....................... fill elements of the vector (p. 203).
read ..................... import data from disk (p. 283).
write.................... export data to disk (p. 367).
Vector Examples
To declare a vector and to fill it with data read in from an Excel file:
vector(10) mydata
mydata.read(b2) thedata.xls
scalar result1=mydata(2)
EViews provides you with tools for working directly with data contained in matrices and
vectors. You can use the EViews matrix language to perform calculations that are not avail-
able using the built-in views and procedures.
The following objects can be created and manipulated using the matrix command lan-
guage:
coef: column vector of coefficients to be used by equation, system, pool, logl, and
sspace objects
scalar: scalar
We term these objects matrix objects (despite the fact that some of these objects are not
matrices).
Declaring Matrices
You must declare matrix objects prior to use. Detailed descriptions of declaration state-
ments for the various matrix objects are provided in Chapter 8, Command Reference,
beginning on page 133.
Briefly, a declaration consists of the object keyword, followed either by size information in
parentheses and the name to be given to the object, followed (optionally) by an assign-
ment statement. If no assignment is provided, the object will be initialized to have all zero
values.
The various matrix objects require different sizing information. A matrix requires the num-
ber of rows and the number of columns. A sym requires that you specify a single number
representing both the number of rows and the number of columns. A vector, rowvector, or
coef declaration can include information about the number of elements. A scalar requires
no size information. If size information is not provided, EViews will assume that there is
only one element in the object.
For example:
matrix(3,10) xdata
54Chapter
54 4. Matrix Language
sym(9) moments
vector(11) betas
rowvector(5) xob
To change the size of a matrix object, you can repeat the declaration statement. Further-
more, if you use an assignment statement with an existing matrix object, the target will be
resized as necessary. For example:
sym(10) bigz
matrix zdata
matrix(10,2) zdata
zdata = bigz
will first declare ZDATA to be a matrix with a single element, and then redeclare ZDATA to
be a 10 ´ 2 matrix. The assignment statement in the last line will resize ZDATA so that it
contains the contents of the 10 ´ 10 symmetric matrix BIGZ.
Element assignment
The most basic method of assigning matrix values is to assign a value for a specific row
and column element of the matrix. Simply enter the matrix name, followed by the row and
column indices, in parentheses, and then an assignment to a scalar value.
matrix(2,2) a
The first command creates and initializes the 2 ´ 2 matrix A so that it contains all zeros.
Then after entering the two commands:
a(1,1) = 1
a(2,1) = 4
we have
A = 1 0 . (4.1)
4 0
Assigning Matrix Values55
55
You can perform a large number of element assignments by placing them inside of pro-
gramming loops:
vector(10) y
matrix (10,10) x
for !i = 1 to 10
y(!i) = !i
for !j = 1 to 10
x(!i,!j) = !i + !j
next
next
Note that the fill procedure provides an alternative to using loops for assignment.
Fill assignment
The second assignment method is to use the fill procedure to assign a list of numbers to
each element of the matrix in the specified order. By default, the procedure fills the matrix
column by column, but you may override this behavior.
You should enter the name of the matrix object, followed by a period, the fill keyword,
and then a comma delimited list of values. For example, the commands:
vector(3) v
v1.fill 0.1, 0.2, 0.3
matrix(2,4) x
matrix.fill 1, 2, 3, 4, 5, 6, 7, 8
0.1
V = 0.2 , X = 1 3 5 7 (4.2)
2 4 6 8
0.3
matrix.fill(b=r) 1,2,3,4,5,6,7,8
then X is given by
X = 1 2 3 4 . (4.3)
5 6 7 8
56Chapter
56 4. Matrix Language
In some situations, you may wish to repeat the assignment over a list of values. You may
use the l option to fill the matrix by repeatedly looping through the listed numbers until
the matrix elements are exhausted. Thus,
matrix(3,3) y
y.fill(l) 1, 0, -1
1 1 1
Y = 0 0 0 (4.4)
−1 −1 −1
See fill (p. 203) for a complete description of the fill procedure.
Matrix assignment
You can copy data from one matrix object into another using assignment statements. To
perform an assignment, you should enter the name of the target matrix followed by the
equal sign =, and then a matrix object expression. The expression on the right-hand
side should either be a numerical constant, a matrix object, or an expression that returns a
matrix object.
There are a variety of rules for how EViews performs the assignment that depend upon the
types of objects involved in the assignment.
Examples:
matrix(5,8) first
scalar second
vec(10) third
first = 5
second = c(2)
third = first(3,5)
Since declaration statements allow for initialization, you can combine the declaration and
assignment statements. Examples:
matrix(5,8) first = 5
scalar second = c(2)
vec(10) third = first(3,5)
Copying Data Between Objects57
57
declares that ZDATA is a 10 ´ 2 matrix filled with 5s. YDATA is automatically resized to be
a 10 ´ 2 matrix and is filled with the contents of ZDATA.
Note that even though the declaration of XDATA calls for a 10 ´ 10 matrix, XDATA is a
10 ´ 2 matrix of 5s. This behavior occurs because the declaration statement above is
equivalent to issuing the two commands,
matrix(10,10) xdata
xdata = ydata
which will first declare the 10 ´ 10 matrix XDATA, and then automatically resize it to
10 ´ 2 when you fill it with the values for YDATA.
The next section discusses assignment statements in the more general case, where you are
converting between object types. In some cases, the conversion is automatic; in other
cases, EViews provides you with additional tools to perform the conversion.
At times, you may wish to move data between different types of matrix objects. For exam-
ple, you may wish to take the data from a vector and put it in a matrix. EViews has a num-
ber of built-in rules which make these conversions automatically.
At other times, you may wish to move data between a matrix object and an EViews series
or group object. There are a separate set of tools which allow you to convert data across a
variety of object types.
The basic rules governing expressions of the form Y=X may be summarized as follows:
58Chapter
58 4. Matrix Language
The target object Y will, if possible, be resized to match the object X; otherwise,
EViews will issue an error. Thus, assigning a vector to a matrix will resize the
matrix, but assigning a matrix to a vector will generate an error if the matrix has
more than one column.
If X is a scalar, Y will keep its original size and will be filled with the value of X.
If X and Y are both vector or rowvector objects, Y will be changed to the same type
as X.
Here are some simple examples illustrating the rules for matrix assignment:
vector(3) x
x(1) = 1
x(2) = 2
x(3) = 3
vector y = x
matrix z = x
Y is now a 3 element vector because it has the same dimension and values as X. EViews
automatically resizes the Z Matrix to conform to the dimensions of X so that Z is now a
3 ´ 1 matrix containing the contents of X: Z(1,1)=1, Z(2,1)=2, Z(3,1)=3.
vector(7) y = 2
rowvector(12) z = 3
coef(20) beta
y = z
z = beta
Y will be a rowvector of length 3, containing the original contents of Z, and Z will be a col-
umn vector of length 20 containing the contents of BETA.
There are some cases where EViews will be unable to perform the specified assignment
because the resize operation is not defined. For example, suppose that X is a 2 ´ 2 matrix.
Then the assignment statement
vector(7) y = x
will result in an error. EViews cannot change Y from a vector to a matrix and there is no
way to assign the 4 elements of the matrix X to the vector Y. Other examples of invalid
assignment statements involve assigning matrix objects to scalars or syms to vector
objects.
A comprehensive list of the EViews commands and functions that may be used for matrix
object conversion appears in Utility Functions and Commands on page 74. However, a
few examples will provide you with a sense of the type of operations that may be per-
formed.
Suppose first that you are interested in copying data from a matrix into a vector. The fol-
lowing commands will copy data from M1 and SYM1 into the vectors V1, V2, V3, and V4.
matrix(10, 10) m1
sym(10) sym1
vector v1 = @vec(m1)
vector v2 = @columnextract(m1,3)
vector v3 = @rowextract(m1,4)
vector v4 = @columnextract(sym1,5)
The @vec function creates a 100 element vector, V1, from the columns of M1 stacked one
on top of another. V2 will be a 10 element vector containing the contents of the third col-
60Chapter
60 4. Matrix Language
umn of M1 while V3 will be a 10 element vector containing the fourth row of M1. The
@vec, @rowextract, and @columnextract functions also work with sym objects. V4 is
a 10 element vector containing the fifth column of SYM1.
You can also copy data from one matrix into a smaller matrix using @subextract. For
example:
matrix(20,20) m1=1
matrix m2 = @subextract(m1,5,5,10,7)
matrix m3 = @subextract(m1,5,10)
matrix m4 = m1
Data from a matrix may be copied into another matrix object using the commands col-
place, rowplace, and matplace. Consider the commands:
matrix(100,5) m1 = 0
matrix(100,2) m2 = 1
vector(100) v1 = 3
rowvector(100) v2 = 4
matplace(m1,m2,1,3)
colplace(m1,v1,3)
rowplace(m1,v2,80)
Keep in mind that there are two primary differences between the ordinary series or group
objects and the matrix objects. First, operations involving series and groups use informa-
tion about the current workfile sample, while matrix objects do not. Second, there are
important differences in the handling of missing values (NAs) between the two types of
objects.
Copying Data Between Objects61
61
Direct Assignment
The easiest method to copy data from series or group objects to a matrix object is to use
direct assignment. Place the destination matrix object on the left side of an equal sign, and
place the series or group to be converted on the right.
If you use a series object on the right, EViews will only include the observations from the
current sample to make the vector. If you place a group object on the right, EViews will
create a rectangular matrix, again only using observations from the current sample.
While very convenient, there are two principal limitations of this approach. First, EViews
will only include observations in the current sample when copying the data. Second,
observations containing missing data (NAs) for a series, or for any series in the group, are
not placed in the matrix. Thus, if the current sample contains 20 observations but the
series or group contains missing data, the dimension of the vector or matrix will be less
than 20. Below, we provide you with methods which allow you to override the current
sample and to retain missing values.
Examples:
smpl 1963:3 1993:6
fetch hsf gmpyq
group mygrp hsf gmpyq
vector xvec = gmpyq
matrix xmat = mygrp
These statements create the vector XVEC and the two column matrix XMAT containing the
non-missing series and group data from 1963:3 to 1993:6. Note that if GMPYQ has a miss-
ing value in 1970:01, and HSF contains a missing value in 1980:01, both observations for
both series will be excluded from XMAT.
When performing matrix assignment, you may refer to an element of a series, just as you
would refer to an element of a vector, by placing an index value in parentheses after the
name. An index value i refers to the i-th element of the series from the beginning of the
workfile range. For example, if the range of the current annual workfile is 1961 to 1980, the
expression GNP(6) refers to the 1966 value of GNP. These series element expressions may
be used in assigning specific series values to matrix elements, or to assign matrix values to
a specific series element. For example:
matrix(5,10) x
series yser = nrnd
x(1,1) = yser(4)
yser(5) = x(2,3)
yser(6) = 4000.2
62Chapter
62 4. Matrix Language
assigns the fourth value of the series YSER to X(1,1), and assigns to the fifth and sixth val-
ues of YSER, the X(2,3) value and the scalar value 4000.2, respectively.
While matrix assignments allow you to refer to elements of series as though they were ele-
ments of vectors, you cannot generally use series in place of vectors. Most vector and
matrix operations will error if you use a series in place of a vector. For example, you cannot
perform a rowplace command using a series name.
Furthermore, note that when you are not performing matrix assignment, a series name fol-
lowed by a number in parentheses will indicate that the lag/lead operator be applied to the
entire series. Thus, when used in generating series or in an equation, system, or model
specification, GNP(6) refers to the sixth lead of the GNP series. To refer to specific ele-
ments of the GNP series in these settings, you should use the @elem function.
X is a 30 ´ 3 matrix with the first column containing data from INV, the second column
from GDP, and the third column from M1.
As with direct assignment, the @convert function excludes observations for which the
series or any of the series in the group contain missing data. If, in the example above, INV
contains missing observations in 1970 and 1980, V would be a 29 element vector while X
would be a 28 ´ 3 matrix. This will cause errors in subsequent operations that require V
and X to have a common row dimension.
There are two primary advantages of using @convert over direct assignment. First, since
@convert is a function, it may be used in the middle of a matrix expression. Second, an
optional second argument allows you to specify a sample to be used in conversion. For
example,
sample s1.set 1950 1990
matrix x = @convert(grp,s1)
sym y = @inverse(@inner(@convert(grp,s1)))
stom (Series TO Matrix) takes a series or group object and copies its data to a vector or
matrix using either the current workfile sample, or the optionally specified sample. As with
direct assignment, the stom command excludes observations for which the series or any of
the series in the group contain missing data.
Example:
sample smpl_cnvrt.set 1950 1995
smpl 1961 1990
group group1 gnp gdp money
vector(46) vec1
matrix(3,30) mat1
stom(gdp,vec1,smpl_cnvrt)
stom(group1,mat1)
While the operation of stom is similar to @convert, stom is a command and cannot be
included in a matrix expression. Furthermore, unlike @convert, the destination matrix or
vector must already exist and have the proper dimension.
stomna (Series TO Matrix with NAs) works identically to stom, but does not exclude
observations for which there are missing values. The elements of the series for the relevant
sample will map directly into the target vector or matrix. Thus,
smpl 1951 2000
vector(50) gvector
stom(gdp,gvector)
will always create a 50 element vector GVECTOR that contains the values of GDP from
1951 to 2000, including observations with NAs.
mtos (Matrix TO Series) takes a matrix or vector and copies its data into an existing series
or group, using the current workfile sample or a sample that you provide.
Examples:
mtos(mat1,group1)
mtos(vec1,resid)
mtos(mat2,group1,smpl1)
As with stom the destination series or group must already exist and the destination dimen-
sion given by the sample must match that of the source vector or matrix.
64Chapter
64 4. Matrix Language
Matrix Expressions
A matrix expression is an expression which combines matrix objects using mathematical
operators or relations, functions, and parentheses. While we discuss matrix functions in
great detail below, some examples will demonstrate the relevant issues.
Examples:
@inner(@convert(grp,s1))
mat1*vec1
@inverse(mat1+mat2)*vec1
mat1 > mat2
EViews uses the following rules to determine the order in which the expression will be
evaluated:
You may nest any number of pairs of parentheses to clarify the order of operations in
a matrix expression.
If you do not use parentheses, the operations are applied in the following order:
1. Unary negation operator and functions
2. Multiplication and division operators
3. Addition and subtraction operators
4. Comparison operators: >=, >, <=, <, <>
Examples:
@inverse(mat1+mat2)+@inverse(mat3+mat4)
vec1*@inverse(mat1+mat2)*@transpose(vec1)
In the first example, the matrices MAT1 and MAT2 will be added and then inverted. Simi-
larly the matrices MAT3 and MAT4 are added and then inverted. Finally, the two inverses
will be added together. In the second example, EViews first inverts MAT1+MAT2 and uses
the result to calculate a quadratic form with VEC1.
Matrix Operators
EViews provides standard mathematical operators for matrix objects.
Negation ()
The unary minus changes the sign of every element of a matrix object, yielding a matrix or
vector of the same dimension. Example:
Matrix Expressions65
65
Addition (+)
You can add two matrix objects of the same type and size. The result is a matrix object of
the same type and size. Example:
matrix(3,4) a
matrix(3,4) b
matrix sum = a + b
You can add a square matrix and a sym of the same dimension. The upper triangle of the
sym is taken to be equal to the lower triangle. Adding a scalar to a matrix object adds the
scalar value to each element of the matrix or vector object.
Subtraction ()
The rules for subtraction are the same as the rules for addition. Example:
matrix(3,4) a
matrix(3,4) b
matrix dif = a - b
Subtracting a scalar object from a matrix object subtracts the scalar value from every ele-
ment of the matrix object.
Multiplication (*)
You can multiply two matrix objects if the number of columns of the first matrix is equal to
the number of rows of the second matrix.
Example:
matrix(5,9) a
matrix(9,22) b
matrix prod = a * b
One or both of the matrix objects can be a sym. Note that the product of two sym objects
is a matrix, not a sym. The @inner function will produce a sym by multiplying a matrix
by its own transpose.
You can premultiply a matrix or a sym by a vector if the number of columns of the matrix
is the same as the number of elements of the vector. The result is a vector whose dimen-
sion is equal to the number of rows of the matrix.
Example:
66Chapter
66 4. Matrix Language
matrix(5,9) mat
vector(9) vec
vector res = mat * vec
You can premultiply a rowvector by a matrix or a sym if the number of elements of the
rowvector is the same as the number of rows of the matrix. The result is a rowvector
whose dimension is equal to the number of columns of the matrix.
Example:
rowvector rres
matrix(5,9) mat
rowvector(5) row
rres = row * mat
You can multiply a matrix object by a scalar. Each element of the original matrix is multi-
plied by the scalar. The result is a matrix object of the same type and dimensions as the
original matrix. The scalar can come before or after the matrix object. Examples:
matrix prod = 3.14159*orig
matrix xxx = d_mat*7
Division (/)
You can divide a matrix object by a scalar. Example:
matrix z = orig/3
Example:
if result <> value then
run crect
endif
Matrix Commands and Functions67
67
It is possible for a vector to be not greater than, not less than, and not equal to a second
vector. For example:
vector(2) v1
vector(2) v2
v1(1) = 1
v1(2) = 2
v2(1) = 2
v2(2) = 1
Since the first element of V1 is smaller than the first element of V2, V1 is not greater than
V2. Since the second element of V1 is larger than the second element of V2, V1 is not less
than V2. The two vectors are not equal.
4. Element Functions
The utility commands and functions provide support for creating, manipulating, and
assigning values to your matrix objects. We have already seen the @convert function and
the stom command, both of which convert data from series and groups into vectors and
matrices.
The matrix algebra functions allow you to perform common matrix algebra manipulations
and computations. Among other things, you can use these routines to compute eigenval-
ues, eigenvectors and determinants of matrices, to invert matrices, to solve linear systems
of equations, and to perform singular value decompositions.
The descriptive statistics functions compute summary statistics for the data in the matrix
object. You can compute statistics such as the mean, median, minimum, maximum, and
variance, over all of the elements in your matrix.
The matrix element functions allow you create a new matrix containing the values of a
function evaluated at each element of another matrix object. Most of the functions that are
available in series expressions may be applied to matrix objects. You can compute the log-
68Chapter
68 4. Matrix Language
arithm of every element of a matrix, or the cumulative normal distribution at every ele-
ment of a vector.
A listing of the commands and functions is included in the matrix summary on page 74.
Functions for computing descriptive statistics for data in matrices are discussed in
Descriptive Statistics on page 421. Additional details on matrix element computations
are provided in Matrix Operators on page 64.
There are two basic ways that you can use a function. First, you may assign the result to an
EViews object. This object may then be used in other EViews expressions, providing you
access to the result in subsequent calculations. For example,
matrix y = @transpose(x)
stores the transpose of matrix X in the matrix Y. Since Y is a standard EViews matrix, it
may be used in all of the usual expressions.
Second, you may use a function as part of a matrix expression. Since the function result is
used in-line, it will not be assigned to a named object, and will not be available for further
use. For example, the command
scalar z = vec1*@inverse(v1+v2)*@transpose(vec1)
uses the results of the @inverse and @transpose functions in forming the scalar expres-
sion assigned to Z. These function results will not be available for subsequent computa-
tions.
By contrast, a command takes object names and expressions as arguments, and operates
on the named objects. Commands do not return a value.
Commands, which do not have a leading @ character, must be issued alone on a line,
rather than as part of a matrix expression. For example, to convert a series X to a vector
V1, you would enter
stom(x,v1)
Because the command does not return any values, it may not be used in a matrix expres-
sion.
Matrix Views and Procs69
69
NA Handling
As noted above, most of the methods of moving data from series and groups into matrix
objects will automatically drop observations containing missing values. It is still possible,
however, to encounter matrices which contain missing values.
For example, the automatic NA removal may be overridden using the stomna command
(p. 336). Additionally, some of the element operators may generate missing values as a
result of standard matrix operations. For example, taking element-by-element logarithms of
a matrix using @log will generate NAs for all cells containing nonpositive values.
EViews follows two simple rules for handling matrices that contain NAs. For all operators,
commands, and functions, except the descriptive statistics function, EViews works with the
full matrix object, processing NAs as required. For descriptive statistic functions, EViews
automatically drops NAs when performing the calculation. These rules imply the follow-
ing:
Matrix operators will generate NAs where appropriate. Adding together two matrices
that contain NAs will yield a matrix containing NAs in the corresponding cells. Mul-
tiplying two matrices will result in a matrix containing NAs in the appropriate rows
and columns.
All matrix algebra functions and commands will generate NAs, since these opera-
tions are undefined. For example, the Cholesky factorization of a matrix that con-
tains NAs will contain NAs.
All utility functions and commands will work as before, with NAs treated like any
other value. Copying the contents of a vector into a matrix using colplace will
place the contents, including NAs, into the target matrix.
All of the matrix element functions will propagate NAs when appropriate. Taking the
absolute value of a matrix will yield a matrix containing absolute values for non-
missing cells and NAs for cells that contain NAs.
The descriptive statistics functions are based upon the non-missing subset of the ele-
ments in the matrix. You can always find out how many values were used in the
computations by using the @OBS function.
each column will be plotted against the row number of the matrix.
Additionally, you can compute descriptive statistics for each column of a matrix, as well as
the correlation and covariance matrix between the columns of the matrix:
z.stats
z.cor
z.cov
EViews performs listwise deletion by column, so that each group of column statistics is
computed using the largest possible set of observations.
The full syntax for the commands to display and print these views is listed in the object
reference.
You must supply the name of the source file. If you do not include the optional path speci-
fication, EViews will look for the file in the default directory. The input specification fol-
lows the source file name. Path specifications may point to local or network drives. If the
path specification contains a space, you must enclose the entire expression in double
quotes .
In reading from a file, EViews first fills the matrix with NAs, places the first data element in
the (1,1) element of the matrix, then continues to read the data by row or by column,
depending upon the options set.
The following command reads data into MAT1 from an Excel file CPS88 in the network
drive specified in the path directory. The data are read by column, and the upper left data
cell is A2.
To read the same file by row, you should use the t option:
Matrix Operations versus Loop Operations71
71
To write data from a matrix, use the write keyword, enter the desired options, then the
name of the output file. For example:
mat1.write mydt.txt
writes the data in MAT1 into the ASCII file MYDT.TXT located in the default directory.
There are many more options for controlling reading and writing of data; Chapter 4 of the
Users Guide provides extensive discussion. See also read (p. 283) and write (p. 367).
however, this approach will generally be much slower than using the built-in function:
You should use the built-in matrix operators rather than loop operators whenever you can.
The matrix operators are always much faster than the equivalent loop operations.
There will be cases when you cannot avoid using loop operations. For example, suppose
you wish to subtract the column mean from each element of a matrix. Such a calculation
might be useful in constructing a fixed effects regression estimator. First, consider a slow
method involving only loops and element operations:
matrix(2000,10) x = @convert(mygrp1)
scalar xsum
for !i = 1 to @columns(x)
xsum = 0
for !j = 1 to @rows(x)
xsum = xsum+x(!j,!i)
next
xsum = xsum/@rows(x)
for !j = 1 to @rows(x)
72Chapter
72 4. Matrix Language
x(!j,!i) = x(!j,!i)-xsum
next
next
The loops are used to compute a mean for each column of data in X, and then to subtract
the value of the mean from each element of the column. A better and much faster method
for subtracting column means uses the built-in operators:
matrix x = @convert(mygrp1)
vector(@rows(x)) xmean
for !i = 1 to @columns(x)
xmean = @mean(@columnextract(x,!i))
colplace(x,@columnextract(x,!i)-xmean,!i)
next
This command extracts each column of X, computes the mean, and fills the vector XMEAN
with the column mean. You then subtract the mean from the column and place the result
back into the appropriate column of X. While you still need to loop over the control vari-
able !i, you avoid the need to loop over the elements of the columns.
The following table summarizes the rules for resizing of matrix objects as a result of decla-
rations of the form
object_type y = x
Each row of the table corresponds to the specified type of the destination object, Y. Each
column represents the type and size of the source object, X. Each cell of the table shows
the type and size of object that results from the declaration or assignment.
Summary of Automatic Resizing of Matrix Objects73
73
matrix(500,4) y = x
where X is a coef of size 50. The object type is given by examining the table entry corre-
sponding to row matrix Y (n = 500, k = 4), and column coef X (p = 50). The entry
reads matrix(p, 1), so that the result Y is a 50 ´ 1 matrix.
The remaining descriptive statistics functions that may be used with matrices and vectors
are described in Descriptive Statistics on page 421.
You can use EViews commands to generate custom tables of formatted output from your
programs. A table is an object made up of rows and columns of cells, each of which can
contain either a number or a string, as well as information used to control formatting for
display or printing. The columns of a table can be set to different widths, and horizontal
lines can be added to visually separate sections of the table.
After you have filled up all of the cells of a table, you can print the table object using the
print command or by pressing the Print button on the table toolbar.
Chapter 10, Graphs, Tables, and Text Objects, on page 235 of the Users Guide describes
table objects in detail.
Declaring a Table
To declare a table, indicate the number of rows and columns and provide a valid name. For
example,
table(10,20) bestres
creates a table with 10 rows and 20 columns named BESTRES. You can change the size of
a table by declaring it again. Redeclaring to a larger size does not destroy the contents of
the table; any cells in the new table that existed in the original table will contain their pre-
vious values.
Tables are automatically resized when you attempt to fill a table cell outside the tables
current dimensions. This behavior is different from matrices which give an error when an
out of range element is accessed.
Controlling Appearance
By default, each cell of a table will display approximately 10 characters. If a string is longer
than the display width of the cell, part of the string may not be visible.
You can change the width of a column in a table using the setcolwidth command. Fol-
low the setcolwidth keyword by the name of the table, the number of the column you
wish to resize, and the approximate number of characters, all enclosed in parentheses.
EViews measures units in terms of the width of a numeric character. Different characters
have different widths, so the actual number of characters displayed may differ somewhat
from the number which you specify. For example,
78Chapter
78 5. Working with Tables
setcolwidth(bestres,2,12)
resizes the second column of table BESTRES to fit strings approximately 12 characters
long.
You may also place horizontal separator (double) lines in the table using the setline
command. Enter the setline keyword, followed by the name of the table, and the row
number, all in parentheses. For example,
setline(bestres,8)
Filling Cells
You can put a value into a cell of a table using an assignment statement. Each cell of the
table can be assigned either a string or a numeric value.
Strings
To place a string value into a table cell, follow the table name by a row and column pair in
parentheses, then an equal sign and a string expression:
bestres(1,6) = "convergence criterion"
%strvar = "lm test"
bestres(2,6) = %strvar
bestres(2,6) = bestres(2,6) + " with 5 df"
Numbers
Numbers can be entered directly into cells, or they can be converted to strings before being
placed in the table. If entered directly, the number will be displayed according to the
numerical format set for that cell; if the format is changed, the number will be redisplayed
according to the new format. If the number is first converted to a string, the number will
be frozen in that form and cannot be reformatted.
By default, the number will be displayed with as many digits as will fit in the cell, with sci-
entific notation used if necessary. If, instead, you use the @str function to first convert the
number into a string, the string will contain the fewest decimal places required to repre-
sent the number. The following are some examples of cell assignments involving numbers:
tab1(3,4) = 15
tab1(4,2) = "R-squared = " + @str(eq1.@r2)
!ev = 10
tab1(5,1) = "There are " + @str(!ev) + " events"
Filling Cells79
79
Cell Formatting
The setcell command is similar to cell assignment in that it allows you to set the con-
tents of a cell. However, the setcell command also allows you to set formatting options
for the cell. This is the only way to adjust formatting of a cell from the command line or
within a program. The setcell command takes the following arguments:
The numerical format code determines the format with which a number in a cell is dis-
played; cells containing strings will be unaffected. The format code can either be a positive
integer, in which case it specifies the number of digits to be displayed after the decimal
point, or a negative integer, in which case it specifies the total number of characters to be
used to display the number. These two cases correspond to the fixed decimal and fixed
character fields in the number format dialog.
Note that when using a negative format code, one character is always reserved at the start
of a number to indicate its sign, and if the number contains a decimal point, that will also
be counted as a character. The remaining characters will be used to display digits. If the
number is too large or too small to display in the available space, EViews will attempt to
use scientific notation. If there is insufficient space for scientific notation (six characters or
less), the cell will contain asterisks to indicate an error.
setcell(tab1,5,6,!data,4)
puts the number !data into TAB1, with 4 digits to the right of the decimal
point.
setcell(tab1,3,11,!data,"r",3)
puts the number !data into TAB1, right-justified, with 3 digits to the right of
the decimal point.
setcell(tab1,4,2,!data,-7)
puts the number in !data into TAB1, with 7 characters used for display.
Table Example
Here we provide an extended example that shows how to construct a table using a pro-
gram. The program constructs a table that displays the results of unit root tests applied to
each series in a group.
We first write a subroutine that returns a vector of augmented Dickey-Fuller t-statistics for
each series in the given group (subroutine construction is described in the next chapter).
subroutine local muroot(group g1, vector v1)
' get number of series in group
!n = g1.@count
' declare vector to save results
vector(!n) tstat
' do ADF test for each series in group
for !i=1 to !n
%str = g1.@seriesname(!i)
series temp = {%str}
equation eq_temp.ls d(temp) temp(-1) c
tstat(!i) = eq_temp.@tstat(1)
next
' copy results to global vector
v1 = tstat
endsub
Note that we do not assign the results directly into the elements of the vector passed in as
an argument. If we did this, we would need to know the number of series in the group
before the function was called, so that we could correctly size the vector. Instead, we store
the results in a temporary vector and copy this entire vector in a vector assignment at the
end of the routine. This automatically resizes the vector to the required size.
Table Example81
81
The following program constructs a table to display the results of the unit root tests:
include c:\evdata\programs\muroot
load c:\evdata\macro
group grp1 ff tb3 tb10
vector tstat
call muroot(grp1,tstat)
' get number of series in group
scalar n = grp1.@count
' declare table and fill in headers
table(6,n+1) adf
setcell(adf,1,1,"ADF test (no lagged first differences with a
constant)")
setline(adf,2)
setcell(adf,3,1,"series")
setcell(adf,4,1,"t-stat")
setline(adf,5)
setcell(adf,6,1,"5% critical value is -2.86 (Davidson & MacKin-
non, Table 20.1)")
' fill in cells
for !i=1 to n
setcell(adf,3,!i+1,grp1.@seriesname(!i))
setcell(adf,4,!i+1,tstat(!i),3)
next
show adf
The first block (paragraph) of the program loads the workfile, creates a group of series, and
carries out the unit root tests by calling the subroutine given above. The second block
declares the table and fills in the cells that contain header information. The third block
loops through the elements of the group to get the series name and the vector of t-statistics
and places them in the appropriate cells of the table. Note that we display the t-statistics
only up to the third decimal place.
82Chapter
82 5. Working with Tables
Table Summary
The following commands are documented in Chapter 8.
setcell .................. format and fill in a table cell (p. 309).
setcolwidth .......... set width of a table column (p. 310).
setline.................. place a horizontal line in table (p. 316).
Chapter 6. EViews Programming
EViews programming features allow you to create and store commands in programs that
automate repetitive tasks, or generate a record of your research project.
For example, you can write a program with commands that analyze the data from one
industry, and then have the program perform the analysis for a number of other industries.
You can also create a program containing the commands that take you from the creation of
a workfile and reading of raw data, through the calculation of your final results, and con-
struction of presentation graphs and tables.
If you have experience with computer programming, you will find most of the features of
the EViews language to be quite familiar. The main novel feature of the EViews program-
ming language is a macro substitution language which allows you to create object names
by combining variables that contain portions of names.
Program Basics
Creating a Program
A program is not an EViews object within a workfile. It is simply a text file containing
EViews commands. To create a new program, click File/New/Program.
File/New/Program You will see a
standard text editing window where you can type in the lines of the program. You may also
open the program window by typing program in the command window, followed by an
optional program name. For example
program firstprg
opens a program window named FIRSTPRG. Program names should follow standard
EViews rules for file names.
A program consists of a one or more lines of text. Since each line of a program corresponds
to a single EViews command, simply enter the text for each command and terminate the
line by pressing the ENTER key.
If a program line is longer than the current program window, EViews will autowrap the
text of the line. Autowrapping alters the appearance of the program line by displaying it on
multiple lines, but does not change the contents of the line. While resizing the window will
change the autowrap position, the text remains unchanged and is still contained in a single
line.
If you wish to have greater control over the appearance of your lines, you can manually
break long lines using the ENTER key, and then use the underscore continuation character
84Chapter
84 6. EViews Programming
_ as the last character on the line to join the multiple lines. For example, the three sepa-
rate lines
equation eq1.ls _
y x c _
ar(1) ar(2)
are actually joined by the continuation character and are equivalent to the single line
equation eq1.ls y x c ar(1) ar(2)
Saving a Program
After you have created and edited your program, you will probably want to save it. Press
the Save or SaveAs button on the program window toolbar. When saved, the program will
have the extension .PRG.
Opening a Program
To load a program previously saved on disk, click on File/Open/Program...,
File/Open/Program... navigate to
the appropriate directory, change the Files of Type combo box to display Program .PRG
files, and click on the desired name. Alternatively, from the command line, you can type
open followed by the full program name, including the file extension .PRG. By default,
EViews will look for the program in the default directory. If appropriate, include the full
path to the file. The entire name should be enclosed in quotations if necessary. For exam-
ple:
open mysp500.prg
open c:\mywork\eviews\myhouse.prg
Executing a Program
When you enter a series of commands in the command window, line by line, we say that
you are working in interactive mode. Alternatively, you can type all of the commands in a
program and execute or run them collectively as a batch of commands. When you execute
or run the commands from a program, we say that you are in program (non-interactive)
mode.
Program Basics85
85
By default, when EViews encounters an error, it will immediately terminate the program
and display a message. If you enter a number into the Maximum errors before halting
field, EViews will continue to execute the program until the maximum number of errors is
reached. If there is a serious error so that it is impractical for EViews to continue, the pro-
gram will halt even if the maximum number of errors is not reached.
You may also execute a program by entering the run command, followed by the name of
the program file:
run mysp500
or
run c:\eviews\myprog
The use of the .PRG extension is not required since EViews will automatically append one.
All of the run options described above may be set using command options. You may use
the v option to run the program in verbose mode, and the q option to run the program
in quiet mode. If you include a number as an option, EViews will use that number to indi-
cate the maximum number of errors encountered before execution is halted. Any argu-
ments to the program may be listed after the filename:
run(v, 500) mysp500
or
run(q) progarg arg1 arg2 arg3
See Handling Execution Errors on page 103 for discussion of execution errors and Mul-
tiple Program Files on page 104 for additional details on program execution.
86Chapter
86 6. EViews Programming
You can also have EViews run a program automatically upon startup by choosing File/Run
from the menu bar of the Windows Program Manager or Start/Run in Windows and then
typing eviews, followed by the name of the program and the values of any arguments.
Stopping a Program
The F1 key halts execution of a program. It may take a few seconds for EViews to respond
to the halt command.
Programs will also stop when they encounter a stop command, when they read the maxi-
mum number of errors, or when they finish processing a file that has been executed via a
run statement.
If you include the exit keyword in your program, the EViews application will close.
Simple Programs
The simplest program is just a list of commands. Execution of the program is equivalent to
typing the commands one by one into the command window.
While you could execute the commands by typing them in the command window, you
could just as easily open a program window, type in the commands and click on the Run
button. Entering commands in this way has the advantage that you can save the set of
commands for later use, and execute the program repeatedly, making minor modifications
each time.
Let us look at a simple example (the data series are provided in the database PROGDEMO
in your EViews directory so that you can try out the program). Create a new program by
typing
program myprog
in the command window. In the program window that opens for MYPROG, we are going to
enter the commands to create a workfile, fetch a series from an EViews database named
PROGDEMO, run a regression, compute residuals and a forecast, make a plot of the fore-
cast, and save the results.
' housing analysis
workfile myhouse m 1968:3 1997:6
fetch progdemo::hsf
smpl 1968:5 1992:12
equation reg1.ls hsf c hsf(-1)
reg1.makeresid hsfres
smpl 1993:1 1997:6
reg1.forecast hsffit
Program Variables87
87
freeze(hsfplot) hsffit.line
save
The first line of the program is a comment, as denoted by the apostrophe '. In executing
a program, EViews will ignore all text following the apostrophe until the end of the line.
HSF is total housing units started. We end up with a saved workfile named MYHOUSE con-
taining the HSF series, an equation object REG1, a residual and forecast series, HSFRES
and HSFFIT, and a graph HSFPLOT of the forecasts.
You can run this program by clicking on Run and filling in the dialog box.
Now, suppose you wish to perform the same analysis, but for the S&P 500 stock price
index (FSPCOM). Edit the program, changing MYHOUSE to MYSP500, and change all of
the references of HSF to FSPCOM:
' s&p analysis
workfile mysp500 m 1968:3 1997:6
fetch progdemo::fspcom
smpl 1968:5 1992:12
equation reg1.ls fspcom c fspcom(-1)
reg1.makeresid fspcomres
smpl 1993:1 1997:6
reg1.forecast fspcomfit
freeze(fscomplot) fspcomfit.line
save
Click on Run to execute the new analysis. Click on the Save button to save your program
file as MYPROG.PRG in the EViews directory.
Since most of these two programs are identical, it seems like a lot of typing to make two
separate programs. Below we will show you a way to handle these two forecasting prob-
lems with a single program.
Program Variables
While you can use programs just to edit, run, and re-run collections of EViews commands,
the real power of the programming language comes from the use of program variables and
program control statements.
88Chapter
88 6. EViews Programming
Control Variables
Control variables are variables that you can use in place of numerical values in your
EViews programs. Once a control variable is assigned a value, you can use it anywhere in a
program that you would normally use a number.
The name of a control variable starts with an ! mark. After the !, the name should be
a legal EViews name of 15 characters or fewer. Examples of control variable names are:
!x
!1
!counter
You need not declare control variables before your refer to them, though you must assign
them a value before use. Control variables are assigned in the usual way, with the control
variable name on the left of an = sign and a numerical value or expression on the right.
For example,
!x=7
!12345=0
!counter= 12
!pi=3.14159
Once assigned a value, a control variable may appear in an expression. For example,
!counter = !counter + 1
genr dnorm = 1/sqr(2*!pi)*exp(-1/2*epsilon^2)
scalar stdx = x/sqr(!varx)
smpl 1950:1+!i 1960:4+!i
Control variables do not exist outside of your program and are automatically erased after a
program finishes. As a result, control variables are not saved when you save the workfile.
You can save the values of control variables by creating new EViews objects which contain
the values of the control variable. For example,
scalar stdx = sqr(!varx)
c(100) = !length
sample years 1960+!z 1990
String Variables
A string is text enclosed in double quotes:
"gross domestic product"
"3.14159"
"ar(1) ar(2) ma(1) ma(2)"
Program Variables89
89
A string variable is a variable whose value is a string of text. The name of a string variable
starts with a % symbol. String variables are assigned by putting the string variable name
on the left of an = sign and a string expression on the right. For example,
%value="value in millions of u.s. dollars"
%armas="ar(1) ar(2) ma(1) ma(2)"
%mysample=" 83:1 96:12"
%dep=" hs"
%pi=" 3.14159"
Once assigned a value, a string variable may appear in an expression. You can use strings
to help you build up commands and variable names or as headings in tables. For example,
gnp.label %value
smpl %mysample
equation eq1.ls %dep c %dep(-1)
equation eq2.ls %dep c %dep(-1) %armas
EViews has a number of operators and functions for manipulating strings; a complete list
is provided in Manipulating Strings on page 90. Here is a quick example:
!repeat = 500
%st1 = " draws from the normal"
%st2 = "Cauchy "
%st3 = @str(!repeat) +@left(%st1,16)+ %st2 +"distribution"
In this example %ST3 is set to the value 500 draws from the Cauchy distribution. Note
the spaces before draws and after Cauchy in the double quotes.
String variables are like control variables in that they only exist during the time that your
program is executing and are not stored in the workfile. You can save string data in a cell of
a table, as described later in this chapter.
You can convert a string variable containing a number into a number by using the @val
function. For example,
%str = ".05"
!level = @val(%str)
creates a control variable !LEVEL=0.05. If the first character of the string is not a numeric
character (and is not a plus or a minus sign), @val returns the value NA. Any characters
to the right of the first non-digit character are ignored. For example,
%date = "04/23/97"
scalar day=@val(@right(%date,5))
90Chapter
90 6. EViews Programming
scalar month=@val(%date)
Manipulating Strings
Strings and string variables may be concatenated using the + operator. For example,
%st1 = "The name "
%st2 = "X"
%st3 = %st1 + "is " + %st2
would leave the string The name is X in the string variable %ST3.
@left: returns a string containing the specified number of characters at the left end
of a string. If there are fewer characters than the number specified, @left will
return the entire string. Put the string and the number of characters in parentheses.
@left("I did not do it",5)
returns the string I did.
@mid: returns the specified number of characters starting from the specified location
in the string and going to the right.
@mid("I doubt I did it",9,5)
returns the string I did.
If you omit the number of characters from @mid, or if there are fewer remaining
characters than the number specified, the function will return all of the characters to
the right of the specified location.
@mid("I doubt I did it",9)
returns the string I did it.
@right: returns a string containing the specified number of characters at the right
end of a string. If there are fewer characters than the number specified, @right will
return the entire string. Put the string and the number of characters in parentheses.
@right("I doubt I did it",8)
returns the string I did it.
@otod: (Obs TO Date) returns a string representing the date associated with the
observation at the given offset from the start of the workfile range. The first observa-
tion of the workfile has an offset of 1.
create q 50:1 90:4
!x = 16
%date = @otod(!x)
returns the string %DATE=1953:4.
@dtoo: (Date TO Obs) returns the scalar offset from the beginning of the workfile
associated with the observation given by the date string. The string must be a valid
EViews date.
create d 2/1/90 12/31/95
%date = "1/1/93"
!t = @dtoo(%date)
returns the value !T=762.
Combining the string functions listed above and the + operator allows you to build up
strings with different meanings. To repeat the example used before,
!repeat = 500
%st1 = " draws from the normal"
%st2 = "Cauchy "
%st3 = @str(!repeat) +@left(%st1,16)+ %st2 +"distribution"
In this example %ST3 is set to 500 draws from the Cauchy distribution.
Replacement Variables
EViews allows you to construct command lines using the contents of string and control
variables. For example if the string variable %X contains the string GDP:
92Chapter
92 6. EViews Programming
%x = "gdp"
ls %x c %x(-1)
ls gdp c gdp(-1)
Replacement variables may be combined with letter and digits or with other replacement
variables to form longer words. When you do this, you should use curly braces { and
} to delimit the replacement variables. For example,
%type = "Low"
%vname = " Income"
series inc1
inc1.label {%type}{%vname}
%type = "High"
series inc2
inc2.label {%type}{%vname}
will label the series INC1 as Low Income and series INC2 as High Income. In these
cases, the term {%type}{%vname} is a replacement variable since the command is con-
structed by replacing the string variables with their contents.
and will create two series Y1 and Y01 that contain a set of (pseudo-)random draws from a
standard normal distribution.
Program Variables93
93
declares a series named X3, a 2 ´ 2 matrix named X2, and a vector named X_TEMP1.
Replacement variables give you great flexibility in naming objects in your programs. We do
suggest, however, that you avoid using the same base names to refer to different objects.
Consider the following example which shows the potential for confusion:
' possibly confusing commands (avoid)
!a=1
series x{!a}
!a=2
matrix x{!a}
In this small code snippet it is easy to see that X1 is the series and X2 is the matrix. But in
a more complicated program, where the assignment of!A may be separated from the series
declaration by many program lines, it may be difficult to tell at a glance what x{!a} repre-
sents. A better approach would be to use different names for different kinds of variables:
!a=1
series ser{!a}
!a=2
matrix mat{!a}
EViews functions perform type checking so that you need to use braces when you call a
function with a replacement variable. Functions that take string arguments only allow
strings to be passed in and functions that take series arguments only accept series. To pass
a series into a series function via a replacement variable, you must enclose the replace-
ment variable in braces so that EViews knows to use the object referenced by the string,
rather than the string itself. For example, when trying to find the number of valid observa-
tions in a series named INCOME, you can use the @obs function
@obs(income)
If you wish to use the string variable %VAR to refer to the INCOME series, the proper syn-
tax is
%var = "income"
94Chapter
94 6. EViews Programming
@obs({%var})
The function @obs(%var) will return an error since the @obs function requires a series,
not a string as an argument.
When you pass series names to subroutines via replacement variables, you also need to
use braces. See Subroutine with arguments on page 106.
Program Arguments
Program arguments are special string variables that are passed to your program when you
run the program. Arguments allow you to change the value of string variables every time
you run the program. You may use them in any context where a string variable is appropri-
ate. Any number of arguments may be included in a program; they will be named %0,
%1, %2, and so on.
When you run a program that takes arguments, you will also supply the values for the
arguments. If you use the Run button or File/Run,
File/Run you will see a dialog box where you
can type in the values of the arguments. If you use the run command, you should list the
arguments consecutively after the name of the program.
To run REGPROG from the command line with %0="lgdp" and %1="m1", we enter
This program performs a regression of the variable LGDP, on C, M1, M1(-1), and TIME, by
executing the command
eq1.ls lgdp c m1 m1(-1) time
Alternatively, you can run this program by clicking on the Run button on the program win-
dow, or selecting File/Run....
File/Run... In the Run Program dialog box that appears, type the name
of the program in the Program name or path field and enter the values of the arguments in
the Program arguments field. For this example, type regprog for the name of the pro-
gram, and lgdp and m1 for the arguments.
Any arguments in your program that are not initialized in the run command or Run Pro-
gram dialog are treated as blanks. For example, suppose you have a one-line program
named REGRESS:
Control of Execution95
95
ls y c time %0 %1 %2 %3 %4 %5 %6 %7 %8
The command
executes
executes
ls y c time
In both cases, EViews ignores arguments that are not included in your run command.
As a last example, we repeat our simple forecasting program from above, but use argu-
ments to simplify our work. Suppose you have the program, MYPROG:
workfile %0 m 1968:3 1997:6
fetch progdemo::%1
smpl 1968:5 1992:12
equation reg1.ls %1 c %1(-1)
reg1.makeresid {%1}res
smpl 93:1 1997:6
reg1.forecast {%1}fit
freeze({%1}plot) {%1}fit.line
save
The results of running the two example programs at the start of this chapter can be dupli-
cated by running MYPROG with arguments:
run myprog myhouse hsf
and
run myprog mysp500 fspcom
Control of Execution
EViews provides you with several ways to control the execution of commands in your pro-
grams. Controlling execution in your program means that you can execute commands
selectively or repeat commands under changing conditions. The methods for controlling
execution will be familiar from other computer languages.
96Chapter
96 6. EViews Programming
IF Statements
There are many situations where you want to execute commands only if some condition is
satisfied. EViews uses IF/ENDIF statements to indicate the condition to be met and the
commands to be executed.
An IF statement starts with the if keyword, followed by an expression for the condition,
and then the word then. You may use AND/OR statements in the condition, using paren-
theses to group parts of the statement as necessary.
If the expression is true, all of the commands until the matching endif are executed. If the
expression is false, all of these commands are skipped. The expression may also take a
numerical value. In this case, zero is equivalent to false and any non-zero value is consid-
ered to be true. For example:
if !stand=1 or (!rescale=1 and !redo=1) then
series gnpstd = gnp/sqr(gvar)
series constd = cons/sqr(cvar)
endif
if !a>5 and !a<10 then
smpl 1950:1 1970:1+!a
endif
if !scale then
series newage = age/!scale
endif
Note that all indentation is done for program clarity and has no effect on the execution of
the program lines.
An IF statement can have an ELSE clause containing commands to be executed if the con-
dition is false. If the condition is true, all of the commands up to the keyword else will be
executed. If the condition is false, all of the commands between else and endif will be
executed. For example,
if !scale>0 then
series newage = age/!scale
else
series newage = age
endif
series stateid = 1
else
if %0="ma" then
series stateid=2
else
if %0="id" then
series stateid=3
endif
endif
endif
All string comparisons are case-insensitive. String comparisons are lexicographic and fol-
low the ASCII ordering rules. Strings are considered equal if they are the same length and
every character matches. One string is less than another if the corresponding characters
come earlier in the alphabet. A string is greater than another if the corresponding charac-
ters come later in the alphabet, or if there is no corresponding character. For example, sup-
pose we assign the string values
%1 = "a"
%2 = "b2"
The string A is less than ABC since the first characters of the strings match; the remain-
ing characters "BC" make the string greater. A is greater than any digit since digits come
before letters in the ASCII ordering.
In order to test whether a string contains any characters, test whether it is equal to an
empty string. For example, the statement
if %str<>"" then
will execute the following lines if the string variable %STR is not empty.
To test whether a scalar contains a missing value, compare with NA. For example,
if !a <> na then
Note that inequality comparisons with NA are always evaluated as false in IF statements.
For example,
if 3 > na then
if 3 <= na then
You may have noticed that all of the above examples of IF statements involved scalar or
string variable comparisons. You should take care when using the IF statement with series
or matrices to note that the boolean is defined on the entire object and will evaluate to
false unless every element of the element-wise comparison is true. Thus, if X and Y are
series, the IF statement
if x<>y then
[some program lines]
endif
evaluates to false if any element of X is not equal to the corresponding value of Y in the
default sample. If X and Y are identically sized vectors or matrices, the comparison is over
all of the elements X and Y. The behavior is described in greater detail in Comparison
Operators (=, >, >=, <, <=, <>) on page 66.
The syntax of the FOR statement differs depending upon whether it uses control variables
or string variables.
In this example, STEP=1 and the variable !J is twice used as a replacement variable, first
for the ten series declarations DECILE1 through DECILE10 and for the ten variables
LEVEL1 through LEVEL10.
Control of Execution99
99
In this example, the step is -1, and !J is used as a replacement variable to name the ten
constructed series RESCALE10 through RESCALE1 and as a scalar in dividing the series
ORIGINAL.
The FOR loop is executed first for the initial value, unless that value is already beyond the
terminal value. After it is executed for the initial value, the control variable is incremented
by step and EViews compares the variable to the limit. If the limit is passed, execution
stops.
One important use of FOR loops with control variables is to change the sample. If you add
a control variable to a date in a smpl command, you will get a new date as many observa-
tions forward as the current value of the control variable. Here is a FOR loop that gradually
increases the size of the sample and estimates a rolling regression:
for !horizon=10 to 72
smpl 1970:1 1970:1+!horizon
equation eq{!horizon}.ls sales c orders
next
One other important case where you will use loops with control variables is in accessing
elements of a series or matrix objects. For example,
!rows = @rows(vec1)
vector cumsum1 = vec1
for !i=2 to !rows
cumsum1(!i) = cumsum1(!i-1) + vec1(!i)
next
computes the cumulative sum of the elements in the vector VEC1 and saves it in the vector
CUMSUM1.
To access an individual element of a series, you will need to use the @elem function and
@otod to get the desired element
for !i=2 to !rows
cumsum1(!i) = @elem(ser1, @otod(!i))
next
The @otod function returns the date associated with the observation index (counting from
the beginning of the workfile), and the @elem function extract the series element associ-
ated with a given date.
100Chapter
100 6. EViews Programming
You can nest FOR loops to contain loops within loops. The entire inner FOR loop is exe-
cuted for each successive value of the outer FOR loop. For example,
matrix(25,10) xx
for !i=1 to 25
for !j=1 to 10
xx(!i,!j)=(!i-1)*10+!j
next
next
You should avoid changing the control variable within a FOR loop. For example, consider
' potentially confusing loop (avoid doing this)
for !i=1 to 25
vector a!i
!i=!i+10
next
Here, both the FOR assignment and the assignment statement within the loop change the
value of the control variable !I. Loops of this type are difficult to follow and may produce
unintended results. If you find a need to change a control variable inside the loop, consider
using a WHILE loop as explained below.
You may execute FOR loops with scalars instead of control variables. However, you must
first declare the scalar, and you may not use the scalar as a replacement variable. For
example,
scalar i
scalar sum = 0
vector (10) x
for i=1 to 10
x(i) = i
sum = sum + i
next
In this example, the scalars I and SUM remain in the workfile after the program has fin-
ished running, unless they are explicitly deleted.
You can put multiple string variables in the same FOR statementEViews will process the
strings in sets. For example,
for %1 %2 %3 1955:1 1960:4 early 1970:2 1980:3 mid 1975:4
1995:1 late
smpl %1 %2
equation {%3}eq.ls sales c orders
next
In this case, the elements of the list are taken in groups of three. The loop is executed three
times for the different sample pairs and equation names:
smpl 1955:1 1960:4
equation earlyeq.ls sales c orders
smpl 1970:2 1980:3
equation mideq.ls sales c orders
smpl 1975:4 1995:1
equation lateeq.ls sales c orders
Note the difference between this construction and nested FOR loops. Here, all string vari-
ables are advanced at the same time, whereas with nested loops, the inner variable is
advanced over all choices, while the outer variable is held constant. For example,
!eqno = 1
for %1 1955:1 1960:4
for %2 1970:2 1980:3 1975:4
smpl %1 %2
'form equation name as eq1 through eq6
equation eq{!eqno}.ls sales c orders
!eqno=!eqno+1
next
102Chapter
102 6. EViews Programming
next
Here, the equations are estimated over the samples 1955:11970:2 for EQ1, 1955:11980:3
for EQ2, 1955:11975:4 for EQ3, 1960:41970:2 for EQ4, 1960:41980:3 for EQ5, and
1960:41975:4 for EQ6.
The WHILE loop begins with a while statement and ends with a wend statement. Any
number of commands may appear between the two statements. WHILE loops can be
nested.
The WHILE statement consists of the while keyword followed by an expression involving
a control variable. The expression should have a logical (true/false) value or a numerical
value. In the latter case, zero is considered false and any non-zero value is considered true.
If the expression is true, the subsequent statements, up to the matching wend, will be exe-
cuted, and then the procedure is repeated. If the condition is false, EViews will skip the fol-
lowing commands and continue on with the rest of the program following the wend
statement. For example,
!val = 1
!a = 1
while !val<10000 and !a<10
smpl 1950:1 1970:1+!a
series inc{!val} = income/!val
!val = !val*10
!a = !a+1
wend
There are four parts to this WHILE loop. The first part is the initialization of the control
variables used in the test condition. The second part is the WHILE statement which
includes the test. The third part is the statements updating the control variables. Finally
the end of the loop is marked by the word wend.
Unlike a FOR statement, the WHILE statement does not update the control variable used in
the test condition. You need to explicitly include a statement inside the loop that changes
the control variable, or your loop will never terminate. Use the F1 key to break out of a
program which is in an infinite loop.
Control of Execution103
103
In the example above of a FOR loop that changed the control variable, a WHILE loop pro-
vides a much clearer program:
!i = 1
while !i<=25
vector a{!i}
!i = !i + 11
wend
To test for and handle execution errors, you should use the @errorcount function to
return the number of errors encountered while executing your program:
!errs = @errorcount
The information about the number of errors may be used by standard program statements
to control the behavior of the program.
For example, to test whether the estimation of a equation generated an error, you should
compare the number of errors before and after the command:
!old_count = @errorcount
equation eq1.ls y x c
!new_count = @errorcount
if !new_count > !old_count then
[various commands]
endif
Here, we perform a set of commands only if the estimation of equation EQ1 incremented
the error count.
Other Tools
Occasionally, you will wish to stop a program or break out of a loop based on some condi-
tions. To stop a program executing in EViews, use the stop command. For example, sup-
pose you write a program that requires the series SER1 to have nonnegative values. The
following commands check whether the series is nonnegative and halt the program if SER1
contains any negative value:
104Chapter
104 6. EViews Programming
Note that if SER1 contains missing values, the corresponding value of TEST will also be
missing. Since the @sum function ignores missing values, the program does not halt for
SER1 that has missing values, as long as there is no negative value.
Sometimes, you do not wish to stop the entire program when a condition is satisfied; you
just wish to exit the current loop. The exitloop command will exit the current for or
while statement and continue running the program.
For example, suppose you computed a sequence of LR test statistics LR11, LR10, LR9, ...,
LR1, say to test the lag length of a VAR. The following program sequentially carries out the
LR test starting from LR11 and tells you the statistic that is first rejected at the 5% level:
!df = 9
for !lag = 11 to 1 step -1
!pval = 1 - @cchisq(lr{!lag},!df)
if !pval<=.05 then
exitloop
endif
next
scalar lag=!lag
Note that the scalar LAG has the value 0 if none of the test statistics are rejected.
While you may be tempted to string files together using the run command, we caution you
that EViews will stop after executing the commands in the referenced file. Thus, a program
containing the lines
run powers.prg
series x = nrnd
will only execute the commands in the file POWERS, and will stop before generating the
series X. This behavior is probably not what you intended.
Subroutines105
105
You should instead use the include keyword to include the contents of a program file in
another program file. For example, you can place the line
include powers
at the top of any other program that needs to use the commands in POWERS. include
also accepts a full path to the program file and you may have more than one include
statement in a program. For example the lines,
include c:\programs\powers.prg
include durbin_h
[more lines]
will first execute all of the commands in C:\PROGRAMS\POWERS.PRG, then will execute
the commands in DURBIN_H.PRG, and then will execute the remaining lines in the pro-
gram file.
Subroutines provide a more general, alternative method of reusing commands and using
arguments.
Subroutines
A subroutine is a collection of commands that allows you to perform a given task repeat-
edly, with minor variations, without actually duplicating the commands. You can also use
subroutines from one program to perform the same task in other programs.
Defining Subroutines
A subroutine starts with the keyword subroutine followed by the name of the routine
and any arguments, and ends with the keyword endsub. Any number of commands can
appear in between. The simplest type of subroutine has the following form:
subroutine z_square
series x = z^2
endsub
where the keyword subroutine is followed only by the name of the routine. This subrou-
tine has no arguments so that it will behave identically every time it is used. It forms the
square of the existing series Z and stores it in the new series X.
You can use the return command to force EViews to exit from the subroutine at any time.
A common use of return is to exit from the subroutine if an unanticipated error is
detected. The following program exits the subroutine if Durbins h statistic for testing serial
correlation with a lagged dependent variable cannot be computed (for details, see Greene,
1997, p.596, or Davidson and MacKinnon, 1993, p. 360):
subroutine durbin_h
106Chapter
106 6. EViews Programming
where f depends upon the argument x. The argument x is merely a place holderits there
to define the function and it does not really stand for anything. Then if you want to evalu-
ate the function at a particular numerical value, say 0.7839, you can write f(0.7839). If you
want to evaluate the function at a different value, say 0.50123, you merely write
f(0.50123). By defining the function, you save yourself from writing out the whole expres-
sion every time you wish to evaluate it for a different value.
To define a subroutine with arguments, you start with subroutine, followed by the sub-
routine name, a left parenthesis, the arguments separated by commas, and finally a right
parenthesis. Each argument is specified by listing a type of EViews object, followed by the
name of the argument. Control variables may be passed by the scalar type and string vari-
ables by the string type. For example,
subroutine power(series v, series y, scalar p)
v = y^p
endsub
This subroutine generalizes the example subroutine Z_SQUARE. Calling POWER will fill
the series given by the argument V with the power P of the series specified by the argu-
ment Y. So if you set V equal to X, Y equal to Z, and P equal to 2, you will get the equiva-
Subroutines107
107
lent of the subroutine Z_SQUARE above. See the discussion below on how to call
subroutines.
Subroutine Placement
Your subroutine definitions should be placed, in any order, at the beginning of your pro-
gram. The subroutines will not be executed until they are executed by the program using a
call statement. For example,
subroutine z_square
series x=z^2
endsub
' start of program execution
load mywork
fetch z
call z_square
Execution of this program begins with the load statement; the subroutine definition is
skipped and is executed only at the last line when it is called.
The subroutine definitions must not overlapafter the subroutine keyword, there
should be an endsub before the next subroutine declaration. Subroutines may call each
other, or even call themselves.
Alternatively, you may wish to place frequently used subroutines in a separate program file
and use an include statement to insert them at the beginning of your program. If, for
example, you put the subroutine lines in the file POWERS.PRG then you may put the line
include powers
at the top of any other program that needs to call Z_SQUARE or POWER. You can use the
subroutines in these programs as though they were built-in parts of the EViews program-
ming language.
Calling Subroutines
Once a subroutine is defined in your program, you may execute the commands in the sub-
routine by using the call keyword. call should be followed by the name of the subrou-
tine, and a list of any argument values you wish to use, enclosed in parentheses and
separated by commas. If the subroutine takes arguments, they must all be provided in the
same order as in the declaration statement. Here is an example program file that calls sub-
routines:
include powers
load mywork
108Chapter
108 6. EViews Programming
fetch z gdp
series x
series gdp2
series gdp3
call z_square
call power(gdp2,gdp,2)
call power(gdp3,gdp,3)
The first calls fills the series X with the value of Z squared. The second call creates the
series GDP2 which is GDP squared. The last call creates the series GDP3 as the cube of
GDP.
When the subroutine argument is a scalar, the subroutine may be called with a scalar
object, a control variable, a simple number (such as 10 or 15.3), a matrix element
(such as mat1(1,2)) or a scalar expression (such as !y+25). Subroutines that take
matrix and vector arguments can be called with a matrix name, and if not modified by the
subroutine, may also take a matrix expression. All other arguments must be passed to the
subroutine with a simple object (or string) name referring to a single object of the correct
type.
Global variables refer either to objects which exist in the workfile when the subroutine is
called, or to the objects that are created in the workfile by a subroutine. Global variables
remain in the workfile when the subroutine finishes.
A local variable is one that has meaning only within the subroutine. Local variables are
deleted from the workfile once a subroutine finishes. The program that calls the subroutine
will not know anything about a local variable since the local variable will disappear once
the subroutine finishes and returns to the original program.
Global Subroutines
By default, subroutines in EViews are global. Any global subroutine may refer to any glo-
bal object that exists in the workfile at the time the subroutine is called. Thus, if Z is a
series in the workfile, the subroutine may refer to and, if desired, alter the series Z. Simi-
larly, if Y is a global matrix that has been created by another subroutine, the current sub-
routine may use the matrix Y.
Newly created objects are global and will be included in the workfile when the sub-
routine finishes.
Subroutines109
109
Global objects may be used and updated directly from within the subroutine. If,
however, a global object has the same name as an argument in a subroutine, the
variable name will refer to the argument and not to the global variable.
The global objects corresponding to arguments may be used and updated by refer-
ring to the arguments.
Z_SQUARE is a global subroutine which has access to the global series Z. The new global
series X contains the square of the series Z. Both X and Z remain in the workfile when
Z_SQUARE is finished.
If one of the arguments of the subroutine has the same name as a global variable, the argu-
ment name takes precedence. Any reference to the name in the subroutine will refer to the
argument, not to the global variable. For example,
subroutine sqseries(series z,string %name)
series {%name} = z^2
endsub
load mywork
fetch z
fetch y
call sqseries(y,"y2")
In this example, there is a series Z in the original workfile and Z is also an argument of the
subroutine. Calling SQSERIES with the argument set to Y tells EViews to use the argument
rather than the global Z. Upon completion of the routine, a new series Y2 will contain the
square of the series Y, not the square of the series Z.
Global subroutines may call global subroutines. You should make certain to pass along any
required arguments when you call a subroutine from within a subroutine. For example,
subroutine wgtols(series y, series wt)
equation eq1
call ols(eq1, y)
equation eq2
110Chapter
110 6. EViews Programming
In this example, the subroutine WGTOLS explicitly passes along the arguments for EQ and
Y to the subroutine OLS; otherwise those arguments would not be recognized by OLS. If
EQ and Y were not passed, OLS would try to find a global series named Y and a global
equation named EQ, instead of using EQ1 and CS or EQ2 and TEMP.
You cannot use a subroutine to change the object type of a global variable. Suppose that
we wish to declare new matrices X and Y by using a subroutine NEWXY. In this example,
the declaration of the matrix Y works, but the declaration of matrix X generates an error
because a series named X already exists:
subroutine newxy
matrix(2,2) x = 0
matrix(2,2) y = 0
endsub
load mywork
series x
call newxy
EViews will return an error indicating that the global series X already exists and is of a dif-
ferent type than a matrix.
Local Subroutines
All objects created by a global subroutine will be global and will remain in the workfile
upon exit from the subroutine. If you include the word local in the definition of the sub-
routine, you create a local subroutine. All objects created by a local subroutine will be local
and will be removed from the workfile upon exit from the subroutine. Local subroutines
Subroutines111
111
are most useful when you wish to write a subroutine which creates many temporary
objects that you do not want to keep.
You may not use or update global objects directly from within the subroutine.
The global objects corresponding to arguments may be used and updated by refer-
ring to the arguments.
All other objects in the subroutine are local and will vanish when the subroutine fin-
ishes.
If you want to save results from a local subroutine, you have to explicitly include them in
the arguments. For example,
subroutine local ols(series y, series res, scalar ssr)
equation temp_eq.ls y c y(-1) y(-1)^2 y(-1)^3
temp_eq.makeresid res
ssr = temp_eq.@ssr
endsub
This local subroutine takes the series Y as input and returns the series RES and scalar SSR
as output. The equation object TEMP_EQ is local to the subroutine and will vanish when
the subroutine finishes.
Note how we first declare the series URES and scalar USSR before calling the local subrou-
tine. These objects are global since they are declared outside the local subroutine. When
we call the local subroutine by passing these global objects as arguments, the subroutine
will update these global variables.
There is one exception to the general inaccessibility of global variables in local subrou-
tines. When a global group is passed as an argument to a local subroutine, any series in
the group is accessible to the local routine.
112Chapter
112 6. EViews Programming
Local subroutines can call global subroutines and vice versa. The global subroutine will
only have access to the global variables, and the local subroutine will only have access to
the local variables, unless information is passed between the routines via arguments. For
example, the subroutine
subroutine newols(series y, series res)
include ols
equation eq1.ls y c y(-1)
eq1.makeresid res
scalar rssr=eq1.@ssr
series ures
scalar ussr
call ols(y, ures, ussr)
endsub
produce equivalent results. Note that the subroutine NEWOLS still does not have access to
any of the temporary variables in the local routine OLS, even though OLS is called from
within NEWOLS.
Programming Summary
Support Commands
open .................... opens a program file from disk (p. 267).
output.................. redirects print output to objects or files (p. 271).
poff...................... turns off automatic printing in programs (p. 410).
pon...................... turns on automatic printing in programs (p. 410).
program ............... declares a program (p. 279).
run ...................... runs a program (p. 296).
statusline ............. sends message to the status line (p. 411).
Program Statements
call ...................... calls a subroutine within a program (p. 405).
else ...................... denotes start of alternative clause for if (p. 405).
endif .................... marks end of conditional commands (p. 406).
Programming Summary113
113
Support Functions
@date...................string containing the current date (p. 405).
@errorcount .........number of errors encountered (p. 406).
@evpath ...............string containing the directory path for the EViews executable
(p. 407).
@isobject .............checks for existence of object (p. 409).
@time ..................string containing the current time (p. 414).
@toc ....................calculates elapsed time (since timer reset) in seconds (p. 415).
String Functions
@dtoo ..................converts date string to observation number (p. 385).
@left ....................extracts left portion of string (p. 391).
@mid ...................extracts middle portion of string (p. 393).
@otod ..................converts observation number to date string (p. 394).
@right..................extracts right portion of string (p. 397).
@str .....................returns a string representing a number (p. 400).
@strlen ................returns the length of a string (p. 400).
@val ....................returns the number represented by a string (p. 403).
114Chapter
114 6. EViews Programming
Chapter 7. Sample Programs
In this chapter, we provide extended examples showing the use of the EViews program-
ming language to perform the following tasks:
In addition, there are a number of example files for creating and estimating user defined
likelihood functions. These example files are as described in Additional Examples on
page 474.
We have included program and data files for each example in your EViews examples direc-
tory. You may open each file by clicking on File/Open/Program
and selecting the appro-
priate file. To run the program, either click on Run in the program window, or enter the
command run, followed by the program name, in the command window.
Note that there may be additional programs in your EViews directory that were added after
the manual went to press and therefore are not listed here. If you find that the examples
here do not cover an issue of interest, you may wish to browse the contents of your EViews
examples directory.
The results are saved in tables named TABIP, TABURATE, TABM1, and TABTB10. For
example, TABIP contains:
(desc2.prg)
The example above saves the values in a table. You may instead wish to place the annual
values in a vector or matrix so that they can be used in other calculations. The following
program creates a vector to hold the median values for each year, and loops through the
calculation of the median for each year:
' load the basics workfile
%evworkfile = @evpath + "\example files\basics"
load "{%evworkfile}"
smpl 1990:1 @last
' create series with the year and find the maximum
series year = @year
Rolling ADF Test117
117
!lastyear = @max(year)
next
freeze(graph1) adftstat.line
graph1.name(1) ADF t-statistic
graph1.name(2) asymptotic 5% critical value
graph1.addtext(t) ADF t-statistic for window of 50 obs for M1
show graph1
Calculating Cumulative Sums119
119
-2
-4
-6
50 100 150 200 250 300 350
Say we have a series X for which we would like to calculate the cumulative sum. If the
series does not contain NAs, you can use:
smpl @first @first
series sum0 = x
smpl @first+1 @last
sum0 = sum0(-1) + x
If the series does contain NAs, you have two options, depending on how you would like
the NAs to be treated. If you would like to continue accumulating the sum, ignoring the
NA observations, you can use:
smpl @first @first
series sum1 = @nan(x, 0)
smpl @first+1 @last
sum1 = sum1(-1) + @nan(x, 0)
smpl @all if x = na
sum1 = na
If you would like to reset the sum to zero whenever an NA appears in the series you can
use:
smpl @all
series sum2 = x
smpl if sum2(-1)<>na and x<>na
120Chapter
120 7. Sample Programs
sum2 = sum2(-1) + x
The following sample output shows the differences between the three methods:
Time series operations often rely on observations being adjacent, so that this method may
not work as expected. In this example we demonstrate a general technique for working
with a subset of observations from the workfile as though they were adjacent. There are
three steps to using the method:
create a short version of the data which contains only the subset of observations.
use the short version of the data to get whatever results you need.
create a long version of the results which match the observations in the original
data.
Consider the simple case of creating a series which contains the differences between con-
secutive positive values of the series X, ignoring any intervening negative values.
The commands
smpl if x>=0
series dxp = d(x)
Creating Dummy Variables with a Loop121
121
will not compute the desired values, since the d function computes differences between
adjacent values, not between successive values in the sample.
The SUBSET.PRG program solves this problem using the general technique outlined above.
The solution is stored in the series DX. The series X_S and DX_S are left in the workfile so
you can follow the intermediate calculations.
' create sample
sample ss if x<>NA and x>=0
The program MAKE_DUM.PRG automates this task. It should be run from the command
line with arguments for the first and the last observation for which to create dummies. For
example, to create dummies in a quarterly workfile from the first quarter of 1982 to the last
quarter of 1983, the command would be:
run make_dum 1982:1 1983:4
As is, the program should work for annual, semiannual, quarterly, monthly and undated
workfiles. It should be modified for weekly and daily workfiles.
'Set up start and end dates
%start = %0 'the first observation to dummy
%end = %1 'the last observation to dummy
If you would like to work with statistics from these views in a program, you should use the
following general method that allows you to extract and store output from any object view.
The basic steps in each step through the loop are:
extract the cell containing the statistic and assign its contents to an element of a
table or vector.
Extracting Test Statistics in a Loop123
123
The following subroutine uses this approach to capture the F-statistic and probability
value from an omitted variables test. The subroutine OMIT_TEST cycles through the series
contained in a group, testing whether the first four lags of each series are jointly significant
when added to the chosen equation. The output is stored in a table.
' test whether the first four lags of an omitted variable
' are jointly significant (eq1: the equation to test;
' g: a list of the series to include; results: output)
subroutine omit_test(equation eq1, group g, table results)
!n = g.@count
table(3, !n) results
setcolwidth(results, 1, 12)
setcell(results, 1, 1, "Four lag F-test for omitted
variables:", "l")
results(2,2) = "F-stat"
results(2,3) = "Probability"
for !i = 1 to !n
%name = g.@seriesname(!i)
series temp_s = %name
freeze(temp_t) eq1.testadd temp_s(-1) temp_s(-2) temp_s(-3)
temp_s(-4)
results(!i+2, 1) = %name
results(!i+2, 2) = temp_t(3, 2)
results(!i+2, 3) = temp_t(3, 5)
delete temp_t
delete temp_s
next
endsub
The following program uses this subroutine to carry out some tests on the data from the
demo in Chapter 2 of the Users Guide. Both the subroutine and the program can be found
in the file OMITTED.PRG.
open demo.wf1
smpl @all
equation eq1.ls dlog(m1) c dlog(m1(-1)) dlog(m1(-2)) dlog(m1(-3))
dlog(m1(-4))
group g1 dlog(gdp) dlog(rs) dlog(pr)
table tab1
call omit_test(eq1, g1, tab1)
show tab1
124Chapter
124 7. Sample Programs
where i is the cross-section index and t represents the time period. EViews provides built-
in procedures to perform fixed effects (within-groups) estimation of ¯ :
where a bar over a variable name represents the average over time for the cross-section.
Alternatively, you may wish to estimate the between groups model:
A quick way to obtain the between groups estimate is to use auto series in a pooled regres-
sion. If we run the pool regression
pool1.ls(c) @mean(log(ivm?)) @mean(log(mm?))
Although the point estimates are correct, the standard errors are not since EViews uses
multiple observations for each cross-section unit.
We can, however, use a program to obtain the between estimator. The following program
stores the cross-section specific means of each series in a matrix, creates a new workfile,
converts the matrix to series, and runs the between groups regression:
' set number of cross-sections
%evworkfile = @evpath + "\example files\pool1"
load "{%evworkfile}"
smpl @all
!ncross = pool1.@ncross
The equation results for the between estimator are given by:
126Chapter
126 7. Sample Programs
Note that the temporary group TEMPGRP and temporary series TEMPSER are deleted at
the end of the program.
covar = pool1.@cov
if qform(1,1)>=0 then
' set table to store results
table(4,2) result
setcolwidth(result, 1, 17)
setcell(result,1,1,"Hausman test","l")
setcell(result,2,1,"(fixed versus random effects)","l")
setline(result,3)
!df = @rows(b_diff)
setcell(result,4,1,"Chi-square ("+@str(!df)+" d.f.)","l")
setcell(result,4,2,qform(1,1))
setcell(result,5,1,"p-value","l")
setcell(result,5,2,1-@cchisq(qform(1,1),!df))
show result
else
statusline "Quadratic form is negative"
endif
Note that the program stops if the computed test statistic is negative, which can happen in
finite samples. Running this program yields the table
Hausman test
(fixed versus random effects)
A commonly used alternative display format places the standard errors or t-statistics,
enclosed in parentheses, below the coefficient estimates. The program file REGTAB.PRG
contains a subroutine which takes an equation object and creates a table with this alterna-
tive output:
' subroutine to reformat regresion output
subroutine regtab(equation eq1, table tab1, scalar format)
setcolwidth(tab1, 1, 19)
setcolwidth(tab1, 2, format+4)
setcolwidth(tab1, 3, 19)
setcolwidth(tab1, 4, format+4)
Regression Output Table129
129
setline(tab1, !line)
!line = !line + 1
!line = !line + 1
endsub
To call the subroutine, you can open the program REGRUN.PRG, which contains the fol-
lowing commands:
include regtab.prg
%evworkfile = @evpath + "\example files\basics"
load "{%evworkfile}"
table tab1
call regtab(eq1, tab1, 3)
show tab1
The first argument to the REGTAB subroutine is the equation object, the second is the table
into which you wish to place the results, and the third argument is a numeric format code.
Here we indicate that we wish to display three digits after the decimal. Table TAB1 will
contain the reformatted output:
132Chapter
132 7. Sample Programs
C -1.700 -1.700
(0.165) **(-10.305)
LOG(IP) 1.766 1.766
(0.044) **(40.552)
TB3 -0.012 -0.012
(0.005) *(-2.570)
This chapter provides a complete alphabetical listing of the commands, views, and procedures
in EViews.
Each entry is comprised of a keyword, followed by a listing of the ways in which the keyword
may be used. The entry also provides a summary of behavior, as well as a description of the
syntax. If appropriate, we also provide a listing of additional arguments, short examples, and
cross-references.
Note that the keyword correl may be used in three distinct ways: as a command to compute
the correlogram of a specified series, as a series view to display the correlogram for a series
object, and as an equation view to display the correlogram of the residuals from the estimated
equation. The syntax for each of these uses is documented separately.
In addition to the dictionary-style alphabetical listing provided here, there are several other
places in the Command and Programming Reference that contain reference material:
Basic Command Summary beginning on page 17, provides a listing of commands com-
monly used when managing objects in workfiles and databases.
134Chapter
134 8. Command Reference
Chapter 3, Object, View and Procedure Reference, beginning on page 21, lists all
of the views and procedures classified by object, making it easy to see which views
and procedures are available for a given object.
In Matrix Function and Command Summary on page 74, we list the basic func-
tions and commands used when working with matrix objects.
In Programming Summary on page 112, we list the commands, functions and key-
words used in the EViews programming and string processing.
Chapter 9, Matrix and String Reference, beginning on page 381 documents the
matrix, vector, scalar, and string functions and commands.
Syntax
System Method: system_name.3sls(options)
Options
Examples
sys1.3sls(i)
Estimates SYS1 by the 3SLS method, iterating simultaneously on the weighting matrix and
the coefficient vector.
nlsys.3sls(d,b,m=500)
Estimates NLSYS by 3SLS using BHHH with up to 500 iterations. The d option displays
the starting values.
Cross-references
See Chapter 19 of the Users Guide for discussion of system estimation.
Syntax
Group Proc: group_name.add ser1 [ser2 ser3 ...]
Group Proc. group_name.add grp1 [grp2 ...]
Pool Proc: pool_
_name.add id1 [id2 id3 ...]
136Chapter
136 8. Command Reference
List the names of series or group of series to add to the group, or list the cross-section iden-
tifiers to add to the pool.
Examples
dummy.add d11 d12
Adds the two series D11 and D12 to the group DUMMY.
countries.add us gr
Cross-references
See also drop (p. 193).
Syntax
Model Proc: model_name.addassign(options) equation_spec
where equation_spec identifies the equations for which you wish to assign add factors. You
may either provide a list of endogenous variables, or you can use one of the following
shorthand keywords:
The options identify the type of add factor to be used, and control the assignment behavior
for equations where you have previously assigned add factors. addassign may be called
multiple times to add different types of add factors to different equations. addassign may
also be called to remove existing add factors.
Options
Examples
m1.addassign(v) @all
assigns variable shifts to the stochastic equations and the equations for Y1, Y2, and Y3,
and assigns intercept shifts to the identities.
Cross-references
See Using Add Factors on page 608 of the Users Guide. See also Chapter 23 of the Users
Guide for a general discussion of models.
Syntax
Model Proc: model_name.addinit(options) equation_spec
where equation_spec identifies the equations for which you wish to initialize the add fac-
tors. You may either provide a list of endogenous variables, or you may use one of the fol-
lowing shorthand keywords:
The options control the type of initialization and the scenario for which you want to per-
form the initialization. addinit may be called multiple times to initialize various types of
add factors in the different scenarios.
Options
Examples
m1.addinit(v=b) @all
sets all of the add factors in the active scenario to the values of the baseline.
m1.addinit(v=z) @stochastic
m1.addinit(v=n) y1 y1 y2
first sets the active scenario stochastic equation add factors to zero, and then sets the Y1,
Y2, and Y3 equation residuals to zero (evaluated at actuals).
m1.addinit(s=b, v=z) @stochastic
Cross-references
See Using Add Factors on page 608 of the Users Guide. See also Chapter 23 of the Users
Guide for a general discussion of models.
Syntax
Graph Proc: graph_name.addtext(options) text
Follow the addtext keyword with the text to be placed in the graph.
Options
The following options control the position of the text.
To place text within a graph, you can use explicit coordinates to specify the position of the
upper left corner of the text.
Coordinates may be used with other options, but they must be in the first two positions of
the options list. Coordinates are overridden by other options that specify location.
When addtext is used with a multiple graph, the text is applied to the whole graph, not
to each individual graph.
Examples
freeze(g1) gdp.line
g1.addtext(t) Fig 1: Monthly GDP (78.1-95.12)
Places the text Fig1: Monthly GDP (78.1-95.12) centered above the graph G1.
Places the text Seasonally Adjusted in a box within the graph, slightly indented from the
upper left corner.
Cross-references
See also legend (p. 233).
Syntax
Graph Proc: graph_
_name.align(n,h,v)
Options
You must specify three numbers (each separated by a comma) in parentheses in the fol-
lowing order: the first number n is the number of columns in which to place the graphs,
the second number h is the horizontal space between graphs, and the third number v is the
vertical space between graphs. Spacing is specified in virtual inches.
Examples
mygraph.align(3,1.5,1)
Aligns MYGRAPH with graphs placed in three columns, horizontal spacing 1.5 inches, and
vertical spacing 1 inch.
var var1.ls 1 4 m1 gdp
freeze(impgra) var1.impulse(m,24) gdp @ gdp m1
impgra.align(2,1,1)
append141
141
Estimates a VAR, freezes the impulse response functions as multiple graphs, and realigns
the graphs. By default, the graphs are stacked in one column, and the realignment places
the graphs in two columns.
Cross-references
For a detailed discussion of customizing graphs, see Chapter 10, Graphs, Tables, and Text
Objects, on page 235 of the Users Guide.
append Logl Proc | Model Proc | Sspace Proc | System Proc | Var Proc
Syntax
Object Proc: object_name.append text
Var Proc: var_name.append(options) text
Type the text to be added after the append keyword. For vars, you must specify the text
type in the options argument.
Examples
model macro2
macro2.merge eq_m1
macro2.merge eq_gdp
macro2.append assign @all f
macro2.solve
The first line declares a model object. The second and third lines merge existing equations
into the model. The fourth line appends an assign statement to the model. The fifth line
solves the model.
system macro1
142Chapter
142 8. Command Reference
macro1.append cons=c(1)+c(2)*gdp+c(3)*cons(-1)
macro1.append inv=c(4)+c(5)*tb3+c(6)*d(gdp)
macro1.append gdp=cons+inv+gov
macro1.append inst tb3 gov cons(-1) gdp(-1)
macro1.gmm
show macro1.results
The first line declares a system. The next three lines appends the specification of each
endogenous variable in the system. The fifth line appends the list of instruments to be
used in estimation. The last two lines estimate the model by GMM and display the estima-
tion results.
vector(2) svec0=0
sspace1.append @mprior svec0
This command appends a line in the state space object SSPACE1 to use the zero vector
SVEC0 as initial values for the state vector.
Cross-references
See also cleartext (p. 161). See Chapters 19 and 23 of the Users Guide for a discussion
of systems and models, respectively.
ar Expression
Examples
The command
regresses M1 on a constant, TB3, and TB3 lagged once with a first order and fourth order
autoregressive component. The command
tsls sale c adv ar(1) ar(2) ar(3) ar(4) @ c gdp
performs two-stage least squares of SALE on a constant and ADV with up to fourth order
autoregressive components using a constant and GDP as instruments.
arch143
143
Cross-references
See Chapter 13, Time Series Regression, on page 295 of the Users Guide for details on
ARMA and seasonal ARMA modeling.
See also sar (p. 298), ma (p. 243), and sma (p. 319).
Syntax
Command: arch(p,q,options) y x1 x2 x3 [@ p1 p2 @ t1 t2]
Equation Method: eq_name.arch(p,q,options) y x1 x2 x3 [@ p1 p2 @ t1 t2]
ARCH estimates a GARCH(p, q) model with p ARCH terms and q GARCH terms. If you do
not specify (p, q), then GARCH(1,1) is assumed by default. After the arch keyword, spec-
ify the dependent variable followed by a list of regressors in the mean equation.
By default, no exogenous variables (except for the intercept) are included in the condi-
tional variance equation. If you want to include variance regressors in addition to the
GARCH terms, list them after the mean equation regressors using an @-sign to separate
the two lists.
If you choose the option for component ARCH models, you may specify exogenous vari-
ables for the permanent and transitory components separately. After the mean equation
regressors, first list the regressors for the permanent component, followed by an @-sign,
then the regressors for the transitory component. A constant term is always included in the
permanent component.
Options
Saved results
Most of the results saved for the ls command are also available after ARCH estimation;
see ls (p. 239) for details.
Examples
The command
arch(4,0,m=1000,h) sp500 c
The commands
archtest145
145
c=.1
equation arc1.arch(s,v) nys c @ r
estimate a GARCH(1,1)-in-mean specification, with the mean equation for NYS depending
upon a constant and a conditional variance (GARCH) term. The conditional variance equa-
tion is the default GARCH(1,1) specification, with exogenous regressors R and a constant.
The first line sets the default coefficient vector to 0.1 and the s option uses these ele-
ments of the C coefficient vector as starting values.
Following estimation, we can save the estimated conditional variance as a series named
GARCH1.
arc1.makegarch garch1
Cross-references
See Chapter 16 of the Users Guide for a discussion of ARCH models.
Carries out Lagrange Multiplier (LM) tests for ARCH in the residuals.
Syntax
Command: archtest(options)
Equation View: eq_name.archtest(options)
Options
You must specify the order of ARCH to test for. The number of lags to include should be
provided in parentheses after the arch keyword.
Other Options:
Examples
ls output c labor capital
archtest(4)
Regresses OUTPUT on a constant, LABOR, and CAPITAL and tests for ARCH up to order 4.
equation eq1.arch sp500 c
146Chapter
146 8. Command Reference
eq1.archtest(4)
Estimates a GARCH(1,1) model with mean equation of SP500 on a constant and tests for
additional ARCH up to order 4. Note that performing an archtest after an arch estima-
tion uses the standardized residuals (the residual of the mean equation divided by the esti-
mated conditional standard deviation).
Cross-references
See ARCH LM Test on page 361 of the Users Guide for further discussion of testing ARCH
and Chapter 16 of the Users Guide for a general discussion of working with ARCH models
in EViews.
Syntax
Var View: var_name.arlm(h, options)
You must specify the highest order of lag h to test for serial correlation.
Options
Examples
var var1.ls 1 6 lgdp lm1 lcpi
show var1.arlm(12,name=lmout)
The first line declares and estimates a VAR with 6 lags. The second line displays the serial
correlation LM tests for lags up to 12 and stores the statistics in a matrix named LMOUT.
Cross-references
See Diagnostic Views on page 504 of the Users Guide for other VAR diagnostics.
See also qstats (p. 281) for related multivariate residual autocorrelation portmanteau
tests.
arroots147
147
Syntax
Var View: var_name.arroots(options)
Options
name= Save roots in named matrix object. The matrix has two
columns, where the first column is the real and the sec-
ond column is the imaginary part of each root in the
rows.
graph Plots the roots together with a unit circle. The VAR is
stable if all roots are inside the unit circle.
p Print table of AR roots.
Examples
var var1.ls 1 6 lgdp lm1 lcpi
var1.arroots(graph)
The first line declares and estimates a VAR with 6 lags. The second line plots the AR roots
of the estimated VAR.
var var1.ls 1 6 lgdp lm1 lcpi
’store roots
freeze(tab1) var1.arroots(name=roots)
The first line declares and estimates a VAR with 6 lags. The second line stores the roots in
a matrix named ROOTS and the table view as a table named TAB1.
Cross-references
See Diagnostic Views on page 504 of the Users Guide for other VAR diagnostics.
148Chapter
148 8. Command Reference
Carries out Breusch-Godfrey Lagrange Multiplier (LM) tests for serial correlation in the
estimation residuals.
Syntax
Command: auto(options)
Equation View: eq_name.auto(options)
In command form, auto tests the residuals from the default equation.
Options
You must specify the order of serial correlation to test for. You should specify the number
of lags in parentheses after the auto keyword, followed by any additional options.
Other Options:
Examples
To regress OUTPUT on a constant, LABOR, and CAPITAL and test for serial correlation of
up to order four:
ls output c labor capital
auto(4)
The commands
output(t) c:\result\artest.txt
equation eq1.ls cons c y y(-1)
eq1.auto(12, p)
perform a regression of CONS on a constant, Y and lagged Y and test for serial correlation
of up to order twelve. The first line redirects printed tables/text to the ARTEST.TXT file.
Cross-references
See Serial Correlation LM Test on page 297 of the Users Guide for further discussion of
the Breusch-Godfrey test.
bar149
149
Syntax
Command: bar(options) ser1 ser2 ser3 ...
Object View: object_name.bar(options)
Graph Proc: graph_name.bar(options)
Options
Template and printing options
Scale options
Examples
Plot a bar graph of POP together with line graphs of GDP and CONS:
150Chapter
150 8. Command Reference
The bar graph is scaled on the left, while the line graphs are scaled on the right. The graph
uses options from graph MYBAR1 as a template.
group mygrp oldsales newsales
mygrp.bar(s)
The first line defines a group of series and the second line graphs a stacked bar graph of
the series in the group.
Cross-references
See Graph Templates on page 241 of the Users Guide for a discussion of graph tem-
plates.
The BDS test is a portmanteau test for time based dependence in a series. It can be used
for testing against a variety of possible deviations from independence including linear
dependence, non-linear dependence, or chaos.
Syntax
Series View: series_name.bds(options)
Options
Cross-references
See BDS Test on page 168 of the Users Guide for additional discussion.
Estimates models where the binary dependent variable Y is either zero or one (probit,
logit, gompit).
Syntax
Command: binary(options) y x1 x2 x3
Equation Method: eq_name.binary(options) y x1 x2 x3
Options
Examples
To estimate a logit model of Y on a constant, WAGE, EDU, and KIDS with QML standard
errors:
binary(d=l,h) y c wage edu kids
This command uses the default quadratic hill climbing algorithm. The commands
param c(1) .1 c(2) .1 c(3) .1
equation probit1.binary(s) y c x2 x3
estimate a probit model of Y on a constant, X2, and X3, using the specified starting values.
The commands
coef beta_probit = probit1.@coefs
matrix cov_probit = probit1.@coefcov
store the estimated coefficients and coefficient covariances in the coefficient vector
BETA_PROBIT, and matrix COV_PROBIT.
Cross-references
See Binary Dependent Variable Models on page 405 of the Users Guide for additional
discussion.
Show the block structure of the model identifying which blocks are recursive and which
blocks are simultaneous.
Syntax
Model View: model_name.block(options)
cause153
153
Options
Cross-references
See Block Structure View on page 605 of the Users Guide for details. See the remainder
of Chapter 23 of the Users Guide for a general discussion of models.
See also eqs (p. 197), text (p. 353) and vars (p. 361) for alternative representations of
the model.
Performs pairwise Granger causality tests between (all possible) pairs of the listed series or
group of series.
Syntax
Command: cause(n, options) ser1 ser2 ser3
Group View: group_name.cause(n, options)
In command form, you should list the series or group of series in which to test Granger
causality.
Options
You must specify the number of lags n to use for the test; specify an integer in parentheses
after the cause keyword. Note that the regressors of the test equation are a constant and
the specified lags of the pair of series under test.
Other options:
Examples
Compute Granger causality tests of whether GDP Granger causes M1 and whether M1
Granger causes GDP.
cause(4) gdp m1
The regressors of each test are a constant and four lags of GDP and M1. The commands
154Chapter
154 8. Command Reference
print the result of six pairwise Granger causality tests for the three series in the MACRO
group. The regressors of each test are a constant and twelve lags of the two series under
test (and do not include lagged values of the third series in the group).
Cross-references
See Granger Causality on page 214 of the Users Guide for a discussion of Grangers
approach to testing hypotheses about causality.
ccopy Command
Copy series from the DRI Basic Economics database to the data bank.
Copies one or more series from the DRI Basic Economics Database to the EViews data
bank (.DB) files. You must have the DRI database installed on your computer to use this fea-
ture.
Syntax
Command: ccopy series_name
Type the name of the series you want to copy after the ccopy keyword. The data bank file
will be stored in the default directory with the same name as the series name in the DRI
database. You can supply path information to indicate the directory for the data bank file.
Examples
The command
ccopy lhur
copies the DRI series LHUR to LHUR.DB file in the default path directory, while
copies the GDP series to GDP.DB file in the B drive and the GNET series to the GNET.DB
file in C:\NIPADATA.
Cross-references
See also cfetch (p. 158), clabel (p. 160), store (p. 337), fetch (p. 201).
cdfplot155
155
The cd command changes the current default working directory. The current working
directory is displayed as Path=... at the bottom right of the EViews window.
Syntax
Command: cd path_name
Examples
To change the default directory to SAMPLE DATA in the A drive:
cd "a:\sample data"
Notice that the quotes surround the entire directory name. If your name does not contain
spaces, you may omit the quotes:
cd a:\test
Everything you save will be saved to the default directory, unless you specify a different
directory in the save command.
Cross-references
See Chapter 3, EViews Basics, on page 33 of the Users Guide for further discussion of
basic operations in EViews.
Syntax
Object View: series_name.cdfplot(options)
Note: due to the potential for very long computation times, standard errors will only be
computed if there are fewer than 2500 observations.
156Chapter
156 8. Command Reference
Options
Examples
To plot the empirical cumulative distribution function of the series LWAGE:
lwage.cdfplot
Cross References
See Chapter 9 of the Users Guide for a discussion of empirical distribution graphs.
Estimates models where the dependent variable is either censored or truncated. The allow-
able specifications include the standard Tobit model.
Syntax
Command: censored(options) y x1 x2 x3
Equation Method: eq_name.censored(options) y x1 x2 x3
censored157
157
Options
Examples
The command
estimates a censored regression model of HOURS on a constant, WAGE, EDU, and KIDS
with QML standard errors. This command uses the default normal likelihood, with left-
censoring at HOURS=0 and no right censoring, and the quadratic hill climbing algorithm.
Cross-references
See Chapter 17 of the Users Guide for discussion of censored and truncated regression
models.
cfetch Command
Fetch a series from the DRI Basic Economics database into a workfile.
cfetch reads one or more series from the DRI Basic Economics Database into the active
workfile. You must have the DRI database installed on your computer to use this feature.
Syntax
Command: cfetch series_name
Examples
cfetch lhur gdp gnet
reads the DRI series LHUR, GDP, and GNET into the current active workfile, performing
frequency conversions if necessary.
Cross-references
EViews automatic frequency conversion is described in Frequency Conversion begin-
ning on page 72 of the Users Guide.
See also ccopy (p. 154), clabel (p. 160), store (p. 337), fetch (p. 201).
Displays a table containing information on the numeric derivatives and user-supplied ana-
lytic derivatives (if available).
chow159
159
Syntax
Logl View: logl_name.checkderiv(options)
Options
Examples
ll1.ml
ll1.checkderiv
estimates a likelihood object named LL1 and displays a table that evaluates the numeric
derivatives.
Cross-references
See Chapter 18, The Log Likelihood (LogL) Object, on page 455 of the Users Guide for a
general discussion of the likelihood object and the @deriv statement.
Carries out Chow breakpoint and Chow forecast tests for parameter constancy.
Syntax
Command: chow(options) obs1 obs2 obs3
Equation View: eq_name.chow(options) obs1 obs2 obs3
You must provide the breakpoint (dates or observation numbers) to be tested. To specify
more than one breakpoint, separate the breakpoints by a space.
Options
f Chow forecast test. For this option, you must specify a single
breakpoint to test (default performs breakpoint test).
p Print the result of test.
160Chapter
160 8. Command Reference
Examples
The commands
ls m1 c gdp cpi ar(1)
chow 1970:1 1980:1
perform a regression of M1 on a constant, GDP, and CPI with first order autoregressive
errors, and test whether the parameters before the 1970s, during the 1970s, and after the
1970s are stable using the Chow breakpoint test.
To regress the log of SPOT on a constant, log of P_US, and log of P_UK and carry out the
Chow forecast test starting from 1973, enter the commands:
equation ppp.ls log(spot) c log(p_us) log(p_uk)
ppp.chow(f) 1973
You may also perform Chow tests on cross-section data. Suppose GENDER is a zero-one
dummy variable and, when sorted, observations up to 533 have GENDER=0 and for
observations from 534 on GENDER=1. Then the chow command tests whether the
LWAGE equation has the same coefficients for observations with GENDER=0 and GEN-
DER=1.
sort gender
ls lwage c edu edu^2 union
chow 534
Cross-references
See Chow's Breakpoint Test on page 364 of the Users Guide for further discussion.
clabel Command
clabel reads the description of a series from the DRI Basic Economics Database and dis-
plays it in the status line at the bottom of the EViews window.
Use this command to verify the contents of a given DRI database series name. You must
have the DRI database installed on your computer to use this feature.
Syntax
Command: clabel series_name
close161
161
Examples
clabel lhur
displays the description of the DRI series LHUR on the status line.
Cross-references
See also ccopy (p. 154), cfetch (p. 158), read (p. 283), fetch (p. 201).
Syntax
Var Proc: var_name.cleartext(arg)
You must specify the text type you wish to clear as an argument.
Options
One of the following arguments is required:
Examples
var1.cleartext(svar)
var1.append(svar) @lr2(@u1)=0
The first line clears the structural VAR identifying restrictions in VAR1. The next line speci-
fies a new long-run restriction for a structural factorization.
Cross-references
See also append (p. 141).
close Command
Closing an object eliminates its window. If the object is named, it is still displayed in the
workfile as an icon, otherwise it is deleted. Closing a program or workfile eliminates its
162Chapter
162 8. Command Reference
window and removes it from memory. If a workfile has changed since you activated it, you
will see a dialog box asking if you want to save it to disk.
Syntax
Command: close object_name
Examples
close gdp graph1 table2
opens the LWAGE window and displays the histogram view of LWAGE, then closes the win-
dow.
Cross-references
See Chapter 1 of the Users Guide for a discussion of basic control of EViews.
Note: vector and coefficient objects are both column vectors. However, only coef elements
are allowed in specifications of models or for sspace estimation.
Syntax
Command: coef(n) coef_name
Follow the coef keyword with the number of coefficients in parentheses and a name for
the object. If you omit the number of coefficients, EViews will create a vector of length 1.
Examples
coef(2) slope
ls lwage=c(1)+slope(1)*edu+slope(2)*edu^2
The first line declares a coef object of length 2 named SLOPE. The second line runs a least
squares regression and stores the estimated slope coefficients in SLOPE.
arch(2,2) sp500 c
coef beta=c
coef(6) beta
coefcov163
163
The first line estimates a GARCH(2,2) model using the default coef vector C. (The C in
an equation specification refers to the constant term, a series of ones.) The second line
declares a coef object named BETA and copies the contents of C to BETA. (The C in the
assignment statement refers to the default coef vector). The third line resizes BETA to
chop off all elements except the first six, which are the estimated parameters from the
GARCH(2,2) model. Note that since EViews stores coefficients with equations for later use,
you will generally not need to perform this operation to save your coefficient vectors.
Cross-references
See Coef on page 22 for a full description of the coef object.
coefcov Equation View | Logl View | Pool View | Sspace View | System View
Displays the covariances of the coefficient estimates for objects containing an estimated
equation or equations.
Syntax
Object View: object_name.coefcov(options)
Options
Examples
The set of commands
equation eq1.ls lwage c edu edu^2 union
eq1.coefcov
declares and estimates an equation and displays the coefficient covariance matrix in a win-
dow. To store the coefficient covariance matrix as a (symmetric) matrix object, use
@coefcov:
Cross-references
See also coef (p. 162) and spec (p. 327).
164Chapter
164 8. Command Reference
Syntax
Command: coint(test_option,n,option) y1 y2 y3
Command: coint(test_option,n,option) y1 y2 y3 @ x1 x2 x3
Group View: group_name.coint(test_option,n,option)
Var View: var_name.coint(test_option,n,option)
In command form, you should enter the coint keyword followed by a list of series or
group names within which you wish to test for cointegration. Each name should be sepa-
rated by a space. To use exogenous variables, such as seasonal dummy variables in the
test, list the names after an @-sign.
Note: the reported critical values assume no exogenous variables other than an intercept and
trend.
When used as a group or var view, coint tests for cointegration among the series in the
group or var. If the var object contains exogenous variables, the cointegration test will use
those exogenous variables. However, if you explicitly list the exogenous variables with an
@-sign, then only those that are listed will be used in the test.
Options
You must specify the test option followed by the number of lags n in parentheses separated
by a comma. You must choose one of the following six test options:
Other Options:
Examples
coint(s,4) gdp m1 tb3
summarizes the results of the Johansen cointegration test among the three series GDP, M1,
and TB3 for all five specifications of trend. The test equation uses lags of up to order four.
var1.coint(c,12) @
carries out the Johansen test for the series in the var object named VAR1. The @-sign
without a list of exogenous variables ensures that the test does not include any exogenous
variables in VAR1.
Cross-references
See Cointegration Test on page 519 of the Users Guide for details on the Johansen test.
166Chapter
166 8. Command Reference
Solve for values of control variable so that target series matches trajectory.
Syntax
Model Proc: model_name.control control_var target_var trajectory
Specify the name of the control variable, followed by the target variable, and then the tra-
jectory you wish to achieve for the target variable. EViews will solve for the values of the
control so that the target equals the trajectory over the current workfile sample.
Examples
m1.control myvar targetvar trajvar
will put into MYVAR the values that lead the solution of the model for TARGETVAR to
match TRAJVAR for the workfile sample.
Cross-references
See Solve Control for Target on page 621 of the Users Guide. See Chapter 23 of the Users
Guide for a general discussion of models.
copy Command
Copy an object. Duplicate objects within and across workfiles and databases.
Syntax
Command: copy(options) source_object_name destination_object_name
To make copies of the object within the active workfile, list the name of the original object
followed by the name for the copy.
To make copies of objects within a database, you can precede the name of the object with
the database name and a double colon ::.
You can also copy objects between a workfile and a database, or between two databases.
Simply prefix the object name with the database name and double colon ::.
You can copy several objects with one command by using the wild card characters ? (to
match any single character) and * (to match zero or more characters).
copy167
167
Options
When copying a group object from a workfile to a database
The following options control the frequency conversion method when copying series and
group objects to a workfile, converting from low to high frequency:
The following options control the frequency conversion method when copying series and
group objects to a workfile, converting from high to low frequency:
Note that if no method is specified, the global or series specific default conversion method
will be employed.
Examples
copy good_equation best_equation
copies GDP in the current workfile to the database named USDAT with the name GDP. To
copy GDP in the default database to the database named MACRO1 with the new name
GDP_US, use the command
The command
copy ::gdp ::gdp2
makes a backup copy of GDP in the default database with a different name GDP2.
makes a duplicate of all objects in the current workfile with name starting with GD to the
database named FINDAT.
cor169
169
Cross-references
See Copying Objects on page 115 of the Users Guide for a discussion of copying and
moving objects.
See also fetch (p. 201), setconvert (p. 311), and store (p. 337).
Correlation matrix.
Syntax
Command: cor(options) ser1 ser2 ser3
Group View: group_name.cor(options)
Matrix View: matrix_name.cor(options)
In command form, EViews will create an untitled group from the listed series, and then
display the correlation matrix view for that group.
When used as a matrix view, cor displays the correlation among the columns of the
matrix.
Options
Examples
cor height weight age
displays a 3 by 3 correlation matrix for the three series HEIGHT, WEIGHT, and AGE.
group mygroup height weight age
mygroup.cor
Cross-references
See also cov (p. 173), @cor (p. 383), and @cov (p. 384).
170Chapter
170 8. Command Reference
correl Command || Equation View | Group View | Series View | Var View
Correlogram.
Displays the autocorrelation and partial correlation functions of the specified series
together with the Q-statistics and p-values associated with each lag.
When used with equation objects, correl displays the correlogram of the residuals of the
equation.
Syntax
Command: correl(n, options) series_name
Object View: object_name.correl(n, options)
Options
Examples
correl(24) m1
m1.correl(24)
Cross-references
See Chapter 7 of the Users Guide for a discussion of autocorrelation (p. 166) and partial
correlation (p. 167) functions.
Displays the autocorrelation and partial correlation functions of the squared residuals from
an estimated equation, together with the Q-statistics and p-values associated with each
lag.
Syntax
View: equation_name.correl(n, options)
Options
Examples
eq1.correl(24)
displays the correlograms of the squared residuals for up to 24 lags, for equation EQ1.
Cross-references
See Chapter 7 of the Users Guide for a discussion of autocorrelation (p. 166) and partial
correlation (p. 167) functions.
Syntax
Command: count(options) y x1 x2 x3
Equation Method: eq_name.count(options) y x1 x2 x3
Follow the count keyword by the name of the dependent variable and a list of regressors,
each separated by a space.
172Chapter
172 8. Command Reference
Options
Examples
The command
count(d=n,v=2,g) y c x1 x2
estimates a normal QML count model of Y on a constant, X1, and X2 with fixed variance
parameter 2 and GLM standard errors.
equation eq1.count arrest c job police
eq1.makeresid(g) res_g
cov173
173
estimates a Poisson count model of ARREST on a constant, JOB, and POLICE and stores
the generalized residuals as RES_G.
equation eq1.count(d=p) y c x1
eq1.fit yhat
estimates a Poisson count model of Y on a constant and X1, and saves the fitted values
(conditional mean) in the series YHAT.
equation eq1.count(d=p, h) y c x1
estimates the same model with QML standard errors and covariances.
Cross-references
See Count Models on page 442 of the Users Guide for additional discussion.
Covariance matrix.
Syntax
Command: cov(options) ser1 ser2 ser3
Group View: group_name.cov(options)
Matrix View: matrix_name.cov(options)
In command form, EViews will create an untitled group from the listed series, and then
display the covariance matrix view for that group.
When used as a matrix view, cov displays the covariance among the columns of the
matrix.
Options
Examples
group grp1 height weight age
grp1.cov
Cross-references
See also cor (p. 169), @cor (p. 383), and @cov (p. 384).
174Chapter
174 8. Command Reference
create Command
Syntax
Command: create optional_name frequency start end
You may provide an optional name for your workfile. If you do not, EViews will create an
untitled workfile.
You must specify the frequency, and the starting and ending dates of your data. For
undated data, you should specify the starting and ending observation numbers.
Options
You must choose one of the following options to specify the frequency of your workfile:
a Annual
s Semi-annual
q Quarterly
m Monthly
w Weekly
d Daily (5 day week)
7 Daily (7 day week)
u Undated or irregular
Examples
create a 1880 90
Creates a weekly workfile from the week starting February 10, 1951 to the week starting
March 17, 1994.
cross175
175
create u 1 5000
Cross-references
See Creating a Workfile on page 34 of the Users Guide and Appendix B of the Users
Guide for a discussion of frequencies and rules for composing dates in EViews.
See workfile (p. 365) for a more general command which allows you to either create a
workfile or change the active workfile.
Cross correlations.
Syntax
Command: cross(n,options) ser1 ser2
Group View: group_name.cross(n,options)
You must specify, as an option, the number of lags n to compute the cross correlations as
an option. In command form, EViews will create an untitled group and display the cross
correlation view for the group. When used as a group view, cross correlations will be com-
puted for the first two series in the group.
Options
The number of lags n for which to compute the cross correlations must be specified as the
first option. The following options may be specified inside the parentheses after the num-
ber of lags:
Examples
cross(36) log(m1) dlog(cpi)
displays the cross correlogram between the log of M1 and the first difference of the log of
CPI up to 36 leads and lags.
equation eq1.arch sp500 c
eq1.makeresid(s) res_std
cross(24) res_std^2 res_std
176Chapter
176 8. Command Reference
The first line estimates a GARCH(1,1) model and the second line retrieves the standardized
residuals. The third line plots the cross correlogram up to 24 leads and lags between the
squared standardized residual and the standardized residual. This correlogram provides a
rough check of asymmetry in ARCH effects.
Cross-references
See Cross Correlations and Correlograms on page 214 of the Users Guide for discussion.
data Command
Syntax
Command: data ser1 ser2 group1 group2
Follow the data keyword by a list of series names and/or a list of group names. You can
list existing names or new names. Unrecognized names will cause new series to be added
to the workfile. These series will be initialized with the value NA.
Examples
data group1 newx newy
opens a group window containing the series in group GROUP1 and the series NEWX and
NEWY.
Cross-references
See Entering Data on page 64 of the Users Guide for a discussion of the process of enter-
ing data from the keyboard.
dates sets options that are specific to appearance of time/date labeling. Many of the
options that also affect the appearance of the date axis are set by the scale (p. 300) com-
mand with the b option. These options include most tick control, label and font options,
and grid lines.
dates177
177
Syntax
Graph Proc: graph_name.dates option list
Options
Examples
graph1.dates format(yyyy:mm)
will display dates with four-digit years followed by the default delimiter : and a two-digit
month (e.g. 1974:04).
graph1.dates format(yy:mm, q)
will display a two-digit year followed by a q separator and then a two-digit month(e.g.
74:04)
graph1.interval(y, 2, 1951)
Cross-references
See Chapter 10 of the Users Guide for a discussion of graph options.
db Command
If the specified database does not exist, a new (empty) database will be created and
opened. The opened database will become the default database.
Syntax
Command: db db_name
Follow the db command by the name of the database to be opened or to be created (if it
does not already exist). You can include a path name to work with a database not in the
default path.
Options
See dbopen (p. 181) for a list of available options for working with foreign format data-
bases.
Examples
db findat
opens the database FINDAT in the default path and makes it the default database from
which to store and fetch objects. If the database FINDAT does not already exist, an empty
database named FINDAT will be created and opened.
dbcreate179
179
Cross-references
See Chapter 6 of the Users Guide for a discussion of EViews databases.
dbcopy Command
Syntax
Command: dbcopy source_name copy_name
Follow the dbcopy command by the name of the existing database and a name for the
copy. You should include a path name to copy a database that is not in the default direc-
tory. All files associated with the database will be copied.
Examples
dbcopy usdat c:\backup\usdat
makes a copy of all files associated with the database USDAT in the default path and stores
it in the C:\BACKUP directory under the name USDAT.
Cross-references
See Chapter 6 of the Users Guide for a discussion of EViews databases.
dbcreate Command
Syntax
Command: dbcreate db_name
Follow the dbcreate keyword by a name for the new database. You can include a path
name to create a database not in the default directory. The new database will become the
default database.
180Chapter
180 8. Command Reference
Examples
dbcreate macrodat
creates a new database named MACRODAT in the default path and makes it the default
database from which to store and fetch objects. This command will issue an error message
if a database named MACRODAT already exists. To open an existing database, use
dbopen or db.
Options
See dbopen (p. 181) for available options for working with foreign format databases.
Cross-references
See Chapter 6 of the Users Guide for a discussion of EViews databases.
dbdelete Command
Syntax
Command: dbdelete db_name
Follow the dbdelete keyword by the name of the database to be deleted. You can include
a path name to delete a database not in the default path.
Options
See dbopen (p. 181) for available options for working with foreign format databases.
Examples
dbdelete c:\temp\testdat
deletes all files associated with the TESTDAT database in the specified directory.
Cross-references
See Chapter 6 of the Users Guide for a discussion of EViews databases.
dbopen Command
Syntax
Command: dbopen db_name
Follow the dbopen keyword with the name of a database. You should include a path name
to open a database not in the default path. The opened database will become the default
database.
Examples
dbopen c:\data\us1
dbopen us1
If the specified database does not exist, EViews will issue an error message. You should use
db or dbcreate to create a new database.
Options
To read a foreign format database, you must specify one of the following database types:
s=server_ id
u=username
p=password
Cross-references
See Chapter 6 of the Users Guide for a discussion of EViews databases.
dbpack Command
Syntax
Command: dbpack db_name
Follow the dbpack keyword by a database name. You can include a path name to pack a
database not in the default path.
Examples
dbpack findat
Cross-references
See Packing the Database on page 134 of the Users Guide for additional discussion.
dbrebuild Command
Syntax
Command: dbrebuild source_name dest_name
Follow the dbrebuild keyword by the name of the database to be rebuilt, and then a new
database name.
Examples
If you issue the command
dbrebuild testdat fixed_testdat
EViews will attempt to rebuild the database TESTDAT into the database FIXED_TESTDAT
in the default directory.
dbrepair183
183
Cross-references
Note that dbrepair may be able to repair the existing database if the damage is not par-
ticularly serious. You should attempt to repair the database before rebuilding. See Main-
taining the Database on page 133 of the Users Guide for a discussion.
dbrename Command
Syntax
Command: dbrename old_name new_name
Follow the dbrename keyword with the current name of an existing database and the new
name for the database.
Options
See dbopen (p. 181) for available options for working with foreign format databases.
Examples
dbrename testdat mydat
Renames all files associated with the TESTDAT database in the specified directory to
MYDAT in the default directory.
Cross-references
See Chapter 6 of the Users Guide for a discussion of EViews databases.
See also db (p. 178) and dbcreate (p. 179). See also dbcopy (p. 179) and dbdelete
(p. 180).
dbrepair Command
Syntax
Command: dbrepair db_name
Follow the dbrepair keyword by the name of the database to repair. You should include a
path name to repair a database not in the default path.
Examples
dbrepair testdat
EViews will attempt to repair the database TESTDAT in the default directory.
Cross-references
If the database is severely damaged, you may have to rebuild it into a new database using
the dbrebuild command. See Maintaining the Database on page 133 of the Users
Guide for a discussion of EViews database maintenance.
Syntax
Var View: var_name.decomp(n, options) series_list @ @ ordering
List the series names in the var whose variance decomposition you would like to compute.
You may optionally specify the ordering of the var to use in the variance decomposition
after two @-signs.
Options
You must specify the number of periods n over which to compute the variance decomposi-
tions as the first option. In addition, there are the following options:
Examples
var var1.ls 1 4 m1 gdp cpi
var1.decomp(10,t) gdp
The first line declares and estimates a var with three variables and lags from1 to 4. The
second line tabulates the variance decompositions of GDP up to 10 periods using the order-
ing as specified in VAR1.
Cross-references
See Variance Decomposition on page 511 of the Users Guide for additional details.
Syntax
Pool View: pool_name.define id1 id2 id3
Examples
pool spot uk japn ger can
spot.def uk ger ita fra
The first line declares a pool object named SPOT with cross section identifiers UK, JAPN,
GER, and CAN. The second line redefines the identifiers to be UK, GER, ITA, and FRA.
Cross-references
See Chapter 21 of the Users Guide for a discussion of cross-section identifiers.
See also add (p. 135), drop (p. 193) and pool (p. 277).
186Chapter
186 8. Command Reference
Syntax
Command: delete name1 name2
Pool Proc: pool_name.delete ser1? ser2?
Follow the delete keyword by a list of the names of any objects you wish to remove from
the current workfile. delete does not remove objects that have been stored on disk in
EViews database files.
You can delete an object from a database by prefixing the name with the database name
and a double colon. You can use a pattern to delete all objects from a workfile or database
with names that match the pattern. Use the ? to match any one character and the * to
match zero or more characters.
When used as a pool procedure, delete allows you to delete series from the workfile using
the pool operator ?.
If you use delete in a program file, EViews will delete the listed objects without prompt-
ing you to confirm each deletion.
Examples
To delete all objects in the workfile with names beginning with temp:
delete temp*
To delete the objects CONS and INVEST from the database MACRO1:
To delete all series in the workfile with names beginning with CPI that are followed by
identifiers in the pool object MYPOOL.
mypool.delete cpi?
Cross-references
See Object Basics on page 41 of the Users Guide for a discussion of working with
objects, and Chapter 6 of the Users Guide for a discussion of EViews databases.
derivs187
187
Display information about the derivatives of the equation specification in tabular, graphical
or summary form.
The (default) summary form shows information about how the derivative of the equation
specification was computed, and will display the analytic expression for the derivative, or
a note indicating that the derivative was computed numerically. The tabular form shows a
spreadsheet view of the derivatives of the regression specification with respect to each
coefficient for each observation. The graphical form shows this information in a multiple
line graph.
Syntax
Equation View: equation_name.derivs(options)
Options
Note that the g and t options may not be used at the same time.
Examples
To show a table view of the derivatives:
eq1.derivs(t)
Cross-references
See Derivative Computation Options on page 652 of the Users Guide for details on the
computation of derivatives.
188Chapter
188 8. Command Reference
See also makederivs (p. 244) for additional routines for examining derivatives, and
grads (p. 218), and makegrads (p. 246) for corresponding routines for gradients.
.
Syntax
Pool View: pool_name.describe(options) ser1? ser2
List the name of pool series for which to compute the descriptive statistics. You may use
the cross-section identifier ? in the series names.
By default, statistics are computed for each pool series, on the stacked data, using only
observations where all of the listed series have nonmissing data. A missing observation in
any one series causes that observation to be dropped for all series. You may change this
default treatment of NAs using the i and b options.
EViews also allows you to compute statistics with the cross-section means removed, statis-
tics for each cross-sectional series in a pool series, and statistics for each period, taken
across all cross-section units.
Options
Examples
pool1.describe(m) gdp? inv? cpi?
displays the within descriptive statistics of the three series GDP, INV, CPI for the POOL1
cross-section members.
pool1.describe(t) gdp?
computes the statistics for GDP for each period, taken across each of the cross-section
identifiers.
Cross-references
See Chapter 21 of the Users Guide for a discussion of the computation of these statistics,
and a description of individual and balanced samples.
Attaches a display name to an object which may be used in tables and graphs in place of
the standard object name.
Syntax
Object Proc: object_name.displayname display_name
Display names are case-sensitive, and may contain a variety of characters, such as spaces,
that are not allowed in object names.
Examples
hrs.displayname Hours Worked
hrs.label
The first line attaches a display name Hours Worked to the object HRS and the second
line displays the label view of HRS, including its display name.
gdp.displayname US Gross Domestic Product
plot gdp
The first line attaches a display name US Gross Domestic Product to the series GDP. The
line graph view of GDP from the second line will use the display name as the legend.
190Chapter
190 8. Command Reference
Cross-references
See Labeling Objects on page 50 of the Users Guide for a discussion of labels and display
names.
do Command
Syntax
Command: do procedure
do is most useful in EViews programs where you wish to run a series of commands with-
out opening windows in the workfile area.
Examples
output(t) c:\result\junk1
do gdp.adf(c,4,p)
The first line redirects table output to a file on disk. The second line carries out a unit root
test of GDP and prints the results to the disk file.
Cross-references
See also show (p. 317).
Syntax
Graph Proc: graph_name.draw(object_type, axis_id [,options]) position1
[position2]
If drawing a line, the drawing position is taken from position1. If drawing a shaded area,
you must provide a position1 and position2 to define the vertical or horizontal boundaries
of the shaded region.
Options
rgb(n1,n2,n3) where n1, n2, and n3, are integers from 0 to 255 repre-
senting the RGB values of the line or shade. The default
is black for lines and gray for shades. RGB values may
be examined by calling up the color palette in the Graph
Options dialog.
width(n1) where n1 is the line width in points (used only if
object_type is line or dashline). The default is 0.5
points
p print the graph object
Examples
The command
graph1.draw(line, left, rgb(0,0,127)) 5.25
draws a horizontal blue line at the value 5.25 as measured on the left axis while
draws a shaded horizontal region bounded by the right axis values 7.1 and 9.7. You
can also draw vertical regions by using the bottom axis_id:
graph1.draw(shade, bottom) 1980:1 1990:2
draws a shaded vertical region bounded by the dates 1980:1 and 1990:2.
192Chapter
192 8. Command Reference
Cross-references
See Chapter 10 of the Users Guide for a discussion of graph options.
See also Graph (p. 27) for a summary of the graph object command language.
driconvert Command
Convert the entire DRI Basic Economics database into an existing EViews database.
You must create an EViews database to store the converted DRI data before you use this
command. This command may be very time-consuming.
Syntax
Command: driconvert db_name
Follow the command by listing the name of an existing EViews database into which you
would like to copy the DRI data. You can include a path name to specify a database not in
the default path.
Examples
dbcreate dribasic
driconvert dribasic
driconvert c:\mydata\dridbase
The first line creates a new (empty) database named DRIBASIC in the default directory.
The second line reads all the data in the DRI Basic Economics database and copies them
into in the DRIBASIC database. The last example copies the DRI data into the database
DRIDBASE that is located in the C:\MYDATA directory.
Cross-references
See Chapter 6 of the Users Guide for a discussion of EViews databases.
Syntax
Group Proc: group_name.drop ser1 ser2 ser3
Pool Proc: pool_
_name.drop id1 id2 id3
List the series or cross-section members to be dropped from the group or pool.
Examples
group gdplags gdp(-1 to -4)
gdplags.drop gdp(-4) gdp(-3)
drops the two series GDP(-4) and GDP(-3) from the group GDPLAGS.
To drop the cross-section members JPN, KOR, and HK from the pool CROSSSC
crossc.drop jpn kor hk
Cross-references
See also add (p. 135).
This group view is designed to make tables for reporting and presenting data, forecasts,
and simulation results. You can display various transformations and various frequencies of
the data in the same table.
The dtable view is currently available only for annual, semi-annual, quarterly, or
monthly workfiles.
Syntax
Group View: group_name.table(options)
Options
Examples
freeze(report) group1.table
freezes the default table view of GROUP1 and saves it as a table object named REPORT.
Cross-references
See Creating and Specifying a Dated Data Table on page 195 of the Users Guide for a
description of dated data tables and formatting options. Note that most of the options for
formatting the table are only available interactively from the window.
ec Var Method
Syntax
Var Method: var_name.ec(trend, n) lag_pairs y1 y2
var_name.ec(trend, n) lag_pairs y1 y2 @ x1 x2
var_name.ec(trend, n) lag_pairs y1 y2
Specify the order of the VEC by entering one or more pairs of lag intervals, then list the
endogenous variables. Note that the lag orders are those of the first differences, not the lev-
els. If you are comparing results to another software program, you should be certain that
the specifications for the lag orders are comparable.
You may include exogenous variables, such as seasonal dummies, in the VEC by including
an @-sign followed by the list of series. Do not include an intercept or trend in the VEC
specification, these terms should be specified using options, as described below.
You must specify the trend option and the number of cointegrating equations n to use
(default is n=1) in parentheses, separated by a comma. You must choose the trend from
the following five alternatives:
Options
Examples
var macro1.ec 1 4 m1 gdp tb3
declares a var object MACRO1 and estimates a VEC with four lagged first differences, three
endogenous variables and one cointegrating equation using the default trend option c.
var term.ec(b,2) 1 2 4 4 tb1 tb3 tb6 @ d2 d3 d4
declares a var object TERM and estimates a VEC with lagged first differences of order 1, 2,
4, three endogenous variables, three exogenous variables, and two cointegrating equations
using trend option b.
Cross-references
See Vector Error Correction (VEC) Models on page 528 of the Users Guide for a discus-
sion of VECs.
Syntax
Object View: object_name.endog(options)
196Chapter
196 8. Command Reference
Options
Examples
sys1.endog(g,p)
Cross-references
See also makeendog (p. 244), system (p. 344), sspace (p. 329) and var (p. 360).
Syntax
Command: equation eq_name
Command: equation eq_name.method(options) specification
Follow the equation keyword with a name and an optional specification. If you wish to
enter the specification, you should follow the new equation name with a period, an esti-
mation method, and then the equation specification. Valid estimation methods are arch,
binary, censored, count, gmm, ls, ordered, and tsls.
Examples
equation cobdoug.ls log(y) c log(k) log(l)
The command
equation ces.ls log(y)=c(1)*log(k^c(2)+l^c(3))
declares an equation object named CES containing a nonlinear least squares specification.
equation demand.tsls q c p x @ x p(-1) gov
creates an equation object named DEMAND and estimates DEMAND using two-stage least
squares with instruments X, lagged P, and GOV.
errbar197
197
Cross-references
See the object reference entry for Equation (p. 23) for a summary of the equation object.
Chapter 11 of the Users Guide provides basic information on estimation and equation
objects. Additional estimation methods are described in the Users Guide.
Lists the equations in the model allowing you to access the equation specifications. This
view also allows you to identify which equations are entered by text, or by link.
Syntax
Model View: model_name.eqs
Cross-references
See Equation View on page 602 of the Users Guide for details. See Chapter 23 of the
Users Guide for a general discussion of models.
See also block (p. 152), text (p. 353), and vars (p. 361) for alternative representations
of the model.
errbar Coef View | Graph Proc | Group View | Matrix View | Sym View
Sets the graph type to error bar or displays an error bar view of the group. If there are two
series in the graph or group, the error bar will show the high and low values in the bar.
The optional third series will be plotted as a symbol. When used as a matrix view, the col-
umns of the matrix replace the series.
Syntax
Graph Proc: graph_name.errbar(options)
Object View: object_name.errbar(options)
198Chapter
198 8. Command Reference
Options
Template and printing options
Examples
The following set of commands
group g1 x y
g1.errbar
displays the error bar view of G1 using the X series as the high value of the bar and the Y
series as the low value.
group g2 plus2se minus2se estimate
g2.errbar
displays the error bar view of G2 with the PLUS2SE series as the high value of the bar, the
MINUS2SE series as the low value, and ESTIMATE as a symbol.
group g1 x y
freeze(graph1) g1.line
graph1.errbar
first creates a graph object GRAPH1 containing a line graph of the series in G1, then
changes the graph type to an error bar.
Cross-references
See High-Low (Open-Close) on page 205 of the Users Guide. See Chapter 10 for details
on graph objects and types.
exit Command
You will be prompted to save objects and workfiles which have changed since the last time
they were saved to disk. Be sure to save your workfile, if desired, since all changes that you
do not save to a disk file will be lost.
Syntax
Command: exit
Cross-references
See also close (p. 161) and save (p. 299).
Syntax
Model Proc: model_name.exclude(options) ser1(smpl) ser2(smpl) ...
Follow the exclude keyword with the argument list containing the endogenous variables
you wish to exclude from the solution along with an optional sample for exclusion. If a
sample is not provided, the variable will be excluded for the entire solution sample.
Options
Examples
mod1.exclude fedfunds govexp("1990:01 1995:02")
will create an exclude list containing the variables FEDFUNDS and GOVEXP. FEDFUNDS
will be excluded for the entire solution sample, while GOVEXP will only be excluded for
the specified sample.
EViews will replace the original exclude list with one containing only GOVEXP. To add
excludes to an existing list, use the m option:
mod1.exclude(m) fedfunds
Cross-references
See the discussion in Specifying Scenarios on page 607 of the Users Guide.
See also model (p. 262), override (p. 273) and solveopt (p. 324).
expand Command
Expands the current workfile (range) by setting new start and end dates or number of
observations.
Syntax
Command: expand start end
Follow the expand keyword with the new starting and ending dates or observations. The
new starting point cannot be later than the current starting point and the new ending point
cannot be earlier than the current ending point.
The range (p. 282) command may be used for more general workfile resizing which also
allows for contracting.
Examples
workfile mywork m 1957:1 1995:12
expand 1945:1 2020:12
The first line creates a monthly workfile from January 1957 to December 1995. The second
line expands the workfile to start from January 1945 and to end at December 2020.
workfile cps88 u 1 5000
expand 1 50000
Creates an undated workfile with 5000 observations and then expands it to 50000 observa-
tions.
smpl 1945 1995
equation eq1.ls y c y(-1) ma(1)
expand 1945 2010
smpl 1996 2010
fetch201
201
eq1.forecast yhat
The first two lines estimate a model of Y over the period 1945 to 1995. The third line
expands the workfile to 2010. We then generate dynamic forecasts of Y for the period 1996
to 2010, using the estimated model.
Cross-references
See Workfile Basics on page 33 of the Users Guide for a discussion of workfiles.
See also range (p. 282), workfile (p. 365), smpl (p. 322).
fetch reads one or more objects from EViews databases or databank files into the active
workfile. The objects are loaded into the workfile under the same name as in the database
or with the databank file name.
When used as a pool proc, EViews will first expand the list of series using the pool opera-
tor, and then perform the fetch.
If you fetch a series into a workfile with a different frequency, EViews will automatically
apply the frequency conversion method attached to the series by setconvert. If the
series does not have a conversion method set by setconvert, EViews will use the
method set by Options/Date-Frequency in the main menu. You can override the conver-
sion method by explicitly specifying a conversion method option in the fetch command.
Syntax
Command: fetch(options) object_name_list
Pool Proc: pool_name.fetch(options) ser1? ser2?
The fetch command keyword is followed by a list of object names separated by spaces.
The default behavior is to fetch the objects from the default database. (This is a change
from versions of EViews prior to EViews 3.x where the default was to fetch from individual
databank files).
You can precede the object name with a database name and the double colon :: to indi-
cate a specific database source. If you specify the database name as an option in parenthe-
ses (see below), all objects without an explicit database prefix will be fetched from the
specified database.
202Chapter
202 8. Command Reference
You may use wild card characters, ? (to match a single character) or * (to match zero
or more characters), in the object name list. All objects with names matching the pattern
will be fetched.
You can optionally fetch from individual databank files or search among registered data-
bases. To fetch from individual databank files that are not in the default path, you should
include an explicit path. If you have more than one object with the same file name (for
example, an equation and a series named CONS), then you should supply the full object
file name.
Options
The database specified by the double colon :: takes precedence over the database speci-
fied by the d= option.
In addition, there are a number of additional options for controlling automatic frequency
conversion when performing a fetch. For details and a complete list of frequency conver-
sion options, see copy (p. 166).
Examples
To fetch M1, GDP, UNEMP from the default database, use:
fetch m1 gdp unemp
To fetch M1 and GDP from the US1 database and UNEMP from the MACRO database, use
the command:
You can fetch all objects with names starting with SP by searching all registered databases
in the search order. The c=f option uses the first (nonmissing) observation to convert
the frequency of any matching series with a higher frequency than the workfile frequency:
fetch(d,c=f) sp*
You can fetch M1 and UNEMP from individual databank files using:
fetch(i) m1 c:\data\unemp
To fetch all objects with names starting with CONS from the two databases USDAT and
UKDAT:
fill203
203
The command
fetch a?income
will fetch all series beginning with the letter a, followed by any single character, and
ending with the string income.
Cross-references
See Chapter 6 of the Users Guide for a discussion of databases, databank files, and fre-
quency conversion. Chapter 4 of the Users Guide discusses importing data. Appendix C of
the Users Guide describes the use of wildcard characters.
See also setconvert (p. 311), store (p. 337), and copy (p. 166).
fill Coef Proc | Matrix Proc | Series Proc | Sym Proc | Vector Proc
fill can be used to set values of series, vectors and matrices in programs.
Syntax
Series Proc: series_name.fill(options) n1, n2, n3
Coef, Vector Proc: vector_name.fill(options) n1, n2, n3
Matrix, Sym Proc: matrix_name.fill(options) n1, n2, n3
Follow the fill keyword with a list of values to place in the specified object. Each value
should be separated by a comma. By default, series fill ignores the current sample and
fills the series from the beginning of the workfile range. You may specify sample informa-
tion using options.
Running out of values before the object is completely filled is not an error; the remaining
cells or observations will be unaffected. If, however, you list more values than the object
can hold, EViews will not modify any of the observations and will return an error message.
204Chapter
204 8. Command Reference
Options
Options for series fill
Examples
To generate a series D70 that takes the value 1, 2, and 3 for all observations from 1970:1:
series d70=0
d70.fill(o=1970:1,l) 1,2,3
Note that the last argument in the fill command above is the letter l. The next three lines
generate a dummy series D70S that takes the value one and two for observations from
1970:1 to 1979:4:
series d70s=0
smpl 1970:1 1979:4
d70s.fill(s,l) 1,2
smpl @all
Assuming a quarterly workfile, the following generates a dummy variable for observations
in either the third and fourth quarter:
series d34
fiml205
205
d34.fill(l) 0, 0, 1, 1
Note that this series could more easily be generated using @seas.
The following example declares a four element coefficient vector MC, initially filled with
zeros. The second line fills MC with the specified values and the third line replaces from
row 3 to the last row with 1.
coef(4) mc
mc.fill 0.1, 0.2, 0.5, 0.5
mc.fill(o=3,l) -1
The commands
matrix(2,2) m1
matrix(2,2) m2
m1.fill 1, 0, 1, 2
m2.fill(b=r) 1, 0, 1, 2
m1 = 1 1 , m2 = 1 0 (8.1)
0 2 1 2
Cross-references
See Chapter 4, Matrix Language, on page 53 of the Command and Programming Refer-
ence for a detailed discussion of vector and matrix manipulation in EViews.
Syntax
System Method: system_name.fiml(options)
206Chapter
206 8. Command Reference
Options
Examples
sys1.fiml
Cross-references
See Chapter 19 of the Users Guide for a discussion of systems in EViews.
fit207
207
When the regressor contains lagged dependent values or ARMA terms, fit uses the actual
values of the dependent variable instead of the lagged fitted values. You may instruct fit
to compare the forecasted data to actual data, and to compute forecast summary statistics.
Not available for equations estimated using ordered methodsuse model instead.
Syntax
Command: fit(options) yhat y_se
Equation Proc: eq_name.fit(options) yhat y_se
ARCH Proc: eq_name.fit(options) yhat y_se y_var
Following the fit keyword you should type a name for the forecast series and, optionally,
a name for the series containing the standard errors and, for ARCH specifications, a name
for the conditional variance series.
Forecast standard errors are currently not available for binary, censored, and count models.
Options
Examples
equation eq1.ls cons c cons(-1) inc inc(-1)
eq1.fit c_hat c_se
genr c_up=c_hat+2*c_se
genr c_low=c_hat-2*c_se
208Chapter
208 8. Command Reference
The first line estimates a linear regression of CONS on a constant, CONS lagged once, INC,
and INC lagged once. The second line stores the static forecasts and their standard errors
as C_HAT and C_SE. The third and fourth lines compute the upper and lower bounds of
the 95% forecast interval (assuming a normal distribution). The fifth line plots the actual
series together with the 95% forecast interval.
equation eq2.binary(d=l) y c wage edu
eq2.fit yf
eq2.fit(I) xbeta
genr yhat=1-@clogit(-xbeta)
The first line estimates a logit of Y on a constant, WAGE, and EDU. The second line com-
putes the fitted probabilities, and the third line computes the fitted values of the index. The
fourth line computes the probabilities from the fitted index using the cumulative distribu-
tion function of the logistic distribution. Note that YF and YHAT should be identical.
Note that you cannot fit values from an ordered model. You must instead solve the values
from a model. The following lines generate fitted probabilities from an ordered model:
equation eq3.ordered y c x z
eq3.model(oprob1)
solve oprob1
The first line estimates an ordered probit of Y on a constant, X, and Z. The second line
makes a model from the estimated equation with a name OPROB1. The third line solves
the model and computes the fitted probabilities that each observation falls in each cate-
gory.
Cross-references
See Chapter 14 of the Users Guide for a discussion of forecasting in EViews. See
Chapter 17 of the Users Guide for forecasting from binary, censored, truncated, and count
models. See Forecasting on page 562 of the Users Guide for a discussion of forecasting
from sspace models.
To perform dynamic forecasting, use forecast (p. 209). See model (p. 262) and solve
(p. 323) for forecasting from systems of equations or ordered equations.
forecast209
209
Dynamic forecast.
forecast computes the forecast for all observations in a specified sample. In some set-
tings, you may instruct forecast to compare the forecasted data to actual data, and to
compute summary statistics.
Syntax
Command: forecast(options) yhat y_se
Equation Proc: eq_name.forecast(options) yhat y_se
ARCH Proc: eq_name.forecast(options) yhat y_se y_var
Sspace Proc: ss_name.forecast(options) keyword1 names1 [keyword2 names2]
[keyword3 names3] ...
When used with an equation, you should type a name for the forecast series and, option-
ally, a name for the series containing the standard errors and, for ARCH specifications, a
name for the conditional variance series. Forecast standard errors are currently not avail-
able for binary or censored models. forecast is not available for models estimated using
ordered methods.
When used with a sspace, you should enter a type-keyword followed by a list of names for
the target series or a wildcard expression, and if desired, additional type-keyword/target
pairs. The following are valid keywords: @state, @statese, @signal, @signalse.
The first two instruct EViews to forecast the state series and the values of the state stan-
dard error series. The latter two instruct EViews to forecast the signal series and the values
of the signal standard error series.
If a list is used to identify the targets in sspace forecasting, the number of target series
must match the number of names implied by the keyword. Note that wildcard expressions
may not be used for forecasting signal variables that contain expressions. The * wildcard
expression may not be used for forecasting signal variables since this would overwrite the
original data.
210Chapter
210 8. Command Reference
Options
Options for Equation forecasting
Examples
The following lines
smpl 1970:1 1990:4
equation eq1.ls con c con(-1) inc
smpl 1991:1 1995:4
eq1.fit con_s
eq1.forecast con_d
plot con_s con_d
freeze211
211
estimate a linear regression over the period 1970:11990:4, compute static and dynamic
forecasts for the period 1991:11995:4, and plots the two forecasts in the same graph
equation eq1.ls m1 gdp ar(1) ma(1)
eq1.forecast m1_bj bj_se
eq1.forecast(s) m1_s s_se
plot bj_se s_se
Estimates an ARMA(1,1) model, computes the forecasts and standard errors with and
without the ARMA terms, and plots the two forecast standard errors.
The following command performs n-step forecasting of the signals and states from the
sspace object, SS1:
Here we save the state forecasts in the names specified in the sspace object, and we save
the two signal forecasts in the series Y1F and Y2F.
Cross-references
For more information on equation forecasting in EViews, see Chapter 14 of the Users
Guide. Details on forecasting for specialized techniques are provided in the corresponding
chapters of the Users Guide. For additional discussion of wildcards, see Appendix C,
Wildcards, on page 639 of the Users Guide.
To perform static forecasting with equation objects see fit (p. 207). For multiple equation
forecasting, see model (p. 262), and solve (p. 323).
freeze Command
Syntax
Command: freeze(name) object.view
If you follow the keyword freeze with an object name but no view of the object, freeze
will use the default view for the object. You can provide a name for the object containing
the frozen view in parentheses.
Examples
The command
212Chapter
212 8. Command Reference
freeze gdp.uroot(4,t)
creates an untitled table that contains the results of the unit root test of the series GDP.
group rates tb1 tb3 tb6
freeze(gra1) rates.line(m)
show gra1.align(2,1,1)
freezes a graph named GRA1 that contains multiple line graphs of the series in the group
RATES, realigns the individual graphs, and displays the resulting graph.
freeze(mygra) gra1 gra3 gra4
show mygra.align(2,1,1)
creates a graph object named MYGRA that combines three graph objects GRA1, GRA2, and
GRA3, and displays MYGRA in two columns.
Cross-references
See Object Commands on page 7, and Object Basics on page 41 of the Users Guide for
further discussion of objects and views of objects. Freezing views is also described in
Chapter 10 of the Users Guide.
When used as a series view (or for a group containing a single series), freq performs a
one-way frequency tabulation. The options allow you to control binning (grouping) of
observations.
When used with a group containing multiple series, freq produces an N-way frequency
tabulation for all of the series in the group.
Syntax
Object View: object_name.freq(options)
Options
Options common to both one-way and N-way frequency tables
Examples
hrs.freq(nov,noa)
tabulates each value (no binning) of HRS in ascending order with counts, percentages, and
cumulatives.
inc.freq(v=20,b=10,noa)
tabulates INC excluding NAs. The observations will be binned if INC has more than 20 dis-
tinct values; EViews will create at most 10 equal width bins. The number of bins may be
smaller than specified.
group labor lwage gender race
labor.freq(v=10,norowm,nocolm)
Cross-references
See Chapters 7 and 8 of the Users Guide for a discussion of frequency tables.
Syntax
Equation View: eq_name.garch(options)
Options
Examples
equation eq1.arch sp500 c
eq1.garch
estimates a GARCH(1,1) model and displays the estimated conditional standard deviation
graph.
Cross-references
ARCH estimation is described in Chapter 16 of the Users Guide.
This procedure allows you to generate multiple series using the cross-section identifiers in
a pool. To generate values for a single series, see series (p. 307).
Syntax
Pool Proc: pool_name.genr ser_name = expression
You may use the cross section identifier ? in the series name and/or in the expression on
the right-hand side.
Examples
The commands
pool pool1
pool1.add 1 2 3
pool1.genr y? = x? - @mean(x?)
Similarly,
pool pool2
pool2.add us uk can
pool2.genr y_? = log(x_?)-log(x_us)
216Chapter
216 8. Command Reference
generates three series Y_US, Y_UK, Y_CAN that are the log differences from X_US. Note
that Y_US=0.
The pool genr command simply loops across the cross-section identifiers, performing the
appropriate substitution. Thus, the command
pool2.genr z=y_?
is equivalent to entering
series z=y_us
series z=y_uk
series z=y_can
so that the ordinary series Z will contain Y_CAN, the last series associated with the Y_?.
Cross-references
See Chapter 21 of the Users Guide for a discussion of the computation of pools, and a
description of individual and balanced samples.
See series (p. 307) for a discussion of the expressions allowed in genr.
Syntax
Command: gmm(options) y x1 x2 @ z1 z2 z3
gmm(options) formula @ z1 z2 z3
Equation Method: eq_name.gmm(options) y x1 x2 @ z1 z2 z3
eq_name.gmm(options) formula @ z1 z2 z3
System Method: system_name.gmm(options)
To use gmm as a command or equation method, follow the name of the dependent variable
by a list of regressors, an @-sign, and a list of instrumental variables which are orthogo-
nal to the residuals. Alternatively, you can specify a (nonlinear) formula using coefficients,
an @-sign, and a list of instrumental variables which are orthogonal to the formula.
There must be at least as many instrumental variables as there are coefficients to estimate.
gmm217
217
Options
Examples
sys1.gmm(b=a,q,i)
estimates SYS1 by GMM with a quadratic kernel, Andrews automatic bandwidth selection,
and iterates until convergence.
Cross-references
See Users Guide, Chapters 12 and 19 for discussion of GMM estimation.
Displays the gradients of the objective function (where available) for objects containing an
estimated equation or equations.
The (default) summary form shows the value of the gradient vector at the estimated
parameter values (if valid estimates exist) or at the current coefficient values. This latter
usage makes grads useful in examining the behavior of the objective function at starting
values. The tabular form shows a spreadsheet view of the gradients for each observation.
The graphical form shows this information in a multiple line graph.
Syntax
Object View: object_name.grads(options)
graph219
219
Options
Examples
To show a summary view of the gradients:
eq1.grads
eq1.grads(t, p)
Cross-references
See also derivs (p. 187), makederivs (p. 244), and makegrads (p. 246).
May also be used to merge multiple graphs into a single graph object using the merge
proc.
Syntax
Command: graph name.type(options) ser1 ser2 ser3
Command: graph name.merge graph1 graph2 graph3
Follow the graph keyword with a name for the graph, a period, a type of the graph, and a
list of series or group names to graph.
The second form of the graph command combines two or more existing graph objects into
a named multiple graph object. Follow the graph keyword with a name for the graph, a
period, the merge keyword, and a list of named graph objects to be merged.
220Chapter
220 8. Command Reference
Options
The valid types of a graph object are:
Additional options will depend on the type of graph chosen. See the entry for each graph
type for a list of the available options (e.g. see bar (p. 149) for details on bar graphs).
Additional Options
Examples
graph gra1.line(m) gdp m1 inf
creates a multiple graph object named MYGRA that combines three graph objects named
GR_LINE, GR_SCAT, and GR_PIE.
Cross-references
The graph object is described in greater detail in Graph (p. 27). See Chapter 10 of the
Users Guide for a general discussion of graphs.
Syntax
Command: group group_name ser1 ser2 ser3
Follow the group name with a list of series to be included in the group.
Examples
group g1 gdp cpi inv
group g1 tb3 m1 gov
g1.add gdp cpi
The first line creates a group named G1 that contains three series GDP, CPI, and INV. The
second line redeclares group G1 to contain the three series TB3, M1, and GOV. The third
line adds two series GDP and CPI to group G1 to make a total of five series. See add
(p. 135).
group rhs d1 d2 d3 d4 gdp(0 to -4)
ls cons rhs
ls cons c rhs(6)
The first line creates a group named RHS that contains nine series. The second line runs a
linear regression of CONS on the nine series in RHS. The third line runs a linear regression
of CONS on C and only the sixth series GDP(-1) of RHS.
Cross-references
See Group on page 28 for a complete description of the group object. See also Chapter 8
of the Users Guide for additional discussion.
hconvert Command
Syntax
Command: hconvert path_haver db_name
You must have a Haver Analytics database installed on your computer to use this feature.
You must also create an EViews database to store the converted Haver data before you use
this command.
222Chapter
222 8. Command Reference
Follow the command by a full path name to the Haver database and the name of an exist-
ing EViews database to store the Haver database. You can include a path name to the
EViews database not in the default path.
Examples
dbcreate hdata
hconvert d:\haver\haver hdata
The first line creates a new (empty) database named HDATA in the default directory. The
second line converts all the data in the Haver database and stores it in the HDATA data-
base.
Cross-references
See Chapter 6 of the Users Guide for a discussion of EViews and Haver databases.
See also dbcreate (p. 179), db (p. 178), hfetch (p. 222) and hlabel (p. 225).
hfetch Command
hfetch reads one or more series from a Haver Analytics Database into the active workfile.
You must have a Haver Analytics database installed on your computer to use this feature.
Syntax
Command: hfetch(database_name) series_name
hfetch, if issued alone on a command line, will bring up a Haver dialog box which has
fields for entering both the database name and the series names to be fetched. If you pro-
vide the database name (including the full path) in parentheses after the hfetch command,
EViews will read the database and copy the series requested into the current workfile. It
will also display information about the series on the statusline. The database name is
optional if a default database has been specified.
hfetch can read multiple series with a single command. List the series names, each sepa-
rated by a space.
hilo223
223
Examples
hfetch(c:\data\us1) pop gdp xyz
reads the series POP, GDP, and XYZ from the US1 database into the current active workfile,
performing frequency conversions if necessary.
Cross-references
Additional information on EViews frequency conversion is provided in Frequency Conver-
sion on page 72 of the Users Guide. See also Chapter 6 of the Users Guide for a discus-
sion of EViews and Haver databases.
See also dbcreate (p. 179), db (p. 178), hconvert (p. 221) and hlabel (p. 225).
hilo Command || Graph Proc | Group View | Matrix View | Sym View
Syntax
Command: hilo(options) high_ser low_ser [close_ser]
hilo(options) high_ser low_ser open_ser close_ser
Graph Proc: graph_name.hilo(options)
Object View: object_name.hilo(options)
For a high-low, or a high-low-close graph, follow the command name with the name of the
high series, followed by the low series, and an optional close series. If four series names
are provided, EViews will use them in the following order: high-low-open-close.
When used with a matrix or group or an existing graph, EViews will use the first series as
the high series, the second series as the low series, and if present, the third series as the
close. If there are four or more series, EViews will use them in the following order: high-
low-open-close. When used as a matrix view, the columns of the matrix are used in place
of the series.
Note that if you wish to display a high-low-open graph, you should use an NA-series for
the close values.
224Chapter
224 8. Command Reference
Options
Template and printing options
Examples
hilo mshigh mslow
The command
The command
Cross-references
See Chapter 10 of the Users Guide for additional details on using graphs in EViews.
When used as a command or a series view, hist computes descriptive statistics and dis-
plays a histogram for the series. When used as an equation view, hist displays a histo-
gram and descriptive statistics of the residual series.
hlabel225
225
Syntax
Command: hist(options) series_name
Object View: object_name.hist(options)
Options
Examples
lwage.hist
Cross-references
See Histogram and Stats on page 152 of the Users Guide for a discussion of the descrip-
tive statistics reported in the histogram view.
hlabel Command
hlabel reads the description of a series from a Haver Analytics Database and displays it
on the status line at the bottom of the EViews window. Use this command to verify the
contents of a Haver database series name.
You must have a Haver Analytics database installed on your computer to use this feature.
Syntax
Command: hlabel(database_name) series_name
hlabel, if issued alone on a command line, will bring up a Haver dialog box which has
fields for entering both the database name and the series names to be examined. If you
provide the database name in parentheses after the hlabel command, EViews will read the
database and find the key information about the series in question, such as the start date,
end date, frequency, and description. This information is displayed in the status line at the
bottom of the EViews window. Note that the database_name should refer to the full path
to the Haver database but need not be specified if a default database has been specified in
HAVERDIR.INI.
If several series names are placed on the line, hlabel will gather the information about
each of them, but the information display may scroll by so fast that only the last will be
visible.
226Chapter
226 8. Command Reference
Examples
hlabel(c:\data\us1) pop
Cross-references
See Chapter 6 of the Users Guide for a discussion of EViews and Haver databases.
Syntax
Command: hpf(n, options) series_name filtered_name
Series Proc: series_name.hpf(n, options) filtered_name
Follow the hpf keyword with the name of the series you want to filter and a name for the
filtered series.
When used as a series procedure, hpf smooths the series without displaying the graph of
the smoothed series.
Options
Examples
The command
hpf(1000) gdp gdp_hp
smooths the GDP series with a smoothing parameter 1000 and saves the smoothed series
as GDP_HP.
Cross-references
See Hodrick-Prescott Filter on page 189 of the Users Guide for details.
impulse227
227
Syntax
Var View: var_name.impulse(n, options) responses @ shocks @ ordering
List the series names in the var whose responses you would like to compute. By default,
EViews computes the responses to all possible sources of shocks using the ordering in the
var.
You may optionally specify the sources of shocks and the ordering of the var. To specify the
shocks, list the shocks series after an @. To specify the ordering, list the order of the
series after a second @.
Options
You must specify the number of periods n, for which you wish to compute the impulse
responses.
Other options
Examples
var var1.ls 1 4 m1 gdp cpi
var1.impulse(10,m) gdp @ m1 gdp cpi
The first line declares and estimates a var with three variables. The second line displays
multiple graphs of the impulse responses of GDP to shocks to the three series in the var
using the ordering as specified in VAR1.
displays the impulse response of GDP to a one standard deviation shock in M1 using a dif-
ferent ordering.
228Chapter
228 8. Command Reference
Cross-references
See Chapter 20 of the Users Guide for a discussion of variance decompositions in VARs.
Syntax
Var View: var_name.jbera(options)
Options
The name= option stores the following matrix. Let the VAR have k endogenous vari-
ables. Then the stored matrix will have dimension (k+1) ´ 4. The first k rows contain sta-
tistics for each orthogonal component, where the 1st column is the third moments, the 2nd
column is the one-degree of freedom chi-square statistics for the third moments, the 3rd
2
column is the fourth moments, and the 4th column is the one-degree of freedom  statis-
tics for the fourth moments. The sum of the 2nd and 4th columns are the Jarque-Bera sta-
tistics reported in the last output table.
The (k + 1) row contains statistics for the joint test. The 2nd and 4th column of the
(k + 1) row is simply the sum of all the rows above in the corresponding column and are
kdensity229
229
2
the  ( k ) statistics for the joint skewness and kurtosis tests, respectively. These joint
skewness and kurtosis statistics add up to the joint Jarque-Bera statistic reported in the
output table, except for the factor=cov option. When this option is set, the joint Jarque-
Bera statistic includes all cross moments (in addition to the pure third and fourth
moments). The overall Jarque-Bera statistic for this option is stored in the 1st column of
the ( k + 1) row (which will be a missing value for all other options).
Examples
var var1.ls 1 6 lgdp lm1 lcpi
show var1.jbera(factor=cor,name=jb)
The first line declares and estimates a VAR. The second line carries out the residual multi-
variate normality test using the inverse square root of the residual correlation matrix as the
factorization matrix and stores the results in a matrix named JB.
Cross-references
See Chapter 20 of the Users Guide for a discussion of the test and other VAR diagnostics.
Kernel density plots. Displays nonparametric kernel density estimates of the specified
series.
Syntax
Series View: series_name.kdensity(options)
Options
Examples
lwage.kdensity(k=n)
plots the kernel density estimate of LWAGE using a normal kernel and the automatic band-
width selection.
Cross-references
See Kernel Density on page 221 of the Users Guide for a discussion of kernel density
estimation.
Fits a kernel regression of the second series in the group (vertical axis) against the first
series in the group (horizontal axis).
Syntax
Group View: group_name.kerfit(options)
Options
Examples
group gg weight height
gg.kerfit(s=w_fit, 200)
Fits a kernel regression of HEIGHT on WEIGHT using 200 points and saves the fitted series
as W_FIT.
Cross-references
See Scatter with Kernel Fit on page 230 of the Users Guide for a discussion of kernel
regression.
Display or change the label view of the object, including the last modified date and dis-
play name (if any).
Syntax
Object View: object_name.label
Object Proc: object_name.label(options) text
Options
To modify the label, you should specify one of the following options along with optional
text. If there is no text provided, the specified field will be cleared:
Examples
The following lines replace the remarks field of LWAGE with Data from CPS 1988 March
File:
lwage.label(r)
lwage.label(r) Data from CPS 1988 March File
To append additional remarks to LWAGE, and then to print the label view:
lwage.label(r) Log of hourly wage
lwage.label(p)
Cross-references
See Labeling Objects on page 50 of the Users Guide for a discussion of labels.
Syntax
Var View: var_name.laglen(m, options)
Options
vname=arg Save selected lag orders in named vector. See below for a
description of the stored vector.
mname=arg Save lag order criteria in named matrix. See below for a
description of the stored matrix.
p Print table of lag order criteria.
The vname= option stores a vector with 5 rows containing the selected lags from the
following criteria: sequential modified LR test (row 1), final prediction error (row 2),
Akaike information criterion (row 3), Schwarz information criterion (row 4), Hannan-
Quinn information criterion (row 5).
legend233
233
Examples
var var1.ls 1 6 lgdp lm1 lcpi
show var1.laglen(12,vname=v1)
The first line declares and estimates a VAR. The second line computes the lag length crite-
ria up to a maximum of 12 lags and stores the selected lag orders in a vector named V1.
Cross-references
See Chapter 20 of the Users Guide for a discussion of the various criteria and other VAR
diagnostics.
When legend is used with a multiple graph, the legend settings apply to all graphs. See
setelem (p. 313) for setting legends for individual graphs in a multiple graph.
Syntax
Graph Proc: graph_name.legend option_list
Note: the syntax of the legend proc has changed considerably from version 3.1 of EViews.
While not documented here, the EViews 3 options are still (for the most part) supported.
However, we do not recommend using the old options as future support is not guaranteed.
Options
Examples
mygra1.legend display position(l) inbox
places the legend of MYGRA1 within the graph, indented slightly from the upper left cor-
ner with no box surrounding the legend text.
Cross-references
See Chapter 10 of the Users Guide for a discussion of graph objects in EViews.
The line graph view of a group plots all series in the group in a single graph. The line
graph view of a matrix plots each column in the matrix in a single graph.
line235
235
Syntax
Command: line(options) object_name
Object View: object_name.line(options)
Graph Proc: graph_name.line(options)
Options
Template and printing options
Scale options (for multiple line views of group and matrix objects)
Examples
group g1 gdp cons m1
g1.line(d)
plots line graphs of the three series in group G1 with dual scaling (no crossing). The latter
two series will share the same scale.
matrix1.line(t=mygra)
displays line graphs of the columns of MATRIX1 using the graph object MYGRA as a tem-
plate.
creates an untitled graph object that contains three line graphs of GDP, CONS, and M1,
with each plotted separately.
236Chapter
236 8. Command Reference
Cross-references
See Chapter 10 of the Users Guide for a detailed discussion of graphs in EViews.
Displays the scatter plot of the second series (horizontal axis) and the first series (vertical
axis) with a regression fit line. You can specify various transformation methods and
weighting for the bivariate fit.
Syntax
Group View: group_name.linefit(options)
Options
If the polynomial degree of x leads to singularities in the regression, EViews will automati-
cally drop the high order terms to avoid collinearity.
load237
237
Examples
group g1 inf unemp
g1.linefit(yl,xl,s=yfit)
displays a scatter plot of log UNEMP against log INF together with the fitted values from a
regression of log UNEMP on the log INF. The fitted values are saved in a series named
YFIT. Note that the saved fitted values are for the original UNEMP, not the log transform.
g1.linefit(yb=0.5,m=10)
The Box-Cox transformation of UNEMP with parameter 0.5 is regressed on INF with 10
iterations of bisquare weights.
Cross-references
See Scatter with Regression on page 226 of the Users Guide for a discussion of scatter
plot with regression fit.
load Command
The workfile becomes the active workfile; existing workfiles in memory remain on the
desktop but become inactive.
Syntax
Command: load(options) workfile_name
Options
Examples
load c:\data\marco
loads a previously saved EViews workfile MACRO.WF1 from the DATA directory in the C
drive.
238Chapter
238 8. Command Reference
load c:\tsp\nipa.wf
loads a MicroTSP workfile NIPA.WF. If you do not use the workfile type option, you should
add the extension .WF to the workfile name when loading a DOS MicroTSP workfile. An
alternative method uses the type d option:
load(d) nipa
Cross-references
See Workfile Basics on page 33 of the Users Guide for a discussion of workfile opera-
tions. Chapter 4 of the Users Guide describes various methods of moving data into
EViews.
See also open (p. 267), save (p. 299), read (p. 283) and fetch (p. 201)
logit Command
Syntax
Command: logl logl_name
Options
Examples
logl ll1
specifies the likelihood function for LL1 and estimates the parameters by maximum likeli-
hood.
Cross-references
See Chapter 18 of the Users Guide for further examples of the use of the likelihood object.
When used as a pool proc, ls estimates linear cross-section weighed least squares, and
fixed and random effects models.
Syntax
Command: ls(options) y x1 x2 x3
ls(options) y=c(1)*x1+c(2)*x2+c(3)*x3
Equation Method: eq_name.ls(options) [specification]
System Method: system_name.ls(options)
VAR Method: var_name.ls(options)
Pool Method: pool_name.ls(options) y x1 x2 @ z1 z2
For linear specifications, list the dependent variable first, followed by a list of the indepen-
dent variables. Use a C if you wish to include a constant or intercept term; unlike some
other programs, EViews does not automatically include a constant in the regression. You
may add AR, MA, SAR and SMA error specifications and PDL specifications for polynomial
distributed lags. If you include lagged variables, EViews will adjust the sample automati-
cally, if necessary.
Both dependent and independent variables may be created from existing series using stan-
dard EViews functions and transformations. EViews treats the equation as linear in each of
the variables and assigns coefficients C(1), C(2), and so forth to each variable in the list.
Linear or nonlinear single equations can also be specified by explicit equation. You should
specify the equation as a formula. The parameters to be estimated should be called C(1),
C(2), and so forth (assuming that you wish to use the default coefficient vector C).
You may also declare an alternative coefficient vector using coef and use these coeffi-
cients in your expressions.
240Chapter
240 8. Command Reference
For equation and var objects, you can declare and estimate the object in a single com-
mand. Follow the declaration of the object type with the name of the new object, then the
ls keyword, separated by a period.
When used as a pool method, ls carries out panel data estimation. Type the name of the
dependent variable followed by one or two lists of regressors. The first list should contain
ordinary and pool series that are restricted to have the same coefficient across all members
of the pool. The second list, if provided, should contain variables that have different coeffi-
cients for each member of the pool. If there is a second list, the two lists must be separated
by an @-sign.
For pool estimation, you may include AR terms as regressors (except when estimating ran-
dom effects models using the r option) but not MA terms.
Options
Options for Equation, System, LogL, Sspace, and Var estimation
Note: not all options are available for all methods. See the Users Guide for details on each
estimation method.
Options for pool estimation
n No intercept.
f Fixed effect estimation (separate intercept for each
cross section member).
r Random effects estimation.
w Weighted least squares, with weights estimated in pre-
liminary regression using equal weights. Not available
with the r option.
s SUR (seemingly unrelated regression), with covariance
matrix of pool members estimated in preliminary
regression and then applied in generalized least squares
in a second round. Not available with the r option.
i Iterate to convergence (default if AR terms are
included).
h White heteroskedasticity consistent standard errors.
b Estimate using a balanced sample.
p Print estimation results.
Examples
equation eq1.ls m1 c uemp inf(0 to -4) @trend(1960:1)
regresses the first difference of TBILL on a constant, INF, a seasonal dummy, and an inter-
action of the dummy and INF with an MA(2) error term. The z option turns off backcast-
ing.
coef(2) beta
param beta(1) .2 beta(2) .5 c(1) 0.1
equation eq3.ls(h) q = beta(1)+beta(2)*(l^c(1) + k^(1-c(1)))
estimates the nonlinear regression starting from the specified initial values. The h option
reports heteroskedasticity consistent standard errors.
equation eq4.ls r=c(1)+c(2)*r(-1)+div(-1)^c(3)
sym betacov=eq4.@cov
declares and estimates a nonlinear equation and stores the coefficient covariance matrix in
a symmetric matrix called BETACOV.
pool1.ls dy? inv? edu? year
estimates a fixed effects model without restricting any of the coefficients to be the same
across pool members.
group rhs c dum1 dum2 dum3 dum4
ls cons rhs ar(1)
uses the group definition for RHS to regress CONS on C, DUM1, DUM2, DUM3, and DUM4
with an AR(1) correction.
Cross-references
Chapters 11 and 12 of the Users Guide discuss the various regression methods in greater
depth. See Chapter 21 of the Users Guide for a discussion of pool estimation.
See Equation (p. 23), Pool (p. 35), System (p. 45), and Var (p. 48) for a complete
description of these objects, including a list of saved results.
See ar (p. 142), ma (p. 243), sar (p. 298), sma (p. 319), and pdl (p. 274) for terms that
may be used in ls specifications.
makecoint243
243
ma Expression
Examples
ls(z) m1 c tb3 tb3(-1) ma(1) ma(2)
regresses M1 on a constant, TB3, and TB3 lagged once with first order and second order
moving average error components. The z option turns off backcasting in estimation.
Cross-references
See Chapter 13 of the Users Guide for details on ARMA and seasonal ARMA modeling.
See also sma (p. 319), ar (p. 142), and sar (p. 298).
Syntax
Var Proc: var_name.makecoint
Var Proc: var_name.makecoint group_name
From the command window, the first form creates an untitled group object containing the
estimated cointegrating relations in the VEC. The second form allows you to name the
group object by following the makecoint proc with a name to be given to the group. The
series contained in the group are named COINTEQ01, COINTEQ02, and so on. In batch
mode (program files), the first form simply creates the series COINTEQ01, COINTEQ02,
and so on.
This proc will return an error message unless you have estimated an error correction
model with the var object.
Examples
var vec1.ec(b,2) 1 4 y1 y2 y3
vec1.makecoint gcoint
244Chapter
244 8. Command Reference
The first line estimates a VEC with 2 cointegrating relations. The second line creates a
group named GCOINT which contains the two estimated cointegrating relations. The two
cointegrating relations will be stored as series named COINTEQ01 and COINTEQ02 if these
names have not yet been used in the workfile. If these names are already used, the next
unused number will be appended to the prefix COINTEQ and will be used to name the
series.
Cross-references
See Chapter 20 of the Users Guide for details.
Make a group containing individual series which hold the derivatives of the equation
specification.
Syntax
Equation Proc: equation_name.grads(options) [names]
If desired, enclose the name of the group object to contain the series in parentheses follow-
ing the command name.
The argument specifying the names of the series is also optional. If not provided, EViews
will name the series DERIV## where ## is a number such that DERIV## is the next
available unused name. If the names are provided, the number of names must match the
number of target series.
Cross-references
See Chapter 22 of the Users Guide for details on state space estimation.
See also derivs (p. 187), grads (p. 218), makegrads (p. 246).
Syntax
Object Proc: object_name.makeendog name
Following the keyword makeendog, you should provide a name for the group to hold the
endogenous series. If you do not provide a name, EViews will create an untitled group.
makegarch245
245
Examples
var1.makeendog grp_v1
creates a group named GRP_V1 that contains the endogenous series in VAR1.
Cross-references
See also endog (p. 195) and makegroup (p. 248).
Creates a new sspace object with all estimated parameter values substituted out of the
specification. This procedure allows you to use the structure of the sspace without refer-
ence to estimated coefficients or the estimation sample.
Syntax
Sspace Proc: sspace_name.makefilter(filter_name)
If you provide a name for the model in parentheses after the keyword, EViews will quietly
create the named model in the workfile. If you do not provide a name, EViews will open an
untitled model window if the command is executed from the command line.
Examples
ss1.makefilter(kfilter)
creates a new sspace object named KFILTER, containing the specification in SS1 with esti-
mated parameter values substituted for coef elements.
Cross-references
See Chapter 22 of the Users Guide for details on state space models.
makegarch saves the estimated conditional variance (from an equation estimated using
ARCH) as a named series.
246Chapter
246 8. Command Reference
Syntax
Equation Proc: eq_name.makegarch name
Following the makegarch keyword you should provide a name for the saved series. If you
do not provide a name, EViews will name the series GARCH1 (if GARCH1 already exists, it
will be named GARCH2, and so on).
Examples
equation eq1.arch sp c
eq1.makegarch cvar
plot cvar^.5
estimates a GARCH(1,1) model, saves the conditional variance as a series named CVAR,
and plots the conditional standard deviation. If you only want to view a plot of the condi-
tional standard deviation use the garch view.
Cross-references
See Chapter 16 of the Users Guide for a discussion of GARCH models.
See also arch (p. 143) archtest (p. 145) and garch (p. 214).
Make a group containing individual series which hold the gradients of the objective func-
tion.
Syntax
Object Proc: object_name.makegrads(options) [names]
The argument specifying the names of the series is also optional. If the argument is not
provided, EViews will name the series GRAD## where ## is a number such that
GRAD## is the next available unused name. If the names are provided, the number of
names must match the number of target series.
Options
Examples
eq1.grads(n=out)
creates a group named OUT containing series named GRAD1, GRAD2, and GRAD3.
makegraph247
247
eq1.grads(n=out) g1 g2 g3
creates the same group, but names the series G1, G2 and G3.
Cross-references
See also derivs (p. 187), makederivs (p. 244), grads (p. 218).
Syntax
Model Proc: model_name.makegraph(options) graph_name model_vars
where graph_name is the name of the resulting graph object, and models_vars are the
names of the series.
Options
a include actuals.
c include comparison scenarios.
d include deviations.
n do not include active scenario (by default the
active scenario is included).
t= t=leveldisplay levels in graph (default).
transformation_type
t=pchdisplay percent change in graph.
t=pchadisplay percent change (annual rates)
in graph.
t=pchydisplay 1-year percent change in graph.
t=difdisplay 1-period differences in graph.
t=difydisplay 1-year differences in graph.
s=solution_type s=ddeterministic.
s=mmean of stochastic.
s=smean and ±2 std. dev. of stochastic.
248Chapter
248 8. Command Reference
Examples
mod1.makegraph(a) gr1 y1 y2 y3
creates a graph containing the model series Y1, Y2, and Y3 in the active scenario and the
actual Y1, Y2, and Y3.
mod1.makegraph(a,t=pchy) gr1 y1 y2 y3
plots the same graph, but with data displayed as 1-year percent changes.
Cross-references
See Displaying Data on page 623 of the Users Guide for details. See Chapter 23 of the
Users Guide for a general discussion of models.
Make group out of pool and ordinary series using a pool object or make group out of
model series and display dated data table.
Syntax
Pool Proc: pool_name.makegroup(group_name) name1 name2
Model Proc: model_name.makegroup(options) group_name model_vars
When used as a pool proc, following the makegroup keyword, you should provide a name
for the new group, and then list the ordinary and pool series to be placed in the group.
When used as a model proc, the makegroup keyword should be followed by any options,
the name of the destination group, and the list of model variables to be created. The
options control the choice of model series, and transformation and grouping features of the
resulting dated data table view.
makegroup249
249
Options
For Model Proc
a include actuals
c include comparison scenarios
d include deviations
n do not include active scenario (by default the
active scenario is included)
t= t=leveldisplay levels in graph (default)
transformation_type
t=pchdisplay percent change in graph
t=pchadisplay percent change (annual rates)
in graph
t=pchydisplay 1-year percent change in graph
t=difdisplay 1-period differences in graph
t=difydisplay 1-year differences in graph
s=solution_type s=ddeterministic
s=mmean of stochastic
s=smean and std. dev. of stochastic
s=bmean and confidence bounds of stochastic
g=grouping g=vgroup series in table by model variable
(default)
g=sgroup series in table by scenario
Examples
pool1.makegroup(g1) x? z y?
places the ordinary series Z, and all of the series represented by the pool series X? and Y?,
in the group G1.
Cross-references
See Displaying Data on page 623 of the Users Guide for details. See Chapter 23 of the
Users Guide for a general discussion of models.
makelimits creates a vector of the estimated limit points from equations estimated by
ordered.
Syntax
Equation Proc: eq_name.makelimits name
Provide a name for the vector after the makelimit keyword. If you do not provide a
name, EViews will name the vector LIMITS1 (if LIMITS1 already exists, it will be named
LIMITS2, and so on).
Examples
equation eq1.ordered edu c age race gender
eq1.makelimit cutoff
Estimates an ordered probit and saves the estimated limit points in a vector named CUT-
OFF.
Cross-references
See Ordered Dependent Variable Models on page 422 of the Users Guide for a discussion
of ordered models.
Equation Proc | Logl Proc | Pool Proc | Sspace Proc | System Proc |
makemodel Var Proc
Syntax
Object Proc: object_name.makemodel(name) assign_statement
You should enter the name of the object, followed by a dot and the keyword makemodel.
If you provide a name for the model in parentheses after the keyword, EViews will quietly
create the named model in the workfile. If you do not provide a name, EViews will open an
untitled model window if the command is executed from the command line.
Examples
var var3.ls 1 4 m1 gdp tb3
makeresids251
251
var3.makemodel(varmod) @prefix s_
estimates a VAR and makes a model named VARMOD from the estimated var object. VAR-
MOD includes an assignment statement assign @prefix s_. Use the command show var-
mod or varmod.spec to open the VARMOD window.
Cross-references
See Chapter 23 of the Users Guide for a discussion of specifying and solving models in
EViews.
See also append (p. 141), merge (p. 260) and solve (p. 323). For sspace objects, see
makefilter (p. 245).
Creates a group containing the dependent and independent variables from an equation
specification.
Syntax
Equation Proc: equation_name.makeregs name
Examples
equation eq1.ls y c x1 x2 x3 z
eq1.makeregs reggroup
Cross-references
See also group (p. 221) and equation (p. 196).
Creates and saves residuals in the workfile from an object with estimated equation or
equations.
252Chapter
252 8. Command Reference
Syntax
Equation Proc: equation_name.makeresids(options) res1
Object Proc: object_name.makeresids res1 res2 res3
Pool Proc: pool_name.makeresids poleaxed
Follow the object name with a period and the makeresid keyword and a list of names to
be given to the stored residuals. For pool residuals, you may use a cross section identifier
?.
For multiple equation objects, make sure to provide as many names as there are equations.
If there are fewer names than equations, EViews creates the extra residual series with
names RESID01, RESID02, and so on. If you do not provide any names, EViews will also
name the residuals RESID01, RESID02, and so on.
[NOTE: makeresids is no longer supported for the sspace object see makesignals
(p. 253) for relevant replacement routines]
Options
The following options are available only for the residuals from single equation objects:
Examples
equation eq1.ls y c m1 inf unemp
eq1.makeresids res_eq1
estimates a linear regression of Y on a constant, M1, INF, UNEMP and saves the residuals
as a series named RES_EQ1.
var macro_var.ls 1 4 y m1 r
macro_var.makeresids resay res_m1 riser
estimates an unrestricted VAR with four lags and endogenous variables Y, M1, R and stores
the residuals as RES_Y, RES_M1, RES_R.
equation probit1.binary y c x z
makesignals253
253
probit1.makeresids(g) res_g
series score1=res_g
series score2=res_g*x
series score3=res_g*z
pool1.makeresids res1_?
The residuals of each pool member will have a name starting with RES1_ and the cross-
section identifier substituted for the ?.
Cross-references
See Weighted Least Squares on page 271 of the Users Guide for a discussion of standard-
ized residuals after weighted least squares and Chapter 17 of the Users Guide for a discus-
sion of standardized and generalized residuals in binary, ordered, censored, and count
models.
Generate signal series or signal standard error series from an estimated sspace object.
Options allow you to choose to generate one-step ahead and smoothed values for the sig-
nals, and the signal standard errors.
Syntax
Sspace Proc: name.makesignals (options) [names]
Follow the object name with a period and the makesignal keyword, options to determine
the output type, and a list of names or wildcard expression identifying the series to hold
the output. If a list is used to identify the targets, the number of target series must match
the number of states implied in the sspace. If any signal variable contain expressions, you
may not use wildcard expressions in the destination names.
Options
Examples
ss1.makesignals(t=smooth) sm*
produces smoothed signals in the series with names beginning with sm, and ending with
the name of the signal dependent variable.
creates a group named PRED_SIGS which contains the one-step ahead signal predictions in
series SIG1, SIG2, and SIG3.
Cross-references
See Chapter 22 of the Users Guide for details on state space models. For additional discus-
sion of wildcards, see Appendix C, Wildcards, on page 639 of the Users Guide.
See also forecast (p. 209), makefilter (p. 245) and makestates (p. 254).
Generate state series or state standard error series from an estimated sspace object.
Options allow you to choose to generate one-step ahead, filtered, and smoothed values for
the states, and the state standard errors.
makestates255
255
Syntax
Sspace Proc: name.makestates (options) [names]
Follow the object name with a period and the makestate keyword, options to determine
the output type, and a list of names or wildcard expression identifying the series to hold
the output. If a list is used to identify the targets, the number of target series must match
the number of names implied by the keyword.
Options
Examples
ss1.makestates(t=smooth) sm*
produces smoothed states in the series with names beginning with sm, and ending with
the name of the state dependent variable.
creates a group named PRED_STATES which contains the one-step ahead state predictions
in series SIG1, SIG2, and SIG3.
256Chapter
256 8. Command Reference
Cross-references
See Chapter 22 of the Users Guide for details on state space models. For additional discus-
sion of wildcards, see Appendix C, Wildcards, on page 639 of the Users Guide.
See also forecast (p. 209), makefilter (p. 245) and makesignals (p. 253).
Creates and saves series of descriptive statistics computed from a pool object.
Syntax
Pool Proc: pool_name.makestats(options) ser1? ser2? @ stat_name
Follow the object name with a period, the makestat command, a list of series names, the
@-sign, and a list of command names for the statistics to compute. The statistics series
will have a name with the cross-section identifier ? replaced by the statistic command.
Options
Options in parentheses specify the sample to use to compute the statistics
Examples
pool1.makestats gdp_? edu_? @ mean sd
computes the mean and standard deviation of the GDP_? and EDU_? series in each period
across the cross-section members using the default common sample. The mean and stan-
dard deviation series will be named GDP_MEAN, EDU_MEAN, GDP_SD, EDU_SD.
Computes the maximum and minimum values of the GDP_? series in each period using the
balanced sample. The max and min series will be named GDP_MAX and GDP_MIN.
Cross-references
See Chapter 21 of the Users Guide for details on the computation of these statistics and a
discussion of the use of individual, common, and balanced samples in pool.
Syntax
Pool Proc: pool_name.makesystem(options) ser1? ser2? @ ser3? @ ser4?
Var Proc: var_name.makesystem(options)
The first usage creates a system out of the pool specification. You can specify the treatment
of the constant term and the name of the system as options in parentheses. Follow the
dependent variable with a list of regressors; first list the regressors with common coeffi-
cients, then list the regressors with cross-section specific coefficients, separating the two
lists with an @- sign. You can use the cross-section identifier ? in the series name. You
may also list a set of instrumental variables after a second @-sign. Note that you can
always modify the specification in the system specification window.
The second form is used to create a system out of the current var specification. You may
specify to order by series (default) or by lags.
Options
Options for Pools:
n no intercept.
c (default) common intercept term.
258Chapter
258 8. Command Reference
Examples
pool1.makesystem(sys1) inv? cap? @ val?
creates a system named SYS1 with INV? as the dependent variable and a common intercept
for each cross-section member. The regressor CAP? is restricted to have the same coeffi-
cient in each equation, while the VAL? regressor has a different coefficient in each equa-
tion.
This command creates a system named SYS2 with INV? as the dependent variable and a
different intercept for each cross-section member equation. The regressor CAP? enters each
equation with a different coefficient and each equation has two instrumental variables
@TREND and INV? lagged.
Cross-references
See Chapter 19 of the Users Guide for a discussion of system objects in EViews.
Syntax
Command: matrix(r, c) matrix_name
Command: matrix(r, c) matrix_name=assignment
The matrix keyword is followed by the name you wish to give the matrix. matrix also
takes an optional argument specifying the row r and column c dimension of the matrix.
You can combine matrix declaration and assignment. If there is no assignment statement,
the matrix will initially be filled with zeros.
means259
259
Once declared, matrices may be resized by repeating the matrix command using the orig-
inal name.
Examples
matrix mom
matrix(3,6) coefs
Cross-references
See Chapter 4, Matrix Language, beginning on page 53 of the Command and Program-
ming Reference for further discussion.
See Matrix (p. 32), Rowvector (p. 38) and Vector (p. 51) and Sym (p. 44) for full
descriptions of the various matrix objects.
Syntax
Equation View: eq_name.means(options)
Options
Examples
equation eq1.binary(d=l) work c edu faminc
eq1.means
estimates a logit and displays the descriptive statistics of the regressors C, EDU, FAMINC
for WORK=0 and WORK=1.
260Chapter
260 8. Command Reference
Cross-references
See Chapter 17 of the Users Guide for a discussion of binary dependent variable models.
Merge objects. When used as a model procedure, merges equations from an estimated
equation, model, pool, system, or var object. When used as a graph procedure, merges
graph objects.
If you supply only the object's name, EViews first searches the current workfile for the
object containing the equation. If it is not there, EViews looks in the default directory for
an equation or pool file (.DBE). If you want to merge the equations from a system file
(.DBS), a var file (.DBV), or a model file (.DBL), include the extension in the command.
You may include a path when merging files. You must merge objects to a model one at a
time; merge appends the object to the equations already existing in the model.
When used as a graph procedure, merge combines graph objects into a single graph
object. The graph objects to merge must exist in the current workfile.
Syntax
Model Proc: model_name.merge(options) object_name
Graph Proc: graph name.merge graph1 graph2
For merge as a model procedure, follow the merge keyword with a name of an object con-
taining estimated equation(s) to merge.
For merge as a graph procedure, follow the graph command with a name for the new
merged graph, the merge keyword, and a list of existing graph object names to merge.
Options
Examples
eq1.makemodel(mod1)
mod1.merge eq2
mod1.merge(t) c:\data\test.txt
The first line makes a model named MOD1 from EQ1. The second line merges (appends)
EQ2 to MOD1 and the third line further merges (appends) the text file TEST from the spec-
ified directory.
ml261
261
The first line merges the four graphs GRA1, GRA2, GRA3, GRA4 into a graph named
MYGRA. The second line displays the four graphs in MYGRA in a single row.
Cross-references
See Chapter 10 of the Users Guide for a discussion of graphs.
Syntax
Graph Proc: graph_name.metafile(options) name
Follow the metafile keyword with a name for the metafile. The graph will be saved with
a .WMF extension.
Options
Examples
mygra1.metafile c:\report\chap1_1
Cross-references
See Chapter 10 of the Users Guide for a discussion of using graphs in other Windows pro-
grams.
Syntax
Object Method: object_name.ml (options)
262Chapter
262 8. Command Reference
Options
Examples
bvar.ml
Cross-references
See Chapters 18 and 22 of the Users Guide for a discussion of user specified likelihood and
state space models.
Syntax
Command: model model_name
Object Proc: object_name.model(name) assign_statement
The keyword model should be followed by a name for the model. To fill the model, you
can use the append command.
Examples
model macro
macro.append cs=10+0.8*y(-1)
macro.append i=0.7*(y(-1)-y(-2))
macro.append y=cs+i+g
declares an empty model named MACRO and adds three lines to MACRO.
na263
263
Cross-references
See Chapter 23 of the Users Guide for a discussion of specifying and solving models in
EViews.
See also append (p. 141), merge (p. 260) and solve (p. 323).
Show view containing messages generated by the most recent model solution.
Syntax
Model View: model_name.msg(options)
Options
Cross-references
See Chapter 23 of the Users Guide for a discussion of specifying and solving models in
EViews.
na Expression
Examples
smpl if y >= 0
series z = y
smpl if y < 0
z = na
generates a series Z containing the contents of Y, but with all negative values of Y set to
NA.
y = log(y)
will replace all positive value of Y with log(Y) and all negative values with NA.
series test = (yt <> na)
creates the series TEST which takes the value one for nonmissing observations of the
series YT. A zero value of TEST indicates missing values of the series YT.
Note that the behavior of missing values has changed since EViews Version 2. Previously,
NA values were coded as 1e-37. This implied that in EViews 2 you could use the expres-
sion
to return the value of Y for non-negative values of Y and NA for negative values of Y.
This expression will now generate the value NA for all values of Y, since mathematical
expressions involving missing values always return NA. You must now use the smpl
statement as in the first example above, or the @recode function.
Cross-references
See Missing Data on page 92 of the Users Guide for a discussion of working with miss-
ing values in EViews.
name allows you to provide an alternative to the series name for legends or axis labels. The
name command is available only for single graphs and will be ignored in multiple graphs.
Syntax
Graph Proc: graph_name.name(n) text_for_legend
Provide a series number in parentheses and text for legend (or axis label) after the name
keyword. If you do not provide text, the series name will be removed from the legend/axis
label.
Examples
graph g1.line(d) unemp gdp
g1.name(1) Civilian unemployment rate
g1.name(2) Gross National Product
nnfit265
265
The first line creates a line graph named G1 with dual scale, no crossing. The second line
replaces the legend of the first series UNEMP, and the third line replaces the legend of the
second series GDP.
graph g2.scat id w h
g2.name(1)
g2.name(2) weight
g2.name(3) height
g2.legend(l)
The first line creates a scatter diagram named G2. The second line removes the legend of
the horizontal axis, and the third and fourth lines replace the legends of the variables on
the vertical axis. The last line moves the legend to the left side of the graph.
Cross-references
See Chapter 10 of the Users Guide for a discussion of working with graphs.
Displays the fit of the second series (vertical axis) on the first series (horizontal axis) in the
group.
Syntax
Group View: group_name.nnfit(options)
Options
Examples
group gr1 gdp90 gdp50
gr1.nnfit(x,m=3)
displays the nearest neighbor fit of GDP50 on GDP90 with exact (full) sampling and 3
robustness iterations. Each local regression fits the default linear regression with tricube
weighting using a bandwidth of span 0.3.
group gro1 weight height
gro1.nnfit(50,d=2,m=3)
displays the nearest neighbor fit of HEIGHT on WEIGHT by fitting approximately 50 data
points. Each local regression fits a quadratic using tricube robustness weights with 3 itera-
tions.
Cross-references
See Scatter with Nearest Neighbor Fit on page 227 of the Users Guide for a discussion of
nearest neighbor regressions.
nrnd Expression
When used in a series expression, nrnd generates (pseudo) random draws from a normal
distribution with zero mean and unit variance.
Examples
smpl @first @first
series y = 0
smpl @first+1 @last
series y = .6*y(-1)+.5*nrnd
open267
267
generates a Y series that follows an AR(1) process with initial value zero. The innovations
are normally distributed with mean zero and standard deviation 0.5.
series u = 10+@sqr(3)*nrnd
series z = u+.5*u(-1)
generates a Z series that follows an MA(1) process. The innovations are normally distrib-
uted with mean 10 and variance 3.
series x = nrnd^2+nrnd^2+nrnd^2
generates an X series as the sum of squares of three independent standard normal random
2
variables, which has a  ( 3 ) distribution. Note that adding the sum of the three series is
not the same as issuing the command
series x=3*nrnd^2
The command
series x=@qchisq(rnd,3)
2
provides an alternative method of simulating random draws from a  ( 3 ) distribution.
Cross-references
See Statistical Distribution Functions on page 426 for a list of other random number gen-
erating functions from various distributions.
See also rnd (p. 294), rndint (p. 294) and rndseed (p. 295).
open Command
You should provide the file name including its extension. File names with the extensions
.WF and .WF1 are processed as workfiles, .PRG files are treated as program files, and any-
thing else is considered a text file. By default, open will look in the current directory
unless an explicit path is provided.
Syntax
Command: open file_name
268Chapter
268 8. Command Reference
Examples
open finfile.wf1
open c:\prog\test1.prg
Cross-references
See Chapter 4 of the Users Guide for a discussion of basic file operations.
See also load (p. 237), fetch (p. 201), read (p. 283).
Allows you to change the option settings of an existing graph object. When options is
used with a multiple graph, the options are applied to all graphs.
Syntax
Graph Proc: graph_name.options option_list
Note: the syntax of the option proc has changed considerably from version 3.1 of EViews.
While not documented here, the EViews 3.x options are still (for the most part) supported.
However, we do not recommend using the old options, as future support is not guaranteed.
Options
The options which support the - may be proceeded by a + or - indicating whether
to turn on or off the option. The + is optional.
Examples
sets GRAPH1 to use a 4 ´ 4 frame enclosed in a box. The graph will use color.
sets GRAPH1 to use a 2 ´ 8 frame with no box. The graph does not use color, with the
lines instead being displayed using patterns.
Cross-references
See Chapter 10 of the Users Guide for a discussion of graph options in EViews.
Syntax
Command: ordered(options) y x1 x2 x3
Equation Method: equation name.ordered(options) y x1 x2 x3
When used as an equation procedure, ordered estimates the model and saves the results
as an equation object with the given name.
Options
If you choose to employ user specified starting values, the parameters corresponding to the
limit points must be in ascending order.
Examples
ordered(d=l,h) y c wage edu kids
estimates an ordered logit model of Y on a constant, WAGE, EDU, and KIDS with QML
standard errors. This command uses the default quadratic hill climbing algorithm.
param c(1) .1 c(2) .2 c(3) .3 c(4) .4 c(5).5
equation eq1.binary(s) y c x z
coef betahat=eq1.@coefs
eq1.makelimit gamma
estimates an ordered probit model of Y on a constant, X, and Z from the specified starting
values. The estimated coefficients are then stored in the coefficient vector BETAHAT, and
the estimated limit points are stored in the vector GAMMA.
Cross-references
See Ordered Dependent Variable Models on page 422 of the Users Guide for additional
discussion.
See binary (p. 151) for the estimation of binary dependent variable models. See also
makelimits (p. 250).
When used as a command, output redirects printer output. You may specify that any pro-
cedure that would normally send output to the printer instead keep the output as a frozen
table or graph, or put the output in an ASCII text file.
272Chapter
272 8. Command Reference
Syntax
Command: output(options) base_name
Command: output off
By default, the output command redirects the output into frozen objects. You should sup-
ply a base name after the output keyword. Each subsequent print command will create a
new table or graph object in the current workfile, using the base name and an identifying
number. For example, if you supply the base name of OUT, the first print command will
generate a table or graph named OUT1, the second print command will generate OUT2,
and so on.
You can also use the optional settings, described below, to redirect table and text output to
an ascii test file.
When followed by the optional keyword off, the output command turns off output redi-
rection. Subsequent print commands will be directed to the printer.
Options
Options for output command
t Redirect table and text output to an ascii file in the default direc-
tory. Graphic output will continue to be sent to the printer.
Examples
output print_
causes the first print command to generate a table or graph object named PRINT_1, the
second print command to generate an object named PRINT_2, and so on.
output(t) c:\data\results
equation eq1.ls(p) log(gdp) c log(k) log(l)
eq1.resids(g,p)
output off
The second line redirects printing to the RESULTS.TXT file, while the print option of the
third line sends the graph output to the printer. The last line turns output redirection off
and restores normal printer use.
override273
273
Cross-references
See Output Redirection beginning on page 633 of the Users Guide for further discussion.
Specifies (or merges) overridden exogenous variables and add factors in the active sce-
nario.
Syntax
Model Proc: model_name.override(options) ser1 ser2 ...
Follow the override keyword with the argument list containing the exogenous variables
or add factors you wish to override.
Options
Examples
mod1.override fed1 add1
EViews will replace the original exclude list with one containing only FED1. To add over-
rides to an existing list, use the m option:
modl.override(m) add1
Cross-references
See the discussion in Specifying Scenarios on page 607 of the Users Guide. See also
Chapter 23 of the Users Guide for a general discussion of models.
See also model (p. 262), exclude (p. 199) and solveopt (p. 324).
274Chapter
274 8. Command Reference
param Command
Allows you to set the current values of coefficient vectors. The command may be used to
provide starting values for the parameters in nonlinear least squares, nonlinear system esti-
mation, and (optionally) ARMA estimation.
Syntax
Command: param coef_name(1) n1 coef_name(2) n2
Simply list, in pairs, the names of the coefficient vector and its element number followed
by the corresponding starting values. You can use param to change the starting value of
all, or just a subset, of the parameters in your equation.
Examples
param c(1) .2 c(2) .1 c(3) .5
The first line declares a coefficient vector BETA of length 3 filled with zeros. The second
line resets the second and third elements of BETA to 0.1 and 0.5, respectively.
Cross-references
See Starting Values on page 289 of the Users Guide for a discussion of setting initial val-
ues in nonlinear estimation.
pdl Expression
Syntax
Expression: ls y x1 x2 pdl(series_name,lags,order[,options])
Expression: tsls y x1 x2 pdl(series_name,lags,order[,options]) @ z1 z2
pie275
275
Options
The PDL specification must be provided in parentheses after the keyword pdl in the fol-
lowing order: the name of the series to which to fit a polynomial lag, the number of lags to
include, the order (degree) of polynomial to fit, and an option number to constrain the
PDL. By default, EViews does not constrain the endpoints of the PDL.
Examples
ls sale c pdl(order,8,3) ar(1) ar(2)
fits a third degree polynomial to the coefficients of eight lags of the regressor ORDER.
tsls sale c pdl(order,12,3,2) @ c pdl(rain,12,6)
fits a third degree polynomial to the coefficients of twelve lags of ORDER, constraining the
far end to be zero. Estimation is by two-stage least squares, using a constant and a sixth
degree polynomial fit to twelve lags of RAIN.
When the PDL variable is exogenous in 2SLS, you may use pdl(*) in the instrument list
instead of repeating the full PDL specification.
Cross-references
See Polynomial Distributed Lags (PDLs) on page 315 of the Users Guide for further dis-
cussion.
pie Command || Graph Proc | Group View | Matrix View | Sym View
Pie chart.
The pie command creates an untitled graph object containing pie charts for any number
of series. There will be one pie for each date or observation number, provided the values of
the series are positive. Each series is shown as a wedge in a different color/pattern, where
the width of the wedge equals the percentage contribution of the series to the total of all
listed series.
276Chapter
276 8. Command Reference
Syntax
Command: pie(options) ser1 ser2 ser3
Object View: object_name.pie(options)
Graph Proc: graph_name.pie(options)
To use pie as a command, simply list the name of the series to include in the pie chart.
You may also change the graph type by using pie as a method. Simply list the graph
name, followed by a period, and the pie keyword.
Options
Examples
smpl 1990 1995
pie cons inv gov
shows six pie charts, each divided into CONS, INV, and GOV.
graph gr1.line cons inv gov
gr1.pie
creates a line graph GR1 and then changes the graph to a pie chart.
Cross-references
See Chapter 10 of the Users Guide for a discussion of graphs and templates.
plot Command
Line graph.
Syntax
Command: pool name id1 id2 id3
Follow the pool keyword with a name for the pool object. You may optionally provide the
identifiers for the cross-section members of the pool object. Pool identifiers may be added
or removed at any time using the add and drop views of a pool.
Examples
pool zoo1 dog cat pig owl ant
Declares a pool object named ZOO1 with the listed cross-section identifiers.
Cross-references
Pool on page 35 contains a a complete description of the pool object. See Chapter 21 of
the Users Guide for a discussion of working with pools in EViews.
The prediction table displays the actual and estimated frequencies of each value of the dis-
crete dependent variable.
Syntax
Equation Proc: eq_name.predict(options)
For binary models, you may optionally specify how large the estimated probability must be
to be considered as a success (y = 1). Specify the cutoff level as an option in parentheses
after the keyword predict.
278Chapter
278 8. Command Reference
Options
Examples
equation eq1.binary(d=l) work c edu age race
eq1.predict(0.7)
Estimates a logit and displays the expectation-prediction table using a cutoff probability of
0.7.
Cross-references
See Binary Dependent Variable Models on page 405 of the Users Guide for a discussion
of binary models, and Expectation-Prediction (Classification) Table on page 413 of the
Users Guide for examples of prediction tables.
print Command
Syntax
Command: print(options) name1 name2 name3
Command: print(options) name1.view
Options
Examples
print gdp log(gdp) d(gdp) @pch(gdp)
sends a table of GDP, log of GDP, first difference of GDP, and percentage change of GDP to
the printer.
To merge the three graphs, realign them in one row, and print in landscape:
graph mygra.merge graph1 graph2 graph3
mygra.align(3,1,1)
print(l) mygra
To estimate the equation EQ1 and send the output view to the printer.
print eq1.ls gdp c gdp(-1)
Cross-references
See Print Setup beginning on page 632 of the Users Guide for a discussion of print
options and the Print Setup dialog.
probit Command
Equivalent to binary(d=n).
program Command
Declare a program.
Syntax
Command: program prog_name
Enter a name for the program after the program keyword. If you do not provide a name,
EViews will open an untitled program window. Programs are text files, not objects.
280Chapter
280 8. Command Reference
Examples
program runreg
opens a program window named RUNREG which is ready for program editing.
Cross-references
See Chapter 6, EViews Programming, on page 83 of the Command and Programming
Reference for further details and examples of writing EViews programs.
Quantile-quantile plots.
qqplot plots the (empirical) quantiles of a series against the quantiles of a theoretical dis-
tribution or the quantiles of another series. You may specify the theoretical distribution
and/or the method used to compute the empirical quantiles as options.
Syntax
Object View: object_name.qqplot(options)
Options
Examples
equation eq1.binary(d=l) work c edu age race
eq1.makeresid(o) res1
res1.qqplot(l)
estimates a logit, retrieves the residuals, and plots the quantiles of the residuals against
those from the logistic distribution. If the error distribution is correctly specified, the QQ-
plot should lie on a straight line.
Cross-references
See Quantile-Quantile on page 219 of the Users Guide for a discussion of QQ-plots.
Syntax
Var View: var_name.qstats(h,options)
You must specify the highest order of lag h to test for serial correlation. h must be larger
than the VAR lag order.
Options
Examples
var var1.ls 1 6 lgdp lm1 lcpi
show var1.qstats(l2,name=q)
282Chapter
282 8. Command Reference
The first line declares and estimates a VAR. The second line displays the portmanteau tests
for lags up to 12 and stores the Q-statistics in a matrix named Q.
Cross-references
See Diagnostic Views on page 504 of the Users Guide for a discussion of the portman-
teau tests and other VAR diagnostics.
See also arlm (p. 146) for a related multivariate residual serial correlation LM test.
range Command
range is more general than expand, since it also allows you to shrink the workfile.
Note that data in the workfile will be lost if you shrink the workfile. Sample objects con-
tained in the workfile may also be modified when shrunk.
Syntax
Command: range start end
For workfiles with dates, follow the range keyword with the new starting and ending
dates. To resize an undated workfile, list a pair of observation numbers to indicate the new
range.
Examples
workfile mywork m 1957:1 1995:12
range 1945:1 1989:12
The first line creates a monthly workfile from January 1957 to December 1995. The second
line resizes the workfile to start from January 1945 and end at December 1989.
workfile test a 1930 1999
sample s1 1930 1972
range 1940 1989
The first line creates an annual workfile named TEST with range from 1930 to 1999. The
second line creates a sample object named S1 with sample range 1930 to 1972. The third
line resizes the workfile range from 1940 to 1989. Note that the sample range of S1 will
also be modified to 19401989.
Cross-references
See Workfile Basics on page 33 of the Users Guide for a discussion of workfiles.
read283
283
See also workfile (p. 365), expand (p. 200), smpl (p. 322).
Command || Coef Proc | Matrix Proc | Pool Proc | Sym Proc | Vector
read Proc
The read command may be used to read multiple series into a workfile from a file on
disk. When used as a procedure, read imports data directly into pool and matrix objects.
Syntax
Command: read(options) path\file_name name1 name2 name3
Command: read(options) path\file_name n
Coef Proc: coef_name.read(options) path\file_name
Pool Proc: pool_name.read(options) path\file_name n1? n2? n3?
Matrix Proc: matrix_name.read(options) path\file_name
You must supply the name of the source file. If you do not include the optional path speci-
fication, EViews will look for the file in the default directory. The input specification fol-
lows the source file name. Path specifications may point to local or network drives. If the
path specification contains a space, you may enclose the entire expression in double quota-
tion marks.
In the command proc form of read, there are two ways to specify the input series. First,
you may list the names of the series in the order they appear in the file. Second, if the data
file contains a header line for the series names, you may specify the number n of the series
in the file instead of a list of names; EViews will name the series as given in the header
line. If you specify a number and the data file does not contain a header line, EViews will
name the series as SER01, SER02, SER03, and so on.
For the pool proc form of read, you must provide a list of ordinary or pool series.
Options
File type options
:
If you do not specify the t option, EViews uses the file name extension to determine the
file type. If you do specify the t option, then the file name extension will not be used to
determine the file type.
Options for ascii text files
Examples
read(t=dat,na=.) a:\mydat.raw id lwage hrs
reads data from an ASCII file MYDAT.RAW in the A drive. The data file is listed by observa-
tion, NA is coded as a . (dot or period), and there are three series, which are to be named
ID, LWAGE, HRS in this order from left to right.
read(a2,s=sheet3) cps88.xls 10
reads data from an Excel file CPS88 in the default directory. The data are organized by
observation, the upper left data cell is A2, and 10 series are read from a sheet named
SHEET3.
reads the Excel file CPS91 from the network drive specified in the path.
Cross-references
See Importing Data on page 64 of the Users Guide for a discussion and examples of
importing data from external files.
rename Command
Syntax
Command: rename old_name new_name
After the rename keyword, first list the old name, followed by the new name.
Examples
rename temp_u u2
Cross-references
See Object Basics on page 41 of the Users Guide for a discussion of working with objects
in EViews.
Syntax
Object View: object_name.representation(options)
Options
Examples
pool1.representation
Cross-references
See Chapters 11, 20, and 21 of the Users Guide, for basic details on the relevant estimation
objects.
Syntax
Object Proc: object_name.resample(options) [output_names]
You should follow the resample keyword and options with a list of names or wildcard
expression identifying the series to hold the output. If a list is used to identify the targets,
the number of target series must match the number of names implied by the keyword.
Options
outsmpl="" Sample to fill the new series. Either provide the sample
range in double quotes or specify a named sample
object. The default is the current workfile sample.
name=group_na Name of group to hold created series
me
permute Draw from rows without replacement. Default is to
draw with replacement.
weight= Name of series to be used as weights. The weight series
series_name must be non-missing and non-negative in the current
workfile sample. The default is equal weights.
block=integer Block length for each draw. Must be a positive integer.
The default block length is 1.
withna (default) Draw from all rows in the current sample, including
those with NAs.
dropna Do not draw from rows that contain missing values in
the current workfile sample.
fixna Excludes NAs from draws but copies rows containing
missing values to the output series.
288Chapter
288 8. Command Reference
Since we append a suffix for the new name, no series in the group can be an auto-
series. For example, a group containing series such as X(1) or LOG(X) will error.
You will have to generate new series, say by setting XLAG = X(1) or LOGX =
LOG(X). Then create a new group consisting of XLAG and LOGX and call the boot-
strap procedure on this new group.
If the name you provided to group the resampled series already exists and if it is a
group object, the group object will be overwritten with the resample series. If it
already exists but is not a group object, EViews will error.
Block bootstrap (block length larger than 1) requires a continuous output sample.
Therefore a block length larger than 1 cannot be used together with the fixna
option and the outsmpl should not contain any gaps.
The fixna option will have an effect only if there are missing values in the overlap-
ping sample of the input sample (current workfile sample) and the output sample
specified by outsmpl.
If you specify fixna, we first copy any missing values in the overlapping sample to
the output series. Then the input sample is adjusted to drop the rows containing
missing values and the output sample is adjusted not to overwrite the copied values.
If you choose dropna and the block length is larger than 1, the input sample may
shrink in order to ensure that there are no missing values in any of the drawn
blocks.
If you choose permute, the block option will be reset to 1, the dropna and
fixna options will be ignored (reset to the default withna option), and the
weight option will be ignored (reset to default equal weights).
Examples
group g1 x y
g1.resample
creates new series X_B and Y_B by drawing with replacement from the rows of X and Y in
the current workfile sample. If X_B or Y_B already exist in the workfile, they will be over-
written if they are series objects; otherwise EViews will error. Note that only values of X_B
and Y_B in the output sample (in this case the current workfile sample) will be overwrit-
ten.
g1.resample(weight=wt,suffix=_2) g2
will append _2 to the names for the new series and group them in a group object named
G2. The rows in the sample will be drawn with probabilities proportional to the corre-
sponding values in the series WT. WT must have non-missing non-negative values in the
current workfile sample.
residcor289
289
Cross-references
See Resampling on page 173 of the Users Guide for a discussion of the resampling proce-
dure. For additional discussion of wildcards, see Appendix C, Wildcards, on page 639 of
the Users Guide.
See also @resample (p. 396) and @permute (p. 395) for sampling from matrices.
Syntax
Command: reset(n, options)
Equation View: eq_name.reset(n, options)
You must provide the number of powers of fitted terms n to include in the test regression.
Options
Examples
equation eq1.ls lwage c edu race gender
eq1.reset(2)
carries out the RESET test by including two terms, the square and the cube of the fitted
values.
Cross-references
See Ramsey's RESET Test on page 366 of the Users Guide for a discussion of the RESET
test.
Displays the correlations of the residuals from each equation in the system, sspace, or var
object, or from each pool cross-section. The sspace object residuals are the standardized
one-step ahead signal forecast errors.
290Chapter
290 8. Command Reference
Syntax
Object View: object_name.residcor(options)
Options
Examples
sys1.residcor
Cross-references
See Chapters 19, 20, 21, and 22 of the Users Guide for a discussion of systems, VARs,
pools, and sspace models.
Displays the covariances of the residuals from each equation in the system, sspace, or var
object, or each pool cross-section. The sspace object residuals are the standardized one-
step ahead forecast errors.
Syntax
Object View: object_name.residcov(options)
Options
Examples
var1.residcov
Cross-references
See Chapters 19, 20, 21, and 22 of the Users Guide for a discussion of systems, vars, pools,
and sspace models.
resids291
291
resids Equation View | Pool View | Sspace View | System View | Var View
Display residuals.
For equation and pool objects, resids allows you to display the actual, fitted values and
residuals in either tabular or graphical form.
For sspace objects, resids allows you to display the actual-fitted-residual graph.
For system, var or pool objects, resids displays multiple graphs of the residuals. Each
graph will contain the residuals for each equation in the VAR, or for each cross-section in
the pool.
Syntax
Object View: object_name.resids(options)
Options
Examples
equation eq1.ls m1 c inc tb3 ar(1)
eq1.resids
regresses M1 on a constant, INC, and TB3 correcting for first order serial correlation, and
displays a table of actual, fitted, and residual series.
eq1.resids(g)
Cross-references
See also graph (p. 219).
292Chapter
292 8. Command Reference
Equation View | Logl View | Pool View | Sspace View | System View |
results Var View
Syntax
Object View: object_name.results(options)
Options
Examples
equation eq1.ls m1 c inc tb3 ar(1)
eq1.results(p)
estimates an equation using least squares, and displays and prints the results.
var mvar.ls 1 4 8 8 m1 gdp tb3 @ @trend(70.4)
mvar.results(p)
Cross-references
See the various chapters in the Users Guide for a description of the results view for each of
the objects.
The rls view of an equation displays the results of recursive least squares (rolling) regres-
sion. This view is only available for equations estimated by ordinary least squares without
ARMA terms.
Syntax
Equation View: eq_name.rls(options) c(1) c(2)
rls293
293
Options
r Plot the recursive residuals about the zero line with plus and
minus two standard errors.
r,s Plot the recursive residuals and save the residual series and
their standard errors as series named R_RES and R_RESSE,
respectively.
c Plot the recursive coefficient estimates with two standard error
bands. Follow the rls(c) command with a list of coeffi-
cients to be displayed.
c,s Plot the listed recursive coefficients and save all coefficients
and their standard errors as series named R_C1, R_C1SE, R_C2,
R_C2SE, and so on.
o Plot the p-values of recursive one-step Chow forecast tests.
n Plot the p-values of recursive n -step Chow forecast tests.
q Plot the CUSUM (standardized cumulative recursive residual)
and 5 percent critical lines.
v Plot the CUSUMSQ (CUSUM of squares) statistic and 5 percent
critical lines.
p Print the view.
Examples
equation eq1.ls m1 c tb3 gdp
eq1.rls(r,s)
eq1.rls(c) c(2) c(3)
plots and saves the recursive residual series and their standard errors from EQ1 as R_RES
and R_RESSE. The third line plots the recursive slope coefficients of EQ1.
equation eq2.ls m1 c pdl(tb3,12,3) pdl(gdp,12,3)
eq2.rls(c) c(3)
eq2.rls(q)
The second command plots the recursive coefficient estimates of PDL02, the linear term in
the polynomial of TB3 coefficients. The third line plots the CUSUM test statistic and the
5% critical lines.
Cross-references
See Recursive Least Squares on page 368 of the Users Guide.
294Chapter
294 8. Command Reference
rnd Expression
Generates (pseudo) random draws from a uniform distribution on (0,1). The expression
may be included in a series expression or in an equation to be used in solve.
Examples
series u=5+(12-5)*rnd
Cross-references
See the list of available random number generators in Appendix A, Operator and Function
Reference, beginning on page 417.
See also nrnd (p. 266), rndint (p. 294) and rndseed (p. 295).
rndint Command
The rndint command fills series, vector, and matrix objects with (pseudo) random inte-
gers drawn uniformly from zero to a user specified maximum. The rndint command
ignores the current sample and fills the entire object with random integers.
Syntax
Command: rndint(object_name, n)
Type the name of the series, vector, or matrix object to fill followed by an integer value rep-
resenting the maximum value n of the random integers. n should a positive integer.
Examples
series index
rndint(index,10)
fills the entire series INDEX randomly with integers from 0 to 10. Note that, unlike genr,
rndint ignores the current sample and fills the series for the entire workfile range.
sym(3) var3
rndint(var3,5)
rowvector295
295
fills the entire symmetric matrix VAR3 with random integers ranging from 0 to 5.
Cross-references
See the list of available random number generators in Appendix A, Operator and Function
Reference, beginning on page 417.
See also nrnd (p. 266), rnd (p. 294) and rndseed (p. 295).
rndseed Command
Use rndseed when you wish to generate a repeatable sequence of random numbers. If
you do not set a seed, EViews chooses a seed using the system clock.
Syntax
Command: rndseed integer
Examples
rndseed 123456
genr t3=@qtdist(rnd,3)
rndseed 123456
genr t30=@qtdist(rnd,30)
generates random draws from a t-distribution with 3 and 30 degrees of freedom using the
same seed.
Cross-references
See the list of available random number generators in Appendix A, Operator and Function
Reference, beginning on page 417.
See also nrnd (p. 266), rnd (p. 294) and rndint (p. 294).
The rowvector command declares and optionally initializes a (row) vector object.
296Chapter
296 8. Command Reference
Syntax
Command: rowvector(n1) vector_name
Command: rowvector vector_name=assignment
You may optionally specify the size (number of columns) of the row vector in parentheses
after the rowvector keyword. If you do not specify the size, EViews creates a rowvector
of size 1 unless the declaration is combined with an assignment.
By default, all elements of the vector are set to 0, unless an assignment statement is pro-
vided. EViews will automatically resize new rowvectors, if appropriate.
Examples
rowvector rvec1
rowvector(20) coefvec=2
rowvector newcoef=coefvec
RVEC1 is a row vector of size one with element 0. COEFVEC is a row vector of size 20 with
all elements equal to 2. NEWCOEF is also a row vector of size 20 with all elements equal to
2.
Cross-references
See Rowvector on page 38 for a complete description of the rowvector object.
run Command
Run a program.
The run command executes a program. The program may be located in memory or stored
in a program file on disk.
Syntax
Command: run(options) path\program_name %0 %1
If the program has arguments, you should list them after the filename. EViews first sees if
the specified program is in memory. If not, it looks for the program on disk in the current
working directory, or in the specified path. EViews expects that program files will have a
.PRG extension.
sample297
297
Options
Examples
run(q) simul x xhat
quietly runs a program named SIMUL from the default directory using arguments X and
XHAT.
Since run is a command, it may also be placed in a program file. You should note that if
you put the run command in a program file and then execute the program, EViews will
stop after executing the program referred to by the run command. For example, if you have
a program containing
run simul
print x
the print statement will not be executed since execution will stop after executing the
commands in SIMUL.PRG. If this behavior is not intended, you should consider using the
include statement (p. 408).
Cross-references
See Executing a Program on page 84 for further details.
The sample statement declares, and optionally defines, a sample object. If no sample
statement is provided, the sample object will be set to the current workfile sample.
To reset the sample dates in a sample object, you must use the set procedure.
298Chapter
298 8. Command Reference
Syntax
Command: sample name start end if_statement
Follow the sample keyword with a name for the sample object and a sample range, possi-
bly with an if condition.
Examples
sample ss
declares a sample object named SS and sets it to the current workfile sample.
sample s2 1974:1 1995:4
The first line declares a sample FE_BL with observations such that GENDER=1 and
RACE=3 in the current workfile range. The second line sets the current sample to FE_BL.
sample sf @last-10 @last
declares a sample object named SF and sets it to the last 10 observations of the current
workfile range.
sample s1 @first 1973:1
s1.set 1973:2 @last
The first line declares a sample object named S1 and sets it from the beginning of the
workfile range to 1973:1. The second line resets S1 from 1973:2 to the end of the workfile
range.
Cross-references
See Samples on page 60, and Appendix B of the Users Guide for a discussion of using
dates and samples in EViews.
sar Expression
the product of that specified by the ar terms and that specified by the sar terms. The pur-
pose of the sar expression is to allow you to form the product of lag polynomials.
Examples
ls tb3 c ar(1) ar(2) sar(4)
In this two-stage least squares specification, the error term is a first order autoregressive
process with multiplicative seasonal autoregressive terms at lags 12 and 24.
Cross-references
See ARIMA Theory beginning on page 303 of the Users Guide for details on ARMA and
seasonal ARMA modeling.
See also sma (p. 319), ar (p. 142), and ma (p. 243).
save Command
Syntax
Command: save file_name
You may supply a name to be given the file and the name may include a path designation.
Examples
The command
save
saves the current workfile in the default directory using the current name.
load macro1
save a:\macro2
loads a workfile named MACRO1 from the default directory and saves it as MACRO2 in the
A drive. The original MACRO1 workfile will be unaltered.
300Chapter
300 8. Command Reference
Cross-references
See Workfile Basics on page 33 of the Users Guide for a discussion of workfile opera-
tions.
The scalar command declares a scalar object and optionally assigns a value.
Syntax
Command: scalar scalar_name
Command: scalar scalar_name=assignment
The scalar keyword should be followed by a valid name, and optionally, by an assign-
ment. If there is no explicit assignment, the scalar will be assigned a value of zero.
Examples
scalar alpha
Cross-references
See Scalar on page 40 for a summary of the features of scalar objects in EViews.
By default, EViews optimally chooses the axes to fit the graph data.
Syntax
Graph Proc: graph_name.scale(axis) options_list
scale301
301
Note: the syntax of the scale proc has changed considerably from version 3.1 of EViews.
While not documented here, the EViews 3 options are still (for the most part) supported.
However, we do not recommend using the old options as future support is not guaranteed.
Options
The axis parameter identifies which of the axes the scale proc modifies. If no option is
specified, the scale proc will modify all of the axes. axis may take on one of the following
values:
Examples
To set the right scale to logarithmic with manual range you can enter
graph1.scale(right) log range(10, 30)
Alternatively,
graph1.scale zeroline ticksnone range(minmax)
draws a horizontal zero line and suppresses the tick marks on the axes which are defined
to match the data range.
Cross-references
See Chapter 10 of the Users Guide for a discussion of graph options.
See also dates (p. 176), options (p. 268) and setelem (p. 313).
scat Command || Graph Proc | Group View | Matrix View | Sym View
Scatter diagram.
The scat command produces an untitled graph object containing a scatter diagram of two
or more series. When used as a view, scat displays a scatter diagram view of the series in
the group or columns of a matrix.
By default, the first series or column of data will be located along the horizontal axis and
the remaining data on the vertical axis. You may optionally choose to plot the data in pairs,
where the first two series or columns are plotted against each other, the second two series
or columns are plotted against each other, and so forth.
When used as a group or matrix view, there must be at least series or columns in the
object.
scat303
303
Syntax
Command: scat(options) ser1 ser2 ser3
Object View: object_name.scat(options)
Graph Proc: graph_name.scat(options)
For scat used as a command, list the names of series or groups. The first series is used for
the horizontal axis and the remaining series are used for the vertical axis.
Options
Template and printing options
Scale options
Examples
scat unemp inf want
produces an untitled graph object containing a scatter plot with UNEMP on the horizontal
and INF and WANT on the vertical axis.
group med age height weight
med.scat(t=scat2)
produces a scatter plot view of the group object MED using the graph object SCAT2 as a
template.
group pairs age height weight length
pairs.scat(b)
produces a scatter plot view with AGE plotted against HEIGHT, and WEIGHT plotted
against LENGTH.
Cross-references
See Chapter 10 of the Users Guide for a discussion of graphs and templates.
304Chapter
304 8. Command Reference
The scatmat view displays a matrix of scatter plots for all pairs of series in a group.
Syntax
Group View: group_name.scatmat(options)
Options
Examples
group g1 weight height age
g1.scatmat
displays a 3 ´ 3 matrix of scatter plots for all pairs of the three series in group G1.
Cross-references
See Scatter on page 206 of the Users Guide for a discussion of scatter plot matrices.
Syntax
Model Proc: model_name.scenario(options)
Options
Examples
mod1.scenario baseline
Cross-references
Scenarios are described in detail beginning on page 598 of the Users Guide. Chapter 23 of
the Users Guide documents EViews models in depth.
Seasonal adjustment.
The seas command carries out seasonal adjustment using either the ratio to moving aver-
age, or the difference from moving average technique.
EViews also performs Census X11 seasonal adjustment. For details, see the x11 command
(p. 371).
Syntax
Command: seas(options) series_name name_adjust name_fac
Series Proc: series_name.seas(options) name_adjust name_fac
To use seas as a command, list the name of the original series and the name to be given
to the seasonally adjusted series. You may optionally include a third series name for the
seasonal factors. seas will display the seasonal factors using the convention of the Census
X11 program.
Options
Examples
seas(a) pass pass_adj pass_fac
seasonally adjusts the series PASS using the additive method and saves the adjusted series
as PASS_ADJ and the seasonal factors as PASS_FAC.
306Chapter
306 8. Command Reference
sales.seas(m) adj_sales
seasonally adjusts the series SALES using the multiplicative method and saves the adjusted
series as ADJ_SALES.
Cross-references
See Seasonal Adjustment on page 175 of the Users Guide for a discussion of seasonal
adjustment methods.
See also seasplot (p. 306), x11 (p. 371) and x12 (p. 372).
seasplot displays a line graph view of a series ordered by season. Available only for
quarterly and monthly frequencies.
Syntax
Series View: series_name.seasplot(options)
Options
Examples
freeze(gra_ip) ipnsa.seasplot
creates a graph object named GAR_IP that contains the stacked seasonal line graph view of
the series IPNSA.
Cross-references
See Spreadsheet and Graph Views on page 151 of the Users Guide for a brief discussion
of seasonal line graphs.
See also seas (p. 305), x11 (p. 371) and x12 (p. 372).
series307
307
The series command creates and optionally initializes a series, or modifies an existing
series.
Syntax
Command: series name
Command: series name=formula
The series command should be followed by either the name of a new series, or an
explicit or implicit expression for generating a series. If you create a series and do not ini-
tialize it, the series will be filled with NAs. Rules for composing a formula are given in
Using Expressions on page 87 of the Users Guide.
Examples
series x
Once a series is declared, you do not need to include the series keyword prior to enter-
ing the formula. The following example generates a series named LOW that takes value 1 if
either INC is less than or equal to 5000 or EDU is less than 13 and 0 otherwise.
series low
low=inc<=5000 or edu<13
This example solves for the implicit relation and generates a series named Z which is the
double log of Y so that Z=log(log(Y)).
series exp(exp(z))=y
The command
series z=(x+y)/2
generates a series named CWAGE which is equal to WAGE if HRS exceeds 5 and zero other-
wise.
308Chapter
308 8. Command Reference
series 10^z=y
The commands
series y_t=y
smpl if y<0
y_t=na
smpl @all
generates a series named Y_T which replaces negative values of Y with NAs.
series z=@movav(x(+2),5)
creates a series named Z which is the centered moving average of the series X with two
leads and two lags. This works only for centered moving averages over an odd number of
periods.
series z=(.5*x(6)+@movsum(x(5),11)+.5*x(-6))/12
generates a series named Z which is the centered moving average of the series X over
twelve periods.
genr y=2+(5-2)*rnd
creates series named Y which is a random draw from a uniform distribution between 2 and
5.
series y=3+@sqr(5)*nrnd
generates a series named Y which is a random draw from a normal distribution with mean
3 and variance 5.
Cross-references
A full listing and description of series functions and expressions is provided in
Appendix A, Operator and Function Reference, on page 417.
See Using Expressions on page 87 of the Users Guide for a discussion of rules for form-
ing EViews expressions.
Syntax
Sample Proc: sample_name.set sample_description
Follow the set command with a sample description. See sample for instructions on
describing a sample.
Examples
sample s1 @first 1973
s1.set 1974 @last
The first line declares and defines a sample object named S1 from the beginning of the
workfile range to 1973. The second line resets S1 from 1974 to the end of the workfile
range.
Cross-references
See Samples on page 60 of the Users Guide for a discussion of samples in EViews.
setcell Command
Syntax
Command: setcell(table_name, r, c, content[, options])
Options
Provide the following information in parentheses in the following order: the name of the
table object, the row number, r, of the cell, the column number, c, of the cell, a number or
string to put in the cell, and optionally, a justification and/or numerical format code. A
string of text must be enclosed in double quotes.
The numerical format code determines the format with which a number in a cell is dis-
played; cells containing strings will be unaffected. The format code can either be a positive
integer, in which case it specifies the number of decimal places to be displayed after the
decimal point, or a negative integer, in which case it specifies the total number of charac-
ters to be used to display the number. These two cases correspond to the fixed decimal
and fixed character fields in the number format dialog.
Note that when using a negative format code, one character is always reserved at the start
of a number to indicate its sign, and that if the number contains a decimal point, that will
also be counted as a character. The remaining characters will be used to display digits. If
the number is too large or too small to display in the available space, EViews will attempt
to use scientific notation. If there is insufficient space for scientific notation (six characters
or less), the cell will contain asterisks to indicate an error.
Examples
setcell(tab1,2,1,"Subtotal")
puts the string Subtotal in row 2, column 1 of the table object named TAB1.
Cross-references
Chapter 5 describes table formatting using commands. See Chapter 10 of the Users Guide
for a discussion and examples of table formatting in EViews.
setcolwidth Command
Syntax
Command: setcolwidth(table_name, c, width)
Options
To change the width of a column, provide the following information in parentheses in the
following order: the name of the table, the column number c, and the number of characters
width for the new width. EViews measures units in terms of the width of a numeric char-
acter. Because different characters have different widths, the actual number of characters
that will fit may differ slightly from the number you specify.
setconvert311
311
Examples
setcolwidth(mytab,2,20)
Cross-references
Chapter 5 describes table formatting using commands. See also Chapter 10 of the Users
Guide for a discussion and examples of table formatting in EViews.
Determines the default frequency conversion method for a series when moved to different
frequency workfiles (using copy or fetch).
You can override this default conversion method by specifying a frequency conversion
method as an option in the fetch (p. 201) command.
If you do not set a conversion method and if you do not specify a conversion method as an
option in the fetch command, EViews will use the conversion method set in the global
option.
Syntax
Series View: ser_name.setconvert up_method [down_method]
Follow the series name with a period, the word setconvert, and option letters to specify
the frequency conversion method. You may specify an up-conversion method, a down-con-
version method, or both. If either the up-conversion or down-conversion method is omit-
ted, EViews will set the method to the use EViews default.
Options
The following options control the frequency conversion method when copying series and
group objects to a workfile, converting from low to high frequency:
The following options control the frequency conversion method when copying series and
group objects to a workfile, converting from high to low frequency:
Examples
unemp.setconvert a
sets the default down-conversion method of the series UNEMP to take the average of non-
missing observations, and resets the up-conversion method to use the global default.
setelem313
313
ibm_hi.setconvert xn d
sets the default down-conversion method for IBM_HI to take the largest observation of the
higher frequency observations, propagating missing values, and the default up-conversion
method to constant, match sum.
consump.setconvert
Cross-references
See Frequency Conversion on page 72 of the Users Guide for a discussion of frequency
conversions and the treatment of missing values.
Set individual line, bar and legend options for each series in the graph.
Syntax
Graph Proc: graph_name.setelem(n1) option_list
where n1 is the identifier for the graph element whose options you wish to modify. For
example, if n1=2, EViews will modify the second line in the graph.
Options
The option list for setelem may contain one or more of the following:
fcolor(args) sets the fill color for symbols, bars, and pies.
gray(n1) sets the gray scale for bars and pies:
n1 should be an integer from 115
corresponding to one of the pre-
defined gray scale settings (from
lightest to darkest).
Examples
graph1.elem(2) lcolor(blue) lwidth(2) symbol(circle)
sets the second line of GRAPH1 to be a blue line of width 2 with circle symbols.
graph1.elem(1) lcolor(blue)
graph1.elem(1) linecolor(0, 0, 255)
The lines
graph1.elem(1) scale(l)
graph1.elem(2) scale(l)
graph1.elem(3) scale(r)
create a dual scale graph where the first two series are scaled together and labeled on the
left axis and the third series is scaled and labeled on the right axis.
Cross-references
See Chapter 10 of the Users Guide for a discussion of graph options in EViews.
setline Command
Syntax
Command: setline(table_name, r)
Options
Specify the name of the table and the row number r in which to place the horizontal line.
Examples
setline(tab3,8)
places a (double) horizontal line in the eighth row of the table object TAB3.
Cross-references
Chapter 5 describes table formatting using commands. See also Chapter 10 of the Users
Guide for a discussion and examples of table formatting in EViews.
Coef View | Group View | Matrix View | Pool View | Series View |
sheet Table View | Sym View | Vector View
Spreadsheet view.
The sheet view displays the spreadsheet view of the named object. For table objects,
sheet simply displays the table.
Syntax
Object View: object_name.sheet(options)
Pool View: pool_name.sheet(options) ser1? ser2?
The sheet view of pool objects displays the spreadsheet view of the series in the pool.
Follow the word sheet by a list of series to display; you may use the cross section identi-
fier ? in the series name.
Options
Examples
tab1.sheet
Cross-references
See Chapter 4 of the Users Guide for a discussion of the spreadsheet view of series and
groups, and Chapter 21 of the Users Guide for a discussion of pools. See also the chapters
for the other individual objects.
show Command
Display objects.
The show command displays series or other objects on your screen. A scalar object is dis-
played in the status line at the bottom of the EViews window.
Syntax
Command: show object_name.view
Command: show name1 name2 name3
The command show should be followed by the name of an object, or an object name with
an attached view.
For series and graph objects, show can operate on a list of names. The list of names must
be of the same type. show creates and displays an untitled group or multiple graph object.
Examples
genr x=nrnd
show x.hist
close x
generates a series X of random draws from a standard normal distribution, displays the his-
togram view of X, and closes the series window.
show wage log(wage)
opens an untitled group window with the spreadsheet view of the two series.
freeze(gra1) wage.hist
genr lwage=log(wage)
freeze(gra2) lwage.hist
show gra1 gra2
318Chapter
318 8. Command Reference
Cross-references
See Chapter 3 for a complete listing of the views of the various objects.
Display graphs of a set of signal series computed using the Kalman filter.
Syntax
Sspace View: object_name.signalgraphs(options)
Options
Examples
ss1.signalgraphs(t=smooth)
ss1.signalgraphs(t=smoothse)
displays a graph view containing the smoothed signal values, and then displays a graph
view containing the root MSE of the smoothed states.
Cross-references
See Chapter 22 of the Users Guide for a discussion of state space models.
See also stategraphs (p. 331), makesignals (p. 253) and makestates (p. 254).
sma Expression
Examples
ls tb3 c ma(1) ma(2) sma(4)
TB3 is modeled as a second order moving average process with a multiplicative seasonal
moving average term at lag four.
tsls(z) sale c adv ma(1) sma(12) sma(24) @ c gdp
In this two-stage least squares specification, the error term is a first order moving average
process with multiplicative seasonal moving average terms at lags 12 and 24. The z
option turns off backcasting.
Cross-references
See ARIMA Theory beginning on page 303 of the Users Guide for details on ARMA and
seasonal ARMA modeling.
See also sar (p. 298), ar (p. 142), and ma (p. 243).
320Chapter
320 8. Command Reference
Exponential smoothing.
smooth automatically calculates in-sample forecast errors and puts them into the series
RESID.
Syntax
Command: smooth(method) series_name smooth_name freq
Series Proc: series_name.smooth(method) smooth_name freq
You should follow the smooth keyword with the name of the series and a name for the
smoothed series. You must specify the smoothing method in parentheses as an option. The
optional freq may be used to override the default for the number of periods in the seasonal
cycle. By default, this value is set to the workfile frequency (e.g. 4 for quarterly data).
For undated data, the default is 5.
Options
Smoothing method options
Other Options:
If you wish to set only some of the damping parameters and let EViews estimate the other
parameters, enter the letter e where you wish the parameter to be estimated.
If the number of seasons is different from the frequency of the workfile (an unusual case
that arises primarily if you are using an undated workfile for data that are not monthly or
quarterly), you should enter the number of seasons after the smoothed series name. This
optional input will have no effect on forecasts without seasonal components.
Examples
smooth(s) sales sales_f
smooths the SALES series by a single exponential smoothing method and saves the
smoothed series as SALES_F. EViews estimates the damping (smoothing) parameter and
displays it with other forecast statistics in the SALES series window.
smooths the TB3 series by a Holt-Winters no seasonal method and saves the smoothed
series as TB3_HW. The mean damping parameter is estimated while the trend damping
parameter is set to 0.3.
smpl @first @last-10
smooth(m,.1,.1,.1) order order_hw
smpl @all
graph gra1.line order order_hw
show gra1
322Chapter
322 8. Command Reference
smooths the ORDER series by a Holt-Winters multiplicative seasonal method leaving the
last 10 observations. The damping parameters are all set to 0.1. The last three lines plot
and display the actual and smoothed series over the full sample.
Cross-references
See Exponential Smoothing on page 184 of the Users Guide for a discussion of exponen-
tial smoothing methods.
smpl Command
The smpl command sets the workfile sample to use for statistical operations and series
assignment expressions.
Syntax
Command: smpl start1 end1 start2 end2
if_condition
Command: smpl sample_name
List the date or number of the first observation and the date or number of the last observa-
tion for the sample. Rules for specifying dates are given in Appendix B, Date Formats, on
page 635 of the Users Guide. smpl may contain more than one pair of beginning and end-
ing observations.
The smpl command also allows you to select observations on the basis of conditions spec-
ified in an if statement. This enables you to use logical operators to specify what observa-
tions to include in EViews procedures. Put the if statement after the pairs of dates.
You can also use smpl to set the current observations to the contents of a named sample
object; put the name of the sample object after the command smpl.
Examples
smpl 1955:1 1972:12
excludes observations (or years) 19411945 and 19731974 from the workfile sample.
smpl if union=1 and edu<=15
sets the sample to those observations where UNION takes the value 1 and EDU is less than
or equal to 15.
sample half @first @first+@obs(x)/2
smpl half
smpl if x>0
smpl @all if x>0
The first line declares a sample object named HALF which includes the first half of the
series X. The second line sets the sample to HALF and the third line sets the sample to
those observations in HALF where X is positive. The last line sets the sample to those
observations where X is positive over the full sample.
Cross-references
See Samples on page 60 of the Users Guide for a discussion of samples in EViews.
solve finds the solution to a simultaneous equation model for the set of observations
specified in the current workfile sample.
Syntax
Command: solve(options)
Model Proc: model_name.solve(options)
Note: When solve is used in a program (batch mode) models are always solved over the
workfile sample. If the model contains a solution sample, it will be ignored in favor of the
workfile sample.
324Chapter
324 8. Command Reference
Syntax
Command: solve(options) model_name
Model Proc: model_name.solve(options)
You should follow the name of the model after the solve command or use solve as a
procedure of a named model object. The default solution method is dynamic simulation.
You may modify the solution method as an option.
solve first looks for the specified model in the current workfile. If it is not present, solve
attempts to fetch a model file (.DBL) from the default directory or, if provided, the path
specified with the model name.
Options
solve can take any of the options available in solveopt (p. 324).
Examples
solve mod1
Cross-references
See Chapter 23 of the Users Guide for a discussion of models.
See also model (p. 262), msg (p. 263) and solveopt (p. 324).
solveopt sets options for model solution but does not solve the model. The same options
can be set directly in a solve procedure.
Syntax
Model Proc: model_name.solveopt(options)
solveopt325
325
Options
Cross-references
See Chapter 23 of the Users Guide for a discussion of models.
See also model (p. 262), msg (p. 263) and solve (p. 323).
326Chapter
326 8. Command Reference
sort Command
The sort command sorts all series in the workfile on the basis of the values of one or
more of the series. For purposes of sorting, NAs are considered to be smaller than any
other value.
By default, EViews will sort the series in ascending order. You may use options to override
the default behavior.
Syntax
Command: sort(options) ser1 ser2
List the name of the series by which you wish to sort the workfile. If you list two or more
series, sort uses the values of the second series to resolve ties from the first series, and
values of the third series to resolve ties from the second, and so on.
Options
Examples
sort(d) inc
sorts all series in the workfile in order of the INC series with the highest value of INC first.
NAs in INC (if any) will be placed at the bottom.
sort gender race wage
sorts all series in the workfile in order of the values of GENDER from low to high, with ties
resolved by ordering on the basis of RACE, with further ties resolved by ordering on the
basis of WAGE.
Cross-references
See Sorting Workfiles on page 39 of the Users Guide.
spike327
327
Display the text specification view for logl, model, sspace, system objects.
Syntax
Object View: object_name.spec(options)
Options
Examples
model1.spec
Cross-references
See also append (p. 141), merge (p. 260), text (p. 353).
Coef View | Graph Proc | Group View | Matrix View | Series View |
spike Sym View | Vector View
Spike graph.
The spike graph view of a group creates spike graphs for all series in the group. The spike
graph view of a matrix plots spikes for each column in the matrix.
Syntax
Object View: object_name.spike(options)
Graph Proc: graph_name.spike(options)
Options
Template and printing options
Scale options
Examples
group g1 gdp cons m1
g1.spike(d)
plots line graphs of the three series in group G1 using dual scaling.
matrix1.spike(t=mygra)
displays spike graphs of the columns of MATRIX1 using the graph object MYGRA as a tem-
plate.
graph1.spike(m)
changes GRAPH1 so that it contains spike graphs of each of the series in the original
graph, with each graph plotted on separate axes.
Cross-references
See Chapter 10 of the Users Guide for a detailed discussion of graphs in EViews.
Syntax
Command: sspace name
Follow the sspace keyword with a name to be given the sspace object. The append key-
word may be used to add lines to an existing sspace.
Examples
sspace stsp1
declares a sspace object named TVP, specifies a time varying coefficient model, and esti-
mates the model by maximum likelihood.
Cross-references
The sspace object is documented in greater detail beginning on page 42.
See Chapter 22 of the Users Guide for a discussion of state space models.
The statby view displays descriptive statistics for the elements of a series classified into
categories by one or more other series.
Syntax
Series View: series_name.statby(options) classifier_name
Follow the series name with a period, the statby keyword, and a name (or a list of
names) for the series or group to classify by. The options control which statistics to display
330Chapter
330 8. Command Reference
and in what form. By default, statby displays the means, standard deviations, and counts
for the series.
Options
Options to control statistics to be displayed
Other options
Examples
wage.statby(max,min) sex race
displays the mean, standard deviation, max, and min of the series WAGE by (possibly
binned) values of SEX and RACE.
Cross-references
See Stats by Classification on page 154 and Descriptive Statistics on page 208 of the
Users Guide.
Display graphs of a set of state series computed using the Kalman filter.
Syntax
Sspace View: ssname_name.stategraph(options)
Options
Other options
Examples
ss1.stategraphs(t=filt)
Cross-references
See Chapter 22 of the Users Guide for a discussion of state space models.
See also signalgraphs (p. 318), makesignals (p. 253) and makestates (p. 254).
Show the one-step ahead state predictions or the state prediction covariance matrix at the
final values (T+1|T) where T is the last observation in the estimation sample. By default,
EViews shows the state predictions.
Syntax
Sspace View: sspace_name.statefinal(options)
stateinit333
333
Options
Examples
ss1.statefinal(c)
displays a view containing the final state covariances (the one-step ahead covariances for
the first out-of-(estimation) sample period.
Cross-references
See Chapter 22 of the Users Guide for a discussion of state space models.
Show the state initial values or the state covariance initial values used to initialize the Kal-
man Filter (1|0). By default, EViews shows the state values.
Syntax
Sspace View: sspace_name.stateinit(options)
Options
Examples
ss1.stateinit
displays a view containing the initial state values (the one-step ahead predictions for the
first period).
Cross-references
See Chapter 22 of the Users Guide for a discussion of state space models.
Descriptive statistics.
Computes and displays a table of means, medians, maximum and minimum values, stan-
dard deviations, and other descriptive statistics of one or more series or a group of series.
When used as a command, stats creates an untitled group containing all of the specified
series and opens a statistics view of the group. By default, if more than one series is given,
the statistics are calculated for the common sample.
When used for coef or matrix objects, stats computes the statistics for each column of
data.
Syntax
Command: stats(options) ser1 ser2 ser3
Object View: group_name.stats(options)
Options
Examples
stats height weight age
opens an untitled group window displaying the histogram and descriptive statistics for the
common sample of the three series.
group group1 wage hrs edu
group1.stats(i)
displays the descriptive statistics view of GROUP1 for the individual samples.
Cross-references
See Descriptive Statistics on page 152 and page 208 of the Users Guide for a discussion
of the descriptive statistics views of series and groups.
statusline Command
Displays a message in the status line at the bottom of the EViews main window. The mes-
sage may include text, control variables, and string variables.
Syntax
Command: statusline message
Examples
statusline Iteration Number: !t
Displays the message Iteration Number: !t in the status line replacing !t with the cur-
rent value of the control variable in the program.
Cross-references
See Chapter 6, EViews Programming, on page 83 of the Command and Programming
Reference for a discussion and examples of programs, control variables and string vari-
ables.
Syntax
Series Proc: stom(series, vector, sample)
Group Proc: stom(group, matrix, sample)
Include the series or group name in parentheses followed by a comma and the vector or
matrix name. By default, the series values in the current workfile sample are used to fill
the vector or matrix; you may optionally provide an alternative sample.
There are two important features of stom that you should keep in mind:
If any of the series contain NAs, those observations will be dropped from the vector/
matrix (for alternative behavior, see stomna, below).
If the vector or matrix already exists in the workfile, EViews automatically resizes
the vector/matrix to fit the series/group.
336Chapter
336 8. Command Reference
Examples
series lwage=log(wage)
stom(lwage,vec1)
converts the series LWAGE into a vector named VEC1 using the current workfile sample.
Any NAs in LWAGE will be dropped from VEC1.
group rhs x1 x2 x3
sample s1 1951 1990
stom(rhs,x,s1)
converts a group of three series named X1, X2 and X3 to a matrix named X using sample
S1. The matrix X will have 40 rows and 3 columns (provided there are no NAs).
Cross-references
See Chapter 4, Matrix Language, on page 53 of the Command and Programming Refer-
ence for further discussion and examples of matrices.
Fills a vector or matrix with the data from a series or group without dropping observations
with missing values.
Works in identical fashion to stom, above, but does not drop observations containing NAs.
Syntax
Series Proc: stomna(series, vector, sample)
Group Proc: stomna(group, matrix, sample)
Include the series or group name in parentheses followed by a comma and the vector or
matrix name. By default, the series values in the current workfile sample are used to fill
the vector or matrix; you may optionally provide an alternative sample.
Examples
series lwage=log(wage)
stomna(lwage,vec1)
converts the series LWAGE into a vector named VEC1 using the current workfile sample.
Any NAs in LWAGE will be placed in VEC1.
store337
337
group rhs x1 x2 x3
sample s1 1951 1990
stom(rhs,x,s1)
converts a group of three series RHS to a matrix named X using sample S1. The matrix X
will always have 40 rows and 3 columns.
Cross-references
See Chapter 4, Matrix Language, on page 53 of the Command and Programming Refer-
ence for further discussion and examples of matrices.
Stores one or more objects in the current workfile in EViews databases or individual data-
bank files on disk. The objects are stored under the name that appears in the workfile.
When used as a pool proc, EViews will first expand the list of series using the pool opera-
tor, and then perform the fetch.
Syntax
Command: store(options) object_name_list
Pool Proc: pool_name.store(options) ser1? ser2?
Follow the store command with a list of the object names (each separated by a space)
that you wish to store. The default is to store the objects in the default database. (This
behavior is a change from EViews Version 2 and earlier where the default was to store
objects in individual databank files).
You can precede the object name with a database name and the double colon :: to indi-
cate a specific database. You can also specify the database name as an option in parenthe-
ses, in which case all objects without an explicit database name will be stored in the
specified database.
When used as a command, you may use wild card characters ? (to match any single
character) or * (to match zero or more characters) in the object name list. All objects
with names matching the pattern will be stored. You may not use ? as a wildcard charac-
ter if store is being used as a pool proc since this conflicts with the pool identifier.
338Chapter
338 8. Command Reference
You can optionally choose to store the listed objects in individual databank files. To store
in files other than the default path, you should include a path designation before the object
name.
Options
Examples
store m1 gdp unemp
stores the three objects M1, GDP, UNEMP in the default database.
stores M1 and GDP in the US1 database and UNEMP in the MACRO database.
stores the same object GDP in two different databases USDAT and MACRO.
store(1) cons*
stores all objects with names starting with CONS in the default database. The 1 option uses
single precision to save space.
store(i) m1 c:\data\unemp
Cross-references
Basic Data Handling on page 55 of the Users Guide discusses exporting data in other file
formats. See Chapter 6 of the Users Guide for a discussion of EViews databases and data-
bank files. For additional discussion of wildcards, see Appendix C, Wildcards, on
page 639 of the Users Guide.
Show view which summarizes the system transition matrices or the covariance structure of
the state space specification. EViews can display either the formulae or the values of the
system transition matrices or covariance. By default, EViews will display the formulae for
the system matrices.
Syntax
Sspace View: sspace_name.structure(options) [argument]
If you choose to display the values for a time-varying system using the v option, you
should use the optional [argument] to specify a single date at which to evaluate the matri-
ces. If none is provided, EViews will use the first date in the current sample.
Options
Examples
ss1.structure
Cross-references
See Chapter 22 of the Users Guide for a discussion of state space models.
340Chapter
340 8. Command Reference
Note that the EViews procedure is more general than textbook versions of SUR since the sys-
tem of equations may contain cross-equation restrictions on parameters.
Syntax
System Method: system_name.sur(options)
Options
Examples
sys1.sur(i)
estimates SYS1 by SUR, iterating simultaneously on the weighting matrix and coefficient
vector.
nlsys.sur(d,b,m=500)
estimates NLSYS by SUR using BHHH with up to 500 iterations. The d option displays
the starting values.
Cross-references
See Chapter 19 of the Users Guide for a discussion of system estimation.
Syntax
Var Proc: var_name.svar(options)
You must specify the identifying restrictions either in text form by the append proc or by a
pattern matrix option. See Specifying the Identifying Restrictions on page 513 of the
Users Guide for details on specifying restrictions.
Options
You must specify one of the following restriction type:
Other Options:
Examples
var var1.ls 1 4 m1 gdp cpi
matrix(3,3) pata
'fill matrix in row major order
pata.fill(by=r) 1,0,0, na,1,0, na,na,1
matrix(3,3) patb
pata.fill(by=r) na,0,0, 0,na,0, 0,0,na
var1.svar(rtype=patsr,namea=pata,nameb=patb)
sym343
343
The first line declares and estimates a VAR with three variables. Then we create the short-
run pattern matrices and estimate the factorization matrix.
var var1.ls 1 8 dy u @
var1.append(svar) @lr1(@u1)=0
freeze(out1) var1.svar(rtype=text)
The first line declares and estimates a VAR with two variables without a constant. The next
two lines specify a long-run restriction in text form and stores the estimation output in a
table object named OUT1.
Cross-references
See Structural (Identified) VARs on page 513 of the Users Guide for a discussion of struc-
tural VARs.
Syntax
Command: sym(n) sym_name
Command: sym(n) sym_name=assignment
sym takes an optional argument n specifying the row and column dimension of the matrix
and is followed by the name you wish to give the matrix.
You may also include an assignment in the sym command. The symmetric matrix will be
resized, if necessary. Once declared, symmetric matrices may be resized by repeating the
sym command for a given matrix name.
You may use sym instead of matrix for working with symmetric matrices.
Examples
sym mom
declares a symmetric matrix Y and assigns to it the inner product of the matrix X.
344Chapter
344 8. Command Reference
Cross-references
See Matrix Language on page 53 of the Command and Programming Reference for a dis-
cussion of matrix objects in EViews.
The system command declares an object as a system for estimation by system methods
such as three-stage least squares.
Syntax
Command: system system_name
Follow the system keyword by a name for the system. If you do not provide a name,
EViews will open an untitled system object (if in interactive mode).
Examples
system mysys
Cross-references
Chapter 19 of the Users Guide provides a full discussion of system objects.
See ls (p. 239), wls (p. 364), tsls (p. 355), wtsls (p. 369), 3sls (p. 134), and gmm
(p. 216) for various system estimation methods.
If you apply template to a multiple graph object, the template options will be applied to
each graph in the multiple graph. If the template graph is a multiple graph, the options of
the first graph will be used.
Syntax
Graph Proc: graph_name.template(options) template_graph_name
testadd345
345
Follow the name of the graph you want to apply the template options with a period, the
keyword template, and the name of the graph object to use as a template.
Options
Examples
gra_cs.template gra_gdp
applies the option settings in the graph object GRA_GDP to the graph GRA_CS. Text and
shadings in GRA_GDP will not be applied to GRA_CS.
g1.template(t) mygraph1
applies the option settings of MYGRAPH1 and all text and shadings in the graph to the
graph G1.
Cross-references
See Graph Templates on page 241 of the Users Guide for additional discussion.
Tests the hypothesis that the listed variables were incorrectly omitted from the (default)
equation. The test displays the Wald and LR test statistics and the test regression.
Syntax
Command: testadd ser1 ser2 ser3
Equation View: eq_name.testadd ser1 ser2 ser3
List the names of the series or groups of series to test for omission after the add keyword.
The command form applies the test to the default equation.
Options
Examples
ls sales c adver lsales ar(1)
346Chapter
346 8. Command Reference
tests whether GDP and GDP(-1) belong in the specification for SALES. The commands
equation oldeq.ls sales c adver lsales ar(1)
oldeq.testadd gdp gdp(-1)
Cross-references
See Coefficient Tests on page 352 of the Users Guide for further discussion.
Test equality of the mean, median or variance between (among) series in a group.
Syntax
Group View: group_name.testbtw(options)
Options
Examples
group g1 wage_m wage_f
g1.testbtw
g1.testbtw(var,c)
tests the equality of means between the two series WAGE_M and WAGE_F.
Cross-references
See Tests of Equality on page 208 of the Users Guide for further discussion of these tests.
testby347
347
Test equality of the mean, median, or variance of a series across categories classified by a
list of series or a group.
Syntax
Series View: series_name.testby(options) ser1 ser2 ser3
Follow the testby keyword by a list of the names of the series to use as classifiers. Specify
the type of test as an option.
Options
Examples
wage.testby(med) race
Cross-references
See Equality Tests by Classification on page 159 of the Users Guide for a discussion of
equality tests.
Tests the hypothesis that the listed variables were incorrectly included in the (default)
equation. The test displays the F and LR test statistics and the test regression.
Syntax
Command: testdrop ser1 ser2 ser3
Equation View: eq_name.testdrop ser1 ser2 ser3
List the names of the series or groups of series to test for omission after the add keyword.
The command form applies the test to the default equation.
Options
Examples
ls sales c adver lsales ar(1)
testdrop adver
tests whether ADVER should be excluded from the specification for SALES. The commands
equation oldeq.ls sales c adver lsales ar(1)
oldeq.testdrop adver
Cross-references
See Coefficient Tests on page 352 of the Users Guide for further discussion of testing
coefficients.
Syntax
Var View: var_name.testexog(options)
Options
name= Save the Wald test statistics in named matrix object. See below
for a description of the statistics stored in the matrix.
p Print output from the test.
The name= option stores a ( k + 1) ´ k matrix, where k is the number of endogenous vari-
ables in the VAR. For the first k rows, the i-th row, j-th column entry is the Wald statistic
for the joint significance of lags of the i-th endogenous variable in the j-th equation. (Note
that the entries in the main diagonal are not reported in the table view). The degrees of
freedom of the Wald statistics for the first k rows is the number of lags you included in the
VAR.
The j-th column of the last row contains the Wald statistic for the joint significance of all
lagged endogenous variables (excluding lags of the dependent variable) in the j-th equa-
tion. The degrees of freedom of the Wald statistics in the last row is ( k - 1) times the
number of lags you included in the VAR.
Examples
var var1.ls 1 6 lgdp lm1 lcpi
freeze(tab1) var1.testexog(name=exog)
The first line declares and estimates a VAR. The second line stores the exclusion test results
in a named table TAB1 and stores the Wald statistics in a matrix named EXOG.
Cross-references
See Diagnostic Views on page 504 of the Users Guide for a discussion other VAR diag-
nostics.
Carry out the Hosmer-Lemeshow and/or Andrews goodness-of-fit tests for binary models.
Syntax
Equation View: binary_equation.testfit(options)
Options
Examples
equation eq1.binary work c age edu
eq1.testfit(h,5,u)
Cross-references
See Goodness-of-Fit Tests on page 415 of the Users Guide for a discussion of the
Andrews and Hosmer-Lemeshow tests.
testlags351
351
Syntax
Var View: var_name.testlags(options)
Options
name= Save the Wald test statistics in named matrix object. See
below for a description of the statistics contained in the
stored matrix.
p Print the result of the test.
The i-th row of the last column contains the system Wald statistic for testing the joint sig-
nificance of all i-th lagged endogenous variables in the VAR system. The system Wald sta-
2
tistics has a chi-square distribution with k degrees of freedom under the exclusion null.
Examples
var var1.ls 1 6 lgdp lm1 lcpi
freeze(tab1) var1.testlags(name=lags)
The first line declares and estimates a VAR. The second line stores the lag exclusion test
results in a table named TAB1 and stores the Wald statistics in a matrix named LAGS.
Cross-references
See Diagnostic Views on page 504 of the Users Guide for a discussion other VAR diag-
nostics.
Test simple hypotheses of whether the mean, median, or variance of a series is equal to a
specified value.
Syntax
Series View: series_name.teststat(options)
Specify the type of test and the value under the null hypothesis as an option.
Options
mean=number Test the null hypothesis that the mean equals the speci-
fied number.
med=number Test the null hypothesis that the median equals the
specified number.
var=number Test the null hypothesis that the variance equals the
specified number. The number must be positive.
std=number Test equality of mean conditional on the specified stan-
dard deviation. The standard deviation must be posi-
tive.
p Print the test results.
Examples
smpl if race=1
lwage.teststat(var=4)
tests the null hypothesis that the variance of LWAGE is equal to 4 for the subsample with
RACE=1.
Cross-references
See Tests for Descriptive Stats on page 156 of the Users Guide for a discussion of simple
hypothesis tests.
Declare a text object when used as a command, or display text representation of the
model specification.
Syntax
Command: text text_name
Model View: model_name.text(options)
Follow the text keyword with a name for the text object. When used as a model view,
text is equivalent to spec (p. 327).
Options
Examples
text notes1
Cross-references
See Chapter 23 of the Users Guide for further details on models. See Chapter 10 of the
Users Guide for a discussion of text objects in EViews.
tic Command
Syntax
Command: tic
Examples
The sequence of commands
tic
[some commands]
toc
354Chapter
354 8. Command Reference
resets the timer, executes commands, and then displays the elapsed time in the statusline.
Alternatively,
tic
[some commands]
!elapsed = @toc
resets the time, executes commands, and saves the elapsed time in the control variable
!ELAPSED.
Cross-references
See also toc (p. 354) and @toc (p. 415).
toc Command
Syntax
Command: toc
Examples
The sequence of commands
tic
[some commands]
toc
resets the timer, executes commands, and then displays the elapsed time in the statusline,
while the set of commands
tic
[some commands]
!elapsed = @toc
resets the time, executes commands, and saves the elapsed time in the control variable
!ELAPSED.
Cross-references
See also tic (p. 353) and @toc (p. 415).
tsls355
355
Display trace view of a model showing iteration history for selected solved variables.
Syntax
Model View: model_name.trace(options)
Options
Cross-references
See Diagnostics on page 619 of the Users Guide for further details on tracing model solu-
tions.
See also msg (p. 263), solve (p. 323) and solveopt (p. 324).
Carries out estimation for equations or systems using two-stage least squares.
Syntax
Command: tsls(options) y x1 x2 @ z1 z2 z3
tsls(options) formula @ z1 z2 z3
Equation Method: eq_name.tsls(options) y x1 x2 @ z1 z2 z3
eq_name.tsls(options) formula @ z1 z2 z3
System Method: system_name.tsls(options)
To use tsls as a command or equation method, list the dependent variable first, followed
by the regressors, then any AR or MA error specifications, then an @-sign, and finally, a
list of exogenous instruments. There must be at least as many instrumental variables as
there are independent variables. All exogenous variables included in the regressor list
should also be included in the instrument list. A constant is included in the list of instru-
mental variables even if not explicitly specified. You can estimate nonlinear equations or
equations specified with formulas; always list the instrumental variables after an @-
sign.
356Chapter
356 8. Command Reference
Options
General options
Examples
eq1.tsls y_d c cpi inc ar(1) @ lw(-1 to -3)
estimates EQ1 using TSLS regression of Y_D on a constant, CPI, INC with AR(1) using a
constant, LW(-1), LW(-2), LW(-3) as instruments.
param c(1) .1 c(2) .1
eq1.tsls(s,m=500) y_d=c(1)+inc^C(2) @ cpi
estimates a nonlinear TSLS model using a constant and CPI as instruments. The first line
sets the starting values for the nonlinear iteration algorithm.
sys1.tsls
Cross-references
See Two-stage Least Squares on page 275 and page 481 of the Users Guide for details on
two-stage least squares estimation in single equations and systems.
See also ls (p. 239). For estimation of weighted TSLS in systems, see wtsls (p. 369).
358Chapter
358 8. Command Reference
updatecoefs Equation Proc | Logl Proc | Pool Proc | Sspace Proc | System Proc
Update coefficients.
Copies coefficients from the estimation object into the appropriate coefficient vector or
vectors.
Syntax
Object Proc: object.updatecoef
Follow the name of the estimation object by a period and the keyword updatecoef.
Examples
equation eq1.ls y c x1 x2 x3
equation eq2.ls z c z1 z2 z3
eq1.updatecoef
updates the coefficient vector A and the default vector C so that both contain the coeffi-
cients from EQ3.
Cross-references
See also coef (p. 162).
Carries out the Augmented Dickey-Fuller (ADF) or Phillips-Perron (PP) test for the speci-
fied series.
Syntax
Command: uroot(options) series_name
Series View: series_name.uroot(options)
uroot359
359
You should enter the keyword uroot followed by the series name, or the series name fol-
lowed by a period and the keyword uroot. You must specify the form of the test equation
using one of the listed options.
Options
Specify the exogenous variables in the test equation from the following options:
You must also specify the number of lagged differenced terms to include in the test equa-
tion (for the ADF test) or the truncation lag (for the PP test). Specify the lag as a nonnega-
tive integer.
Other Options:
Examples
uroot(t,2) gdp
performs an augmented Dickey-Fuller test of GDP with a constant, linear trend, and 2
lagged differenced terms.
tbill3.uroot(c,4,h)
computes a Phillips-Perron test of TBILL3 with a constant and Newey-West lag truncation
at lag 4.
Cross-references
See Unit Root Tests on page 321 of the Users Guide for further discussion.
360Chapter
360 8. Command Reference
Syntax
Command: var var_name
Command: var var_name.ls lag_pairs y1 y2 @ x1 x2
Command: var var_name.ec(options) specification
Declare the var as a name, or a name followed by an estimation method (either ls or ec).
The ls method estimates an unrestricted VAR using equation-by-equation OLS. You must
specify the order of the VAR (using one or more pairs of lag intervals), and then provide a
list of endogenous variables. You may include exogenous variables such as trends and sea-
sonal dummies in the VAR by including an @-sign followed by a list of series. A constant
is always included as an exogenous variable.
Options
Examples
var mvar.ls 1 4 8 8 m1 gdp tb3 @ @trend(70.4)
declares and estimates an unrestricted VAR named MVAR with three endogenous variables
(M1, GDP, TB3), five lagged terms (lags 1 through 4 and 8), a constant, and a linear trend.
declares and estimates an error correction model named JVAR with three endogenous vari-
ables (M1, GDP, TB3), four lagged terms (lags 1 through 4) including two cointegrating
relations. The c option assumes a linear trend in data but only a constant in the cointe-
grating relations.
Cross-references
See Chapter 20 of the Users Guide for a discussion of vector autoregressions.
Display the model in variable form with identification of endogenous, exogenous, and
identity variables, as well as dependency tracking.
Syntax
Model View: model_name.vars
Cross-references
See Variable View on page 604 of the Users Guide for details. See Chapter 23 of the
Users Guide for a general discussion of models.
See also block (p. 152), text (p. 353), and eqs (p. 197) for alternative representations of
the model.
The vector command declares and optionally initializes a (column) vector object.
Syntax
Command: vector(size) name
Command: vector(size) name=assignment
The vector keyword should be followed by the name you wish to give the vector. vec-
tor also takes an optional argument specifying the size of the vector. Once declared, vec-
tors may be resized by repeating the vector command.
You may combine vector declaration and assignment. If there is no assignment statement,
the vector will initially be filled with zeros.
Examples
vector vec1
vector(20) vec2=nrnd
rowvector(10) row3=3
vector vec3=row3
362Chapter
362 8. Command Reference
VEC1 is declared as a column vector of size one with element 0. VEC2 is declared as a col-
umn vector of size 20 containing a simulated random draw from the standard normal dis-
tribution. Although declared as a column vector, VEC3 is reassigned as a row vector of size
10 with all elements equal to 3.
Cross-references
See Chapter 4, Matrix Language, on page 53 of the Command and Programming Refer-
ence for a discussion of matrices and vectors in EViews.
wald Equation View | Logl View | Pool View | Sspace View | System View
The wald view carries out a Wald test of coefficient restrictions for an estimation object.
Syntax
Object View: object_name.wald restrictions
Enter the object name, followed by a period, and the keyword wald. This should be fol-
lowed by a list of the coefficient restrictions. Joint (multiple) coefficient restrictions should
be separated by commas.
Options
Examples
eq1.wald c(2)=0, c(3)=0
tests the null hypothesis that the second and third coefficients in equation EQ1 are jointly
zero.
sys1.wald c(2)=c(3)*c(4)
tests the non-linear restriction that the second coefficient is equal to the product of the
third and fourth coefficients in SYS1.
pool panel us uk jp
panel.ls cons? inc? @ ar(1)
panel.wald c(3)=c(4)=c(5)
white363
363
declares a pool object with three cross section members (US, UK, JP), estimates a pooled
OLS regression with separate AR(1) coefficients, and tests the null hypothesis that all
AR(1) coefficients are equal.
Cross-references
See Wald Test (Coefficient Restrictions) on page 352 of the Users Guide for a discussion
of Wald tests.
Carries out Whites test for heteroskedasticity to the residuals of the specified equation. By
default, the test is computed without the cross-product terms (using only the terms involv-
ing the original variables and squares of the original variables). You may elect to compute
the original form of the White test including the cross-products.
Whites test is not available for equations estimated by binary, ordered, censored, or
count. For a var object, the white command computes the multivariate version of the
test.
Syntax
Equation View: eq_name.white(options)
Var View: var_name.white(options)
Options
name= Save test statistics in named matrix object. See below for a
description of the statistics stored in the matrix.
For var views, the name= option stores a (r + 1) ´ 5 matrix, where r is the number of
unique residual cross-product terms. For a VAR with k endogenous variables, r = k
(k + 1) / 2. The first r rows contain statistics for each individual test equation, where the
364Chapter
364 8. Command Reference
first column is the regression R-squared, the second column is the F-statistic, the third col-
2
umn is the p-value of F-statistic, the 4th column is the T × R chi-square statistic, and the
fifth column is the p-value of the chi-square statistic. The numerator and denominator
degrees of freedom of the F-statistic are stored in the (r + 1)-st row, third and fourth col-
umns, while the chi-square degrees of freedom is stored in the (r + 1)-st row, fifth col-
umn.
In the (r + 1)-st row and first column contains the joint (system) LM chi-square statistic
and the second column contains the degrees of freedom of this chi-square statistic.
Examples
eq1.white(c)
carries out the White test of heteroskedasticity including all possible cross-product terms.
Cross-references
See White's Heteroskedasticity Test on page 362 of the Users Guide for a discussion of
Whites test. For the multivariate version of this test, see page 508 of the Users Guide.
wls estimates a system of equations using weighted least squares. To perform weighted
least squares in single equation estimation, see ls (p. 239).
Syntax
System Method: system_name.wls(options)
Options
Examples
sys1.wls
Cross-references
See Chapter 19 of the Users Guide for a discussion of system estimation.
See also the available options for weighted least squares in ls (p. 239).
workfile Command
Syntax
Command: workfile name
Command: workfile name frequency start end
dates for the workfile (see Creating a Workfile on page 34 of the Users Guide for the
rules of specifying dates). Once you specify the information, EViews will create an untitled
workfile of the specified type.
You may also use the keyword workfile followed by a name for a workfile. If a workfile
with that name is already loaded into memory, the workfile will become active.
If you specify workfile with a name, followed by a frequency code and a start and end
date or observation, a new workfile will be created.
Options
The frequency codes for workfiles are:
a Annual.
s Semi-annual.
q Quarterly.
m Monthly.
w Weekly.
d Daily (5 day week).
7 Daily (7 day week).
u Undated or irregular.
Examples
workfile test
either makes the loaded workfile named TEST active or brings up a dialog to create a new
workfile named TEST.
Cross-references
See Creating a Workfile on page 34 of the Users Guide and Appendix B, Date Formats,
on page 635 of the Users Guide for a discussion of frequencies and rules for composing
dates in EViews.
write367
367
See also create (p. 174), load (p. 237) and open (p. 267).
Command || Coef Proc | Matrix Proc | Pool Proc | Sym Proc | Vector
write Proc
The write command creates a foreign format disk file containing any number of series.
You should use write when you wish to export EViews data to another program.
Syntax
Command: write(options) path\file name1 name2 name3
Pool Proc: pool_name.write(options) path\file n1? n2? n3?
Coef Proc: coef_name.write(options) path\file
Matrix Proc: matrix_name.write(options) path\file
Follow the write keyword by a name for the output file and list the series to be written.
The optional path name may be on the local machine, or may point to a network drive. If
the path name contains spaces, enclose the entire expression in double quotation marks.
To write matrix objects, simply provide a filename; the entire matrix will be exported.
Options
Options are specified in parentheses after the write keyword and are used to specify the
format of the output file.
File type
If you omit the t= option, EViews will determine the type based on the file extension.
Unrecognized extensions will be treated as ASCII files. For Lotus and Excel spreadsheet
files specified without the t= option, EViews will automatically append the appropriate
extension if it is not otherwise specified.
ASCII text files
Examples
write(t=txt,na=.,d=c,dates) a:\dat1.csv hat1 hat_se1
Writes the two series HAT1 and HAT_SE1 into an ASCII file named DAT1.CSV on the A
drive. The data file is listed by observations, NAs are coded as . (dot), each series is sep-
arated by a comma, and the date/observation numbers are written together with the series
names.
writes an Excel file GROWTH.XLS in the specified directory. The data are organized by
observations and are listed by period/time.
Cross-references
See Exporting to a Spreadsheet or Text File. on page 71 of the Users Guide for a discus-
sion.
wtsls estimates a system of equations using weighted two-stage least squares. To perform
weighted two-stage least squares in a single equation, see ls (p. 239).
Syntax
System Method: system_name.wtls(options)
370Chapter
370 8. Command Reference
Options
Examples
sys1.wtsls
Cross-references
See Weighted Two-Stage Least Squares on page 481 of the Users Guide for further dis-
cussion.
x11371
371
See also tsls (p. 355) for both unweighted and weighted single equation 2SLS.
Syntax
Series Proc: series_name.x11(options) adj_name fac_name
The X11 procedure carries out Census X11.2 seasonal adjustment. Enter the name of the
original series followed by a period, the keyword x11 and then provide a name for the sea-
sonally adjusted series. You may optionally list a second series name for the seasonal fac-
tors. The seasonal adjustment method is specified as an option in parentheses after the
x11 keyword.
The X11 procedure is available only for quarterly and monthly series. The procedure
requires at least four full years of data, and can adjust up to 20 years of monthly data and
30 years of quarterly data.
Options
m Multiplicative seasonals.
a Additive seasonals.
s Use sliding spans.
h Adjustment for all holidays (only for monthly data spec-
ified with the m option).
i Adjustment for holidays if significant (only for monthly
data specified with the m option).
t Adjustment for all trading days (only for monthly data).
q Adjustment for trading days if significant (only for
monthly data).
p Print the X11 results.
Examples
sales.x11(m,h) salesx11 salesfac
seasonally adjusts the SALES series and saves the adjusted series as SALESX11 and the sea-
sonal factors as SALESFAC. The adjustment assumes multiplicative seasonals and makes
adjustment for all holidays.
372Chapter
372 8. Command Reference
Cross-references
See Census X11 (Historical) on page 182 of the Users Guide for a discussion of Census
X11 seasonal adjustment method.
Note that the X11 routines are separate programs provided by the Census and are installed
in the EViews directory in the files X11Q2.EXE and X11SS.EXE. The documentation for
these programs can also be found in your EViews directory as text files X11DOC1.TXT
through X11DOC3.TXT.
See also seas (p. 305), seasplot (p. 306) and x12 (p. 372).
x12 is available only for quarterly and monthly series. The procedure requires at least 3
full years of data and can adjust up to 600 observations (50 years of monthly data or 150
years of quarterly data).
Syntax
Series Proc: series_name.x12(options) adj_base_name
Enter the name of the original series followed by a dot, the x12 keyword, and then provide
a base name (no more than the maximum length of a series name minus 4) for the saved
series. If you ask to save any series, they will be given names with the base name
appended with the extensions specified in the save option.
Options
Commonly Used Options
Other Options
To provide your own specification file, specify the path/name of your file using the
sfile= option in the x12 proc. Your specification file should follow the format of an X12
specification file as described in the X12-ARIMA Reference Manual, except
the specification file should not have a series spec nor a composite spec.
the x11 spec must have a save option for D11 (the final seasonally adjusted series)
and any other extensions you want to store. EViews will always look for D11 and
will error if not found.
to read back data for a save option other than D11, you must use the save= option
in the x12 proc. For example, to get back the final trend-cycle series (D12) into
EViews, you must have a save= option for D12 (and D11) in the x11 spec of your
specification file and a save=d12" option in the EViews x12 proc.
Note that when you use an sfile= option, EViews will ignore any other options in the
x12 proc, except for the save= option.
Difference between the dialog and command line
The options corresponding to the Trading Day/Holiday and Outliers tab in the X12 dialog
should be specified by listing the appropriate regressors in the x11reg= and reg=
options.
Examples
sales.x12(mode=m,save="d10 d12") salesx12
seasonally adjusts the SALES series in multiplicative mode. The seasonally adjusted series
is stored as SALESX12, the seasonal factors is stored as SALESX12_D10, and the trend-
cycles series is stored as SALESX12_D12.
xyline377
377
specifies a regARIMA model with a constant, trading day effect variables, and MA(1) using
a log transformation. The seasonally adjusted series is stored as SALES_SA by default.
stores the output from X12 in a text object named X12OUT. The options specify an auto-
matic transformation and an automatic model selection from the file MYMDL.TXT. The
seasonally adjusted series is stored as SALES_SA by default.
revenue.x12(tf=auto,sfile="c:\eviews\spec1.txt",save="d12
d13")
adjusts the series REVENUE using the options given in the SPEC1.TXT file. Note the fol-
lowing: (1) the tf=auto option will be ignored (you should specify this in your specifica-
tion file) and (2) EViews will error if you did not specify a save option for D11, D12, and
D13 in your specification file.
Cross-references
See Census X12 on page 175 of the Users Guide for a discussion of the Census X12 pro-
gram. The documentation for X12, X12-ARIMA Reference Manual, can be found in the
DOCS subdirectory of your EViews directory in the PDF files FINALPT1.PDF and
FINALPT2.PDF.
XY line graph.
The xyline view of a graph object changes the graph to XY line (if possible). The xyline
view of a group displays an XY plot.
By default, the first series or column of data will be located along the horizontal axis and
the remaining data on the vertical axis. You may optionally choose to plot the data in pairs,
where the first two series or columns are plotted against each other, the second two series
or columns are plotted against each other, and so forth.
When used as a group or matrix view, there must be at least series or columns in the
object.
378Chapter
378 8. Command Reference
Syntax
Graph Proc: graph_name.xyline(options)
Group View: group_name.xyline(options)
Options
Options may be specified in parentheses after the xyline keyword.
Template and printing options
Scale options
Examples
group g1 inf unemp gdp inv
g1.xyline
plots INF on the horizontal axis and UNEMP, GDP and INV on the vertical axis.
g1.xyline(b)
g1.xyline(b,m)
plots INF against UNEMP and GDP against INV in first in a single graph, and then in mul-
tiple graphs.
xyline379
379
Cross-references
See XY Line on page 204 of the Users Guide for additional details.
See also graph (p. 219) for additional graph types. See also options (p. 268) for graph
options.
380Chapter
380 8. Command Reference
Chapter 9. Matrix and String Reference
Syntax: @cholesky(s)
Argument: sym, s
Return: matrix
Syntax: colplace(m, v, n)
Argument 1: matrix, m
Argument 2: vector, v
Argument 3: integer, n
Places the column vector v into the matrix m at column n. The number of rows of m and v
must match, and the destination column must already exist within m. Example:
colplace(m1,v1,3)
Syntax: @columnextract(m, n)
Argument 1: matrix or sym, m
Argument 2: integer, n
Return: vector
382Chapter
382 9. Matrix and String Reference
Extract a vector from column n of the matrix object m, where m is a matrix or sym.
Example:
vector v1 = @columnextract(m1,3)
Note that while you may extract the first column of a column vector, or any column of a
row vector, the command is more easily executed using simple element or vector assign-
ment in these cases.
Syntax: @columns(o)
Argument: matrix, vector, rowvector, sym, scalar, or series, o
Return: integer
Usage: @cond(o, n)
Argument 1: matrix or sym, o
Argument 2: (optional) scalar n
Return: scalar
Returns the condition number of a square matrix or sym, o. If no norm is specified, the
infinity norm is used to determine the condition number. The condition number is the
product of the norm of the matrix divided by the norm of the inverse. Possible norms are -
n
1 for the infinity norm, 0 for the Frobenius norm, and an integer n for the L norm.
Example:
scalar sc1 = @cond(m1)
mat1(1,4) = @cond(s1,2)
@cor383
383
If o is a series, @convert returns a vector from the values of o using the optional sample
smp or the current workfile sample. If any observation has the value NA, the observation
will be omitted from the vector. Examples:
vector v2 = @convert(ser1)
vector v3 = @convert(ser2,smp1)
If o is a group, @convert returns a matrix from the values of o using the optional sample
object smp or the current workfile sample. The series in o are placed in the columns of the
resulting matrix in the order they appear in the group spreadsheet. If any of the series for a
given observation, has the value NA, the observation will be omitted for all series. For
example,
matrix m1=@convert(grp1)
matrix m2=@convert(grp1, smp1)
For a conversion method that preserves NAs, see stomna (p. 399) .
Syntax: @cor(o)
Argument: matrix object or group, o
Return: sym
If used with two vector or series objects, v1 and v2, @cor returns the correlation between
the two vectors or series. Examples:
scalar sc1 = @cor(v1,v2)
384Chapter
384 9. Matrix and String Reference
s1(1,2) = @cor(v1,r1)
If used with a matrix object or group, o, @cor calculates the correlation matrix between
the columns of the matrix object.
scalar sc2 = @cor(v1,v2)
mat3(4,2) = 100*@cor(r1,v1)
For series and group calculations, EViews will use the current workfile sample. See also
@cov (p. 384).
Syntax: @cov(o)
Argument: matrix object or group, o
Return: sym
If used with two vector or series objects, v1 and v2, @cov returns the covariance between
the two vectors or series. Examples:
scalar sc1 = @cov(v1, v2)
s1(1,2) = @cov(v1, r1)
If used with a matrix object or group, o, @cov calculates the covariance matrix between
the columns of the matrix object.
!1 = @cov(v1, v2)
mat3(4,2) = 100*@cov(r1, v1)
For series and group calculations, EViews will use the current workfile sample. See also
@cor (p. 383).
Syntax: @det(m)
Argument: matrix or sym, m
Return: scalar
@eigenvalues385
385
Calculate the determinant of the square matrix or sym, m. The determinant is nonzero for
a nonsingular matrix and 0 for a singular matrix. Example:
scalar sc1 = @det(m1)
vec4(2) = @det(s2)
Syntax: @dtoo(str)
Argument: string, str
Return: integer
Suppose that the workfile contains quarterly data. Then the second example places the
1957:02 value of the GDP series in the first element of VEC1.
Usage: @eigenvalues(s)
Argument: sym, s
Return: vector
Returns a vector containing the eigenvalues of the sym. The eigenvalues are those scalars
l that satisfy Sx = lx. where S is the sym associated with the argument s. Associated
with each eigenvalue is an eigenvector (see @eigenvectors (p. 386)). The eigenvalues
are arranged in ascending order.
Example:
386Chapter
386 9. Matrix and String Reference
vector v1 = @eigenvalues(s1)
Syntax: @eigenvectors(s)
Argument: sym, s
Return: matrix
Returns a square matrix, of the same dimension as the sym, whose columns are the eigen-
vectors of the source matrix. Each eigenvector v satisfies Sv=nv, where S is the symmetric
matrix given by s, and where n is the eigenvalue associated with the eigenvector v. The
eigenvalues are arranged in ascending order, and the columns of the eigenvector matrix
correspond to the sorted eigenvalues. Example:
matrix m2 = @eigenvectors(s1)
Syntax: @explode(s)
Argument: sym, s
Return: matrix
Creates a square matrix from a sym, s, by duplicating the lower triangle elements into the
upper triangle. Example:
matrix m2 = @explode(s1)
Returns a matrix with n1 rows and n2 columns, where each element contains the value n3.
Example:
matrix m2 = @filledmatrix(3,2,7)
creates a 3 ´ 2 matrix where each element is set to 7. See also fill (p. 203).
Returns a rowvector of length n1, where each element contains the value n2. Example:
rowvector r1 = @filledrowvector(3,1)
creates a 3 element rowvector where each element is set to 1. See also fill (p. 203).
creates a 3 ´ 3 sym where each element is set to 9. See also fill (p. 203).
Returns a vector of length n1, where each element contains the value n2. Example:
388Chapter
388 9. Matrix and String Reference
vector r1 = @filledvector(5,6)
creates a 5 element column vector where each element is set to 6. See also fill (p. 203).
Syntax: @getmaindiagonal(m)
Argument: matrix or sym, m
Return: vector
Returns a vector created from the main diagonal of the matrix or sym object. Example:
vector v1 = @getmaindiagonal(m1)
vector v2 = @getmaindiagonal(s1)
Syntax: @identity(n)
Argument: integer, n
Return: matrix
matrix i1 = @identity(4)
Syntax: @implode(m)
Argument: square matrix, m
Return: sym
Forms a sym by copying the lower triangle of a square input matrix, m. Where possible,
you should use a sym in place of a matrix to take advantage of computational efficiencies.
Be sure you know what you are doing if the original matrix is not symmetricthis function
does not check for symmetry. Example:
sym s2 = @implode(m1)
If used with two vectors, v1 and v2, @inner returns the dot or inner product of the two
vectors. Examples:
scalar sc1 = @inner(v1, v2)
s1(1,2) = @inner(v1, r1)
If used with two series, @inner returns the inner product of the series using observations
in the workfile sample. You may provide an optional sample.
If used with a matrix or sym, o, @inner returns the inner product, or moment matrix, o′o.
Each element of the result is the vector inner product of two columns of the source matrix.
The size of the resulting sym is the number of columns in o. Examples:
scalar sc1 = @inner(v1)
sym sym1 = @inner(m1)
If used with a group, @inner returns the uncentered second moment matrix of the data in
the group, g, using the observations in the sample, smp. If no sample is provided, the
workfile sample is used. Examples:
sym s2 = @inner(gr1)
sym s3 = @inner(gr1, smp1)
Syntax: @inverse(m)
Argument: square matrix or sym, m
Return: matrix or sym
Returns the inverse of a square matrix object or sym. The inverse has the property that the
product of the source matrix and its inverse is the identity matrix. The inverse of a matrix
returns a matrix, while the inverse of a sym returns a sym. Note that inverting a sym is
much faster than inverting a matrix.
Examples:
matrix m2 = @inverse(m1)
sym s2 = @inverse(s1)
sym s3 = @inverse(@implode(m2))
Syntax: @issingular(o)
Argument: matrix or sym, o
Return: integer
Returns 1 if the square matrix or sym, o, is singular, and 0 otherwise. A singular
matrix has a determinant of 0, and cannot be inverted.
Example:
Calculates the Kronecker product of the two matrix objects, o1 and o2. The resulting
matrix has a number of rows equal to the product of the numbers of rows of the two
matrix objects and a number of columns equal to the product of the numbers of columns
of the two matrix objects. The elements of the resulting matrix consist of submatrices con-
sisting of one element of the first matrix object multiplied by the entire second matrix
object.
Example:
matrix m3 = @kronecker(m1,m2)
Syntax: @left(str, n)
Argument 1: string, str
Argument 2: integer, n
Return: string
Returns a string containing n characters from the left end of str. If the string is shorter than
n characters, this function returns all of the characters in the source string.
Example:
returns I did.
Usage: @makediagonal(v, k)
Argument 1: vector or rowvector, v
Argument 2: (optional) integer, k
Return: matrix
Creates a square matrix with the specified vector or rowvector, v, in the k-th diagonal rela-
tive to the main diagonal, and zeroes off the diagonal. If no k value is provided or if k is set
to 0, the resulting matrix will have the same number of rows and columns as the length of
v, and will have v in the main diagonal. If a value for k is provided, the matrix has the
same number of rows and columns as the number of elements in the vector plus k, and
will place v in the diagonal offset from the main by k. Example:
392Chapter
392 9. Matrix and String Reference
matrix m1 = @makediagonal(v1)
matrix m2 = @makediagonal(v1,1)
matrix m4 = @makediagonal(r1,-3)
M1 will contain V1 in the main diagonal; M2 will contain V1 in the diagonal immediately
above the main diagonal; M4 will contain R1 in the diagonal 3 positions below the main
diagonal. Using the optional k parameter may be useful in creating covariance matrices for
AR models. For example, you can create an AR(1) correlation matrix by issuing the com-
mands:
matrix(10,10) m1
vector(9) rho = .3
m1 = @makediagonal(rho,-1) + @makediagonal(rho,+1)
m1 = m1 + @identity(10)
Places the matrix object m2 into m1 at row n1 and column n2. The sizes of the two matri-
ces do not matter, as long as m1 is large enough to contain all of m2 with the upper left
cell of m2 placed at row n1 and column n2.
Example:
matrix(100,5) m1
matrix(100,2) m2
matplace(m1,m2,1,1)
mtos393
393
Returns n2 characters from str, starting at location n1 and continuing to the right. If you
omit n2, it will return all of the remaining characters in the string.
Example:
%1 = @mid("I doubt it", 9, 2)
%2 = @mid("I doubt it", 9)
Convert matrix to a series or group. Fills a series or group with the data from a vector or
matrix.
Syntax
Vector Proc: mtos(vector, series[, sample])
Matrix Proc: mtos(matrix, group[, sample])
Examples
The command
mtos(mom,gr1)
converts the first column of the matrix MOM to the first series in the group GR1, the sec-
ond column of MOM to the second series in GR1, and so on. The current workfile sample
length must match the row length of the matrix MOM. If GR1 is an existing group object,
the number of series in GR1 must match the number of columns of MOM. If a group object
394Chapter
394 9. Matrix and String Reference
named GR1 does not exist, EViews creates GR1 with the first series named SER1, the sec-
ond series named SER2, and so on.
series col1
series col2
group g1 col1 col2
sample s1 1951 1990
mtos(m1,g1,s1)
The first two lines declare series objects, the third line declares a group object, the fourth
line declares a sample object, and the fifth line converts the columns of the matrix M1 to
series in group G1 using sample S1. This command will generate an error if M1 is not a
40 ´ 2 matrix.
Cross-references
See Chapter 4, Matrix Language, on page 53 for further discussions and examples of
matrices.
Syntax: @norm(o, n)
Argument 1: matrix, vector, rowvector, sym, scalar, or series, o
Argument 2: (optional) integer, n
Return: scalar
Returns the value of the norm of any matrix object, o. Possible choices for the norm type n
include 1 for the infinity norm, 0 for the Frobenius norm, and an integer n for the
n
L norm. If no norm type is provided, this function returns the infinity norm.
Examples:
scalar sc1 = @norm(m1)
scalar sc2 = @norm(v1,1)
Syntax: @otod(n)
Argument: integer, n
Return: string
@permute395
395
%1 = @otod(5)
For an annual workfile dated 19912000, %1 will contain the string 1995. For a quarterly
workfile dated 1970:12000:4, %1 will contain the string 1971:1. Note that @otod(1)
returns the date or observation label for the start of the workfile.
Calculates the cross product of v1 and v2. Vectors may be either row or column vectors.
The outer product is the product of v1 (treated as a column vector) and v2 (treated as a
row vector), and is a square matrix of every possible product of the elements of the two
inputs. Example:
matrix m1=@outer(v1,v2)
matrix m4=@outer(r1,r2)
Syntax: @permute(m1)
Input: matrix m1
Return: matrix
This function returns a matrix whose rows are randomly drawn without replacement from
rows of the input matrix m1. The output matrix has the same size as the input matrix.
matrix xp = @permute(x)
To draw with replacement from rows of a matrix, use @resample (p. 396).
396Chapter
396 9. Matrix and String Reference
Syntax: @rank(o, n)
Argument 1: vector, rowvector, matrix, sym, or series, o
Argument 2: (optional) integer, n
Return: integer
Returns the rank of the matrix object o. The rank is calculated by counting the number of
singular values of the matrix which are smaller in absolute value than the tolerance, which
is given by the argument n. If n is not provided, EViews uses the value given by the largest
dimension of the matrix multiplied by the norm of the matrix multiplied by machine epsi-
lon (the smallest representable number).
scalar rank1 = @rank(m1)
scalar rank2 = @rank(s1)
This function returns a matrix whose rows are randomly drawn with replacement from
rows of the input matrix.
n2 represents the number of extra rows to be drawn from the matrix. If the input matrix
has r rows and c columns, the output matrix will have r + n2 rows and c columns. By
default, n2=0.
n3 represents the block size for the resample procedure. If you specify n3 > 1, then blocks
of consecutive rows of length n3 will be drawn with replacement from the first r - n3 + 1
rows of the input matrix.
You may provide a name for the vector v4 to be used for weighted resampling. The weight-
ing vector must have length r and all elements must be non-missing and non-negative. If
@rowextract397
397
you provide a weighting vector, each row of the input matrix will be drawn with probabil-
ity proportional to the weights in the corresponding row of the weighting vector. (The
weights need not sum to 1. EViews will automatically normalize the weights).
matrix xb = @bootstrap(x)
To draw without replacement from rows of a matrix, use @permute (p. 395).
Syntax: @right(str, n)
Argument 1: string, str
Argument 2: integer, n
Return: same as source
Returns a string containing n characters from the right end of str. If the source is shorter
than n, the entire string is returned. Example:
Syntax: @rowextract(m, n)
Argument 1: matrix or sym, m
Argument 2: integer, n
Return: rowvector
rowvector r1 = @rowextract(m1,3)
Syntax: rowplace(m, r, n)
Argument 1: matrix, m
Argument 2: rowvector, r
Argument 3: integer
Places the rowvector r into the matrix m at row n. The number of columns in m and r must
match, and row n must exist within m. Example:
rowplace(m1,r1,4)
Syntax: @rows(o)
Argument: matrix, vector, rowvector, sym, series, or group, o
Return: scalar
Example:
scalar sc1=@rows(m1)
scalar size=@rows(m1)*@columns(m1)
For series and groups @rows (p. 398) returns the number of observations in the workfile
range. See also @columns (p. 382).
Usage: @solvesystem(o, v)
Argument 1: matrix or sym, o
Argument 2: vector, v
Return: vector
Returns the vector x that solves the equation Mx = v where the matrix or sym M is given
by the argument o. Example:
stomna399
399
vector v2 = @solvesystem(m1,v1)
Series-TO-Matrix Object. If o1 is a series, stom fills the vector o2 with data from the o1
using the optional sample object smp or the workfile sample. o2 will be resized accord-
ingly. If any observation has the value NA, the observation will be omitted from the vec-
tor. Example:
stom(ser1,v1)
stom(ser1,v2,smp1)
If o1 is a group, stom fills the matrix o2 with data from o1 using the optional sample object
smp or the workfile sample. o2 will be resized accordingly. The series in o1 are placed in
the columns of o2 in the order they appear in the group spreadsheet. If any of the series in
the group has the value NA for a given observation, the observation will be omitted for
all series. Example:
stom(grp1,m1)
stom(grp1,m2,smp1)
For a conversion method that preserves NAs, see stomna (p. 399) .
Series-TO-Matrix Object with NAs. If o1 is a series, stom fills the vector o2 with data from
o1 using the optional sample object smp or the workfile sample. o2 will be resized accord-
ingly. All NA values in the series will be assigned to the corresponding vector elements.
Example:
400Chapter
400 9. Matrix and String Reference
stom(ser1,v1)
stom(ser1,v2,smp1)
If o1 is a group, stom fills the matrix o2 with data from o1 using the optional sample object
smp or the workfile sample. o2 will be resized accordingly. The series in o1 are placed in
the columns of o2 in the order they appear in the group spreadsheet. All NAs will be
assigned to the corresponding matrix elements. Example:
stomna(grp1,m1)
stomna(grp1,m2,smp1)
For conversion methods that automatically remove observations with NAs, see @convert
(p. 383) and stom (p. 399).
Syntax: @str(n)
Argument: scalar, n
Return: string
%1 = @str(15)
Syntax: @strlen(s)
Argument: string, s
Return: number n
!1 = @strlen("Hi mom")
!1 will contain the value 6. See also @val (p. 403).
@svd401
401
Returns a submatrix of a specified matrix, o. n1 is the row and n2 is the column of the
upper left element to be extracted. The optional arguments n3 and n4 provide the row and
column location of the lower right corner of the matrix. Unless n3 and n4 are provided this
function return a matrix containing all of the elements below and to the right of the start-
ing element.
Examples:
matrix m2 = @subextract(m1,5,9,6,11)
matrix m2 = @subextract(m1,5,9)
Performs a singular value decomposition of the matrix m1. The matrix U is returned by the
function, the vector v1 will be filled (resized if necessary) with the singular values and the
matrix m2 will be assigned (resized if necessary) the other matrix, V, of the decomposi-
tion. The singular value decomposition satisfies
m 1 = UW V ′
(9.1)
U′U = V′V = I
402Chapter
402 9. Matrix and String Reference
where W is a diagonal matrix with the singular values along the diagonal. Singular values
close to zero indicate that the matrix may not be of full rank. See the @rank (p. 396) func-
tion for a related discussion.
Examples:
matrix m2
vector v1
matrix m3 = @svd(m1,v1,m2)
Syntax: @trace(m)
Argument: matrix or sym, m
Return: scalar
Returns the trace (the sum of the diagonal elements) of a square matrix or sym, m. Exam-
ple:
Syntax: @transpose(o)
Argument: matrix, vector, rowvector, or sym, o
Return: matrix, rowvector, vector, or sym
Forms the transpose of a matrix object, o. o may be a vector, rowvector, matrix, or a sym.
The result is a matrix object with a number of rows equal to the number of columns in the
original matrix and number of columns equal to the number of rows in the original matrix.
This function is an identity function for a sym, since a sym by definition is equal to its
transpose. Example:
matrix m2 = @transpose(m1)
rowvector r2 = @transpose(v1)
@val403
403
Creates an n1 element vector with a 1 in the n2-th element, and 0 elsewhere. Example:
vec v1 = @unitvector(8, 5)
creates an 8 element vector with a 1 in the fifth element and 0 for the other 7 ele-
ments.
Note: if you wish to create an n1 element vector of ones, you should use a declaration
statement of the form
vector(n1) v1=1
Syntax: @val(str)
Argument: string, str
Return: scalar
Returns the number that a string str represents. The number is terminated by the first non-
numeric character. If the string begins with a non-numeric character (that is not a plus or a
minus sign), the function returns NA. This function is useful for extracting numbers from
tables. Example:
scalar sc1 = @val("17.4648")
scalar sc2 = @val(tab1(3,4))
scalar sc3 = @val("-234.35")
Syntax: @vec(o)
Argument: matrix, sym, o
Return: vector
Creates a vector from the columns of the given matrix stacked one on top of each other.
The vector will have the same number of elements as the source matrix. Example:
vector v1 = @vec(m1)
Syntax: @vech(o)
Argument: matrix, sym, o
Return: vector
Creates a vector from the columns of the lower triangle of the source square matrix o
stacked on top of each another. The vector has the same number of elements as the source
matrix has in its lower triangle. Example:
vector v1 = @vech(m1)
Chapter 10. Programming Language Reference
Cross-references
See Calling Subroutines on page 107. See also subroutine (p. 413), endsub (p. 406).
Syntax: @date
Return: string
Examples
%y = @date
Cross-references
See also @time (p. 414).
Starts a sequence of commands to be executed when the IF condition is false. The else
keyword must be terminated with an endif.
Syntax
if [condition] then
[commands to be executed if condition is true]
406Chapter
406 10. Programming Language Reference
else
[commands to be executed if condition is false]
endif
Cross-references
See IF Statements on page 96. See also, if (p. 408), endif (p. 406), then (p. 413).
Syntax
if [condition] then
[commands if condition true]
endif
Cross-references
See IF Statements on page 96. See also, if (p. 408), else (p. 405), then (p. 413).
Syntax
subroutine name(arguments)
commands
endsub
Cross-references
See Defining Subroutines beginning on page 105. See also, subroutine (p. 413),
return (p. 411).
Syntax: @errorcount
Argument: none
Return: integer
exitloop407
407
Number of errors encountered. Returns a scalar containing the number of errors encoun-
tered during program execution.
Syntax: @evpath
Return: string
Returns a string containing the directory path for the EViews executable.
Examples
If your currently executing copy of EViews is installed in D:\EVIEWS, then
%y = @evpath
Cross-references
See also cd, chdir (p. 155).
exitloop causes the program to break out of the current FOR or WHILE loop.
Syntax
Command: exitloop
Examples
for !i=1 to 107
if !i>6 then exitloop
next
Cross-references
See The FOR Loop on page 98. See also, stop (p. 413), return (p. 411), for (p. 408),
next (p. 409), step (p. 412).
408Chapter
408 10. Programming Language Reference
Syntax
for counter=start to end [step stepsize]
commands
next
Cross-references
See The FOR Loop on page 98. See also, exitloop (p. 407), next (p. 409), step
(p. 412) .
if Program Statement
IF statement in a program.
The if statement marks the beginning of a condition and commands to be executed if the
statement is true. The statement must be terminated with the beginning of an ELSE clause,
or an endif.
Syntax
if [condition] then
[commands if condition true]
endif
Cross-references
See IF Statements on page 96. See also else (p. 405), endif (p. 406), then (p. 413).
The include statement is used to include the contents of another file in a program file.
open409
409
Syntax
include filename
Cross-references
See Multiple Program Files on page 104. See also call (p. 405).
Syntax: @isobject(str)
Argument: string, str
Return: integer
Check for an objects existence. Returns a 1 if the object exists in the current workfile,
and a 0 if it does not exist.
End of FOR loop. next marks the end of a FOR loop in a program.
Syntax
for [conditions of the FOR loop]
[commands]
next
Cross-references
See The FOR Loop beginning on page 98. See also, exitloop (p. 407), for (p. 408),
step (p. 412).
open Command
Open a file. Opens a workfile, database, program file, or ASCII text file.
output Command
poff turns off automatic printing of all output. In programs, poff is used in conjunction
with pon to control automatic printing; these commands have no effect in interactive use.
Syntax
Command: poff
Cross-references
See Print Setup on page 632 of the Users Guide for a discussion of printer control.
pon instructs EViews to send all statistical and data display output to the printer (or the
redirected printer destination; see output (p. 271)). It is equivalent to including the p
option in all commands that generate output. pon and poff only work in programs; they
have no effect in interactive use.
Syntax
Command: pon
Cross-references
See Print Setup on page 632 of the Users Guide for a discussion of printer control.
program Command
Create a program.
Exit subroutine.
The return statement forces an exit from a subroutine within a program. A common use
of return is to exit from the subroutine if an unanticipated error has occurred.
Syntax
if [condition] then
return
endif
Cross-references
See Subroutines beginning on page 105. See also exitloop (p. 407), stop (p. 413).
run Command
Run a program. The run command executes a program. The program may be located in
memory or stored in a program file on disk.
Syntax
for !i = 1 to 10
statusline Iteration !i
next
412Chapter
412 10. Programming Language Reference
Syntax
for !i=a to b step n
[commands]
next
step may be used in a FOR loop to specify the size of the step in the looping variable. If
no step is provided, for assumes a step of +1.
If a given step exceeds the end value b in the FOR loop specification, the contents of the
loop will not be executed.
Examples
for !j=5 to 1 step -1
series x = nrnd*!j
next
repeatedly executes the commands in the loop with the control variable !J set to 5, 4,
3, 2, 1.
for !j=0 to 10 step 3
series z = z/!j
next
Loops the commands with the control variable !J set to 0, 3, 6, and 9.
You should take care when using non-integer values for the stepsize since round-off error
may yield unanticipated results. For example:
for !j=0 to 1 step .01
series w = !j
next
may stop before executing the loop for the value !J=1 due to round-off error.
Cross-references
See The FOR Loop beginning on page 98. See also exitloop (p. 407), for (p. 408),
next (p. 409).
then413
413
The stop command halts execution of a program. It has the same effect as hitting the F1
(break) key.
Syntax
Command: stop
Cross-references
See also, exitloop (p. 407), return (p. 411).
Syntax
subroutine name(arguments)
[commands]
endsub
Cross-references
See Subroutines beginning on page 105. See also endsub (p. 406).
Part of IF statement.
then marks the beginning of commands to be executed if the condition given in the IF
statement is satisfied.
Syntax
if [condition] then
[commands if condition true]
endif
414Chapter
414 10. Programming Language Reference
Cross-references
See IF Statements on page 96. See also, else (p. 405), endif (p. 406), if (p. 408).
Syntax: @time
Return: string
Examples
%y = @time
Cross-references
See also @date (p. 405).
to is required in the specification of a FOR loop to specify the upper limit of the control
variable; see The FOR Loop on page 98.
When used as a lag specifier, to may be used to specify a range of lags to be used in esti-
mation.
Syntax
Used in a FOR loop:
for !i=n to m
[commands]
next
Used as a Lag specifier:
series_name(n to m)
wend415
415
Examples
ls cs c gdp(0 to -12)
Runs an OLS regression of CS on a constant, and the variables GDP, GDP(1), GDP(2),
,
GDP(11), GDP(12).
Cross-references
See The FOR Loop beginning on page 98. See also, exitloop (p. 407), for (p. 408),
next (p. 409).
Syntax: @toc
Return: integer
Examples
tic
[some commands]
!elapsed = @toc
resets the timer, executes commands, and saves the elapsed time in the control variable
!ELAPSED.
Cross-references
See also tic (p. 353) and toc (p. 354).
wend marks the end of a set of program commands that are executed under the control of
a WHILE statement.
Syntax
while [condition]
[commands while condition true]
wend
416Chapter
416 10. Programming Language Reference
Cross-references
See The WHILE Loop on page 102. See also while (p. 416).
Conditional control statement. The while statement marks the beginning of a WHILE
loop.
The commands between the while keyword and the wend keyword will be executed
repeatedly until the condition in the while statement is false.
Syntax
while [condition]
[commands while condition true]
wend
Cross-references
See The WHILE Loop on page 102. See also wend (p. 415).
Appendix A. Operator and Function Reference
Operators
All of the operators described below may be used in expressions involving series and
scalar values. When applied to a series expression, the operation is performed for
each observation in the current sample. The precedence of evaluation is listed in
Operators on page 87 of the Users Guide. Note that you can enforce order-of-evalu-
ation using parentheses
.
with a monthly workfile, Y will contain a numeric indicator for each month (1 through
12). If you create the series
series z = @quarter
for the same workfile, EViews will fill Z with the numeric quarter indicator (1 through 4)
associated with each observation.
You may only use these functions in a workfile of at least as high frequency. Thus, while
you can use the @month function in a daily or annual workfile, you cannot use the @day
function in a monthly or annual workfile, nor can you use the @month function in an
annual workfile.
Note that the logarithmic functions are base-e (natural logarithms). To convert the natural
logarithm into log 10 , use the relationship
log 10 ( x ) = log e ( x ) ⁄ log e ( 10 ) ≈ log e ( x ) ⁄ 2.303 . (A.1)
Descriptive Statistics
These functions compute descriptive statistics for a specified sample, excluding missing
values if necessary. The default sample is the current workfile sample. If you are perform-
ing these computations on a series and placing the results into a series, you can specify a
sample as the last argument of the descriptive statistic function, either as a string (in dou-
ble quotes) or using the name of a sample object. For example,
series z = @mean(x,"1945:01 1979:12")
or
w = @var(y, s2)
where S2 is the name of a sample object and W and X are series. Note that you may not
use a sample argument if the results are assigned into a matrix, vector, or scalar object. For
example, the following assignment
vector(2) a
series x
a(1) = @mean(x, "1945:01 1979:12")
422Appendix
422 A. Operator and Function Reference
is not valid since the target A(1) is a vector element. To perform this latter computation
you must explicitly set the global sample prior to performing the calculation performing
the assignment:
smpl 1945:01 1979:12
a(1) = @mean(x)
To determine the number of observations available for a given series, use the @obs func-
tion. Note that where appropriate, EViews will perform casewise exclusion of data with
missing values. For example, @cov(x,y) and @cor(x,y) will use only observations for
which data on both X and Y are valid.
[s]: sample expression in double quotes or name of a sample object. The optional
sample argument may only be used if the result is assigned to a series. For @quan-
tile, you must provide the method option argument in order to include the
optional sample argument.
Function Description
@beta(a,b) beta integral (Euler integral of the second kind)
1 a− 1
dt = ¡ ( a )¡ ( b )
b−1
B ( a, b ) = ∫0 t (1 − t )
¡(a + b)
for a, b > 0.
@betainc(x,a,b) incomplete beta integral
1 x a−1 b−1
∫ t (1 − t ) dt
B ( a, b ) 0
for 0 £ x £ 1, and a, b > 0.
@betaincder(x,a,b,s) derivative of the incomplete beta integral:
Evaluates the derivatives of the incomplete beta integral
B(x, a, b), where s is an integer from 1 to 9 corre-
sponding to the desired derivative:
@B @B @B
@x @a @b
1 2 3 2
@ B @ B @ B
2 2
4 5 6 =
@x @x@a @x@b
7 8 9 2 2 2
@ B @ B @ B
@a @a@b @b
424Appendix
424 A. Operator and Function Reference
∫ t (1 − t ) dt
B ( a, b ) 0
for 0 £ p £ 1, and a, b > 0.
@betalog(a,b) natural logarithm of the beta integral:
log B ( a, b ) = log ¡ ( a ) + log ¡ ( b ) − log ¡ ( a + b ) .
@binom(n,x) binomial coefficient
n!
n =
x x! ( n − x )!
for n and x positive integers, 0 £ x £ n.
@binomlog(n,x) natural logarithm of the binomial coefficient:
log ( n! ) − log ( x! ) − log ( ( n − x )! )
@cloglog(x) complementary log-log function:
log ( − log ( 1 − x ) )
See also @qextreme.
@digamma(x), @psi(x) first derivative of the log gamma function:
d log ¡ ( x ) 1 d¡ ( x )
« ( x ) =
dx ¡ ( x ) dx
@erf(x) error function:
2 x −t2
erf ( x ) =
∫ e dt
¼ 0
for x ³ 0.
@erfc(x) complementary error function:
2 ∞ −t2
erfc ( x ) =
∫ e dt = 1 − erf ( x ) .
¼ x
for x ³ 0.
@gamma(x) (complete) gamma function:
∞ −t x − 1
¡(x ) = ∫0 e t dt
for x ³ 0.
Additional and Special Functions425
425
∫ e t dt
¡( a) 0
for x ³ 0 and a > 0.
@gammaincder(x,a,n) derivative of the incomplete gamma function:
Evaluates the derivatives of the incomplete gamma
integral G(x, a), where s is an integer from 1 to 5 corre-
sponding to the desired derivative:
@G @G
-
1 2 - = @x @a
2 2 2
3 4 5 @ G @ G @ G
@x @x@a @a
@gammaincinv(p,a) inverse of the incomplete gamma function: find the
value of x satisfying
1 x −t a − 1
p = G ( x, a ) =
∫ e t dt
¡( a) 0
for 0 £ p < 1 and a > 0.
@gammalog(x) logarithm of the gamma function: log G(x). For deriva-
tives of this function see @digamma and @trigamma.
@logit(x) logistic transform:
x
1 e
=
−x
1+e 1+e
@psi(x) see @digamma.
@trigamma(x) second derivative of the log gamma function:
2
d log ¡ ( x )
«′ ( x ) =
dx
426Appendix
426 A. Operator and Function Reference
Trigonometric Functions
When applied to a series, all of the trigonometric functions operate on every observation in
the current sample and return a value for every observation. Where relevant, the input and
results should/will be expressed in radians. All results are real valuedcomplex values
will return NAs.
There are four functions associated with each distribution. The first character of each func-
tion name identifies the type of function:
The remainder of the function name identifies the distribution. For example, the functions
for the beta distribution are @cbeta, @dbeta, @qbeta and @rbeta.
When used with series arguments, EViews will evaluate the function for each observation
in the current sample. As with other functions, NA or invalid inputs will yield NA values.
For values outside of the support, the functions will return zero.
The information provided below should be sufficient to identify the meaning of the param-
eters for each distribution. For further details, see the Command and Programming Refer-
ence.
\
B ( a, b )
@qbeta(p,a,b)
for 0 £ p £ 1 and for a, b > 0, where B is
@rbeta(a,b)
the @beta function.
Binomial
Pr ( x, n, p ) = n p ( 1 − p )
@cbinom(x,n,p) x n−x
@dbinom(x,n,p) x
@qbinom(s,n,p) if x = 0, 1, ¼, n, ¼, and 0 otherwise, for
@rbinom(n,p) 0 £ p £ 1.
Chi-square @cchisq(x,v) 1 v ⁄ 2 − 1 −x ⁄ 2
f ( x, v ) =
v⁄2
x e
@dchisq(x,v) 2 ¡(v ⁄ 2)
@qchisq(p,v)
where x ³ 0, and v > 0. Note that the
@rchisq(v)
degrees-of-freedom parameter v need not be
an integer.
Exponential @cexp(x,m) 1 −x ⁄ m
f ( x, m ) =
e
@dexp(x,m) m
@qexp(p,m)
for x ≥ 0 , and m > 0 .
@rexp(m)
Extreme Value @cextreme(x) x
f ( x ) = exp ( x − e )
(Type I-minimum) @dextreme(x)
@qextreme(p), for -¥ £ x £ ¥.
@cloglog(p)
@rextreme
428Appendix
428 A. Operator and Function Reference
F-distribution @cfdist(x,v1,v2) v1 ⁄ 2 v2 ⁄ 2
v1 v 2
@dfdist(x,v1,v2) f ( x, v 1, v 2 ) =
B ( v 1 ⁄ 2, v 2 ⁄ 2 )
@qfdist(p,v1,v2)
( v1 − 2 ) ⁄ 2 − ( v1 + v2 ) ⁄ 2
@rfdist(v1,v1) x ( v2 + v1x )
@rgamma(b,r)
Laplace @claplace(x) 1 −x
f ( x ) =
e
@dlaplace(x) 2
@qlaplace(x)
for -¥ £ x £ ¥.
@rlaplace
Logistic @clogistic(x) x
1 e
@dlogistic(x) f ( x ) =
−x
1+e 1+e
@qlogistic(p)
@rlogistic for -¥ £ x £ ¥.
Log-normal @clognorm(x,m,s) 1 2 2
−( logx − m) ⁄ ( 2s )
f ( x, m , s ) =
e
@dlognorm(x,m,s) 2
x 2¼s
@qlognorm(p,m,s)
@rlognorm(m,s) x > 0, -¥ £ m £ ¥, and s > 0.
Negative Binomial @cnegbin(x,n,p) ¡( x + n) n x
Pr ( x, n, p ) =
p ( 1 − p )
@dnegbin(x,n,p) ¡ ( x + 1 )¡ ( n )
@qnegbin(s,n,p)
if x = 0, 1, ¼, n, ¼, and 0 otherwise, for
@rnegbin(n,p) 0 £ x £ 1.
Normal (Gauss- @cnorm(x) − 1 ⁄ 2 − x2 ⁄ 2
f ( x ) = ( 2¼ ) e
ian) @dnorm(x)
@qnorm(p) for -¥ £ x £ ¥.
@rnorm, nrnd
Poisson @cpoisson(x,m) x −m
Pr ( x, m ) = m e ⁄ x!
@dpoisson(x,m)
@qpoisson(p,m) if x = 0, 1, ¼, n, ¼, and 0 otherwise, for
m > 0.
@rpoisson(m)
Statistical Distribution Functions429
429
2
¡( (v + 1) ⁄ 2) x
1 +
=
1⁄2
( v¼ ) ¡ ( v ⁄ 2 ) v
@dunif(x,a,b) b−a
@qunif(p,a,b)
for a £ x £ b, and b > a.
@runif(a,b), rnd
Weibull @cweib(x,m,a) − a a − 1 − ( x ⁄ m)
a
f ( x, m , a ) = am x e
@dweib(x,m,a)
@qweib(p,m,a) where -¥ £ x £ ¥, and m, a > 0.
@rweib(m,a)
L MA 243
seasonal 319
Label object 231 Main diagonal of matrix 388
Lag Make model object 250
specify as range 414 Make residuals 251
VAR lag order selection 232 Mathematical functions 418
Lag exclusion test 351 Matrix
Lagrange multiplier convert to other matrix objects 72
test for ARCH in residuals 145 convert to series or group 60
Landscape printing 9 copy 57
Laplace distribution 428 copy submatrix 59
Least squares estimation 239 declare 53
Legend export data 71
appearance and placement 233 filled 386
rename 264 import data 70
Line drawing 190 main diagonal 388
Line graph 234 objects 53
permute rows of 395
Line pattern 190
place submatrix 392
Line style 190 resample rows from 396
Load workfile 237 singular value decomposition 401
Local stack columns 404
subroutine 110 stack lower triangular columns 404
variable 108 Matrix (object)
Logistic assign values 54
logit function 425 data members 33
Logistic distribution 428 declare 258
Logit models 151 fill values 203
Logl (object) 30 procs 33
check user-supplied derivatives 158 views 33, 70
data members 31 Matrix commands and functions 381
Index437
437
Q numbers 398
place in matrix 398
QQplot. See Distribution function. Rowvector (object)
Q-statistic 170 data members 38
Quantile-Quantile plot. See Distribution function. declare 295
Quiet mode 85 extract 397
filled rowvector function 387
R procs 31
Random effects 241 views 38
Random number Run program 296, 411
integer 294 multiple files 104
seed 295 See Program.
uniform 294 S
Random number generator
normal 266 Sample
Rank 396 change using for loop 99
Read data from foreign file 283 set 308, 322
Recursive least squares 292 Sample (object)
CUSUM 293 declare 297
CUSUM of squares 293 procs 39
Redirect output to file 8 Save
Redirect printer output 271 commands in file 2
Redundant variables test 348 objects to disk 16
workfile 299
Regressor group 251
Scalar
Regressors
evaluate a string 403
make group containing 251
Scalar (object) 40
Rename object 15, 286
declare 300
Replacement variable 91
Scatter diagram 302
naming objects 93
matrix of 304
Resample observations 287 with bivariate fit 236
Resample rows from matrix 396 Seasonal adjustment
RESET test 289 moving average 305
Reset timer 353 X11 371
Residuals X12 372
correlation matrix of 289 Seasonal autoregressive error 298
covariance matrix of 290 Seasonal dummy variable 421
make group containing 251 Seasonal line graph 306
make series 251
Second moment matrix 389
Resize workfile 282
Seed random number generator 295
Restricted VAR text 161
Seemingly unrelated regression. See SUR
Results
Sequential LR tests 104
display 292
retrieving. See Data members. Serial correlation
Breusch-Godfrey LM test 148
Roots of the AR polynomial 147
LM test 148
Roundoff error in for loops 412 multivariate VAR LM test 146
Row
440
440 Index
Series views 42
convert to matrix 335, 336, 393, 399 State variables
convert to matrix (with NAs) 399 display graphs of 331
extract observation 418 final one-step ahead predictions 332
Series (object) 40 initial values 333
data members 41 smoothed series 255
declare 307 Static forecast 207
element function 41 Statistical distribution functions 426
fill values 203 Statistics
views 40 compute for subgroups 329
Set date labeling formats 176 Status line 335
Shade region of graph 190 display message 411
Show object view 317 Step 412
Signal variables Stop program execution 103, 413
display graphs 318 Store object 16, 337
saving 253 String 88
Sine 426 assign to table cell 78
Singular matrix comparison 97
test for 390 convert to a scalar 403
Singular value decomposition 401 empty 97
Smooth from a number 400
exponential smooth series 320 String variable 88
signal series 253 @-functions 90
state series 255 as replacement variable 92
Solve comparison 97
linear system 398 convert to a scalar 89, 91
simultaneous equations model 323 in for loop 100
Solve. See Model. program arguments 94
Sort workfile 326 test for empty string 97
Specification view 327 Subroutine 105
Spike graph 327 arguments 106
Spreadsheet view 316 call 107, 405
declare 413
Sspace (object)
define 105
append specification line 141
global 108
data members 43
local 110
declare 329
mark end 406
display signal graphs 318
placement 107
make Kalman filter from 245
return from 105, 411
procs 43
state graphs 331 Subtraction operator (-) 65
Stack matrix by column 404 Sum 423
lower triangle 404 Sum of squares 423
Standard deviation 423 SUR
Starting values 274 estimating 340
State space (object) Sym (object) 44
method 42 create from lower triangle of square matrix 388
procs 31 create from scalar function 387
Index441
441
views 49
Variance 423
Variance decomposition 184
Variance test 346, 347
VEC (vector error correction)
estimate 194
Vector (object) 51
data members 52
declare 361
procs 52
return filled 387
views 51
Vector autoregression. See VAR.
Verbose mode 85
Views
extracting results from 122
W
Wald test 362
Weibull distribution 429
Weighted least squares 364
Weighted two-stage least squares 369
While loop 102
abort 102
end of 415
exit loop 104
start of 416
White heteroskedasticity test 363
Wildcards 14
Workfile 11
close 12
creating 174
creating or changing active 365
expand 200
frequency 11
open 12
open existing 237
resize 282
save 12
save to disk 299
sort observations 326
Write data to file 367
X
X11 371
X12 372