Working With Data in Eviews
Working With Data in Eviews
Working With Data in Eviews
In the following discussion, we describe EViews’ powerful language for using numeric
expressions and generating and manipulating the data in series and groups. We first describe
the fundamental rules for working with mathematical expressions in EViews, and then
describe how to use these expressions in working with series and group data.
More advanced tools for working with numeric data, and objects for working with different
kinds of data are described in Chapter 7. “Working with Data (Advanced),” beginning on
page 191.
Numeric Expressions
One of the most powerful features of EViews is the ability to use and to process mathemati-
cal expressions. EViews contains an extensive library of built-in operators and functions that
allow you to perform complicated mathematical operations on your data with just a few key-
strokes. In addition to supporting standard mathematical and statistical operations, EViews
provides a number of specialized functions for automatically handling the leads, lags and
differences that are commonly found in time series data.
As in other programs, you can use these expressions to calculate a new series from existing
series, to describe a sample of observations, or to describe an equation for estimation or
forecasting. However, EViews goes far beyond this simple use of expressions by allowing
you to use expressions virtually anywhere you would use a series. We will have more on this
important feature shortly, but first, we describe the basics of using expressions.
Operators
EViews expressions may include operators for the usual arithmetic operations. The operators
for addition (+), subtraction (-), multiplication (*), division (/) and raising to a power (^)
are used in standard fashion so that:
5 + 6 * 7.0 / 3
7 + 3e-2 / 10.2345 + 6 * 10^2 + 3e3
3^2 - 9
are all valid expressions. Notice that explicit numerical values may be written in integer,
decimal, or scientific notation.
168—Chapter 6. Working with Data
In the examples above, the first expression takes 5 and adds to it the product of 6 and 7.0
divided by 3 (5+14=19); the last expression takes 3 raised to the power 2 and subtracts 9
(9 – 9 = 0). These expressions use the order of evaluation outlined below.
The “-” and “+” operators are also used as the unary minus (negation) and unary plus oper-
ators. It follows that:
2-2
-2+2
2+++++++++++++-2
2---2
EViews follows the usual order in evaluating expressions from left to right, with operator
precedence order as follows (from highest precedence to lowest):
• unary minus (-), unary plus (+)
• exponentiation (^)
• multiplication (*), division (/)
• addition (+), subtraction (-)
• comparison (<, >, <=, >=, =)
• and, or
To enforce a particular order of evaluation, you can use parentheses. As in standard mathe-
matical analysis, terms which are enclosed in parentheses are treated as a subexpression
and evaluated first, from the innermost to the outermost set of parentheses. We strongly rec-
ommend the use of parentheses when there is any possibility of ambiguity in your expres-
sion.
A full listing of operators is presented in Chapter 13. “Operator and Function Reference,” on
page 545 of the Command and Programming Reference.
Series Expressions
Much of the power of EViews comes from the fact that expressions involving series operate
on every observation, or element, of the series in the current sample. For example, the series
expression:
2*y + 3
tells EViews to multiply every sample value of Y by 2 and then to add 3. We can also per-
form operations that work with multiple series. For example:
x/y + z
indicates that we wish to take every observation for X and divide it by the corresponding
observation on Y, and add the corresponding observation for Z.
Series Functions
EViews contains an extensive library of built-in functions that operate on all of the elements
of a series in the current sample. Some of the functions are “element functions” which
return a value for each element of the series, while others are “summary functions” which
return scalars, vectors or matrices, which may then be used in constructing new series or
working in the matrix language (see Chapter 11. “Matrix Language,” on page 257 of the
Command and Programming Reference for a discussion of scalar, vector and matrix opera-
tions).
Most function names in EViews are preceded by the @-sign. For example, @mean returns the
average value of a series taken over the current sample, and @abs takes the absolute value
of each observation in the current sample.
All element functions return NAs when any input value is missing or invalid, or if the result
is undefined. Functions which return summary information generally exclude observations
for which data in the current sample are missing. For example, the @mean function will com-
pute the mean for those observations in the sample that are non-missing.
There is an extensive set of functions that you may use with series:
• A list of mathematical functions is presented in Chapter 13. “Operator and Function
Reference,” on page 545 of the Command and Programming Reference.
• Workfile functions that provide information about observations identifiers or allow
you to construct time trends are described in Chapter 15. “Workfile Functions” of the
Command and Programming Reference.
170—Chapter 6. Working with Data
• Functions for working with strings and dates are documented in “String Function
Summary” on page 609 and “Date Function Summary” on page 610 both in the Com-
mand and Programming Reference.
The remainder of this chapter will provide additional information on some of these func-
tions, then examples of expressions involving functions.
Series Elements
At times, you may wish to access a particular observation for a series. EViews provides you
with a special function, @elem, which allows you to use a specific value of a series.
@elem takes two arguments: the first argument is the name of the series, and the second is a
quoted date or observation identifier.
For example, suppose that you want to use the 1980Q3 value of the quarterly series Y, or
observation 323 of the undated series X. Then the functions:
@elem(y, "1980Q3")
@elem(x, "323")
will return the values of the respective series in the respective periods.
A numeric relational comparison is an expression which contains the “=” (equal), “>=”
(greater than or equal), “<=” (less than or equal), “<>” (not equal), “>” (greater than),
or “<” (less than) comparison operators. These expressions generally evaluate to TRUE or
FALSE, returning a 1 or a 0, depending on the result of the comparison.
Note that EViews also allows relational comparisons to take the value “missing” or NA, but
for the moment, we will gloss over this point until our discussion of missing values (see
“Missing Values” on page 175).
We have already seen examples of expressions using relational operators in our discussion
of samples and sample objects. For example, we saw the sample condition:
incm > 5000
which allowed us to select observations meeting the specified condition. This is an example
of a relational expression—it is TRUE for each observation on INCM that exceeds 5000; oth-
erwise, it is FALSE.
Numeric Expressions—171
As described above in the discussion of samples, you may use the “and” and “or” conjunc-
tion operators to build more complicated expressions involving relational comparisons:
(incm>5000 and educ>=13) or (incm>10000)
It is worth emphasizing the fact that EViews uses the number 1 to represent TRUE and 0 to
represent FALSE. This internal representation means that you can create complicated expres-
sions involving logical subexpressions. For example, you can use relational operators to
recode your data:
0*(inc<100) + (inc>=100 and inc<200) + 2*(inc>=200)
which yields 0 if INC<100, 1 if INC is greater than or equal to 100 and less than 200, and 2
for INC greater than or equal to 200.
The equality comparison operator “=” requires a bit more discussion, since the equal sign is
used both in assigning values and in comparing values. We consider this issue in greater
depth when we discuss creating and modifying series (see “Series” on page 177). For now,
note that if used in an expression:
incm = 2000
Descriptive Statistics
Standard descriptive statistic functions are available in EViews. These include, but are not
limited to functions to calculate the mean (@mean), the median (@median), the standard
deviation (@stdev), the variance (@var) and covariance (@cov). The descriptive statistic
functions all take an optional sample as an argument. For a full list of descriptive statistics
functions, details on the use of samples, and some examples, see “Descriptive Statistics,” on
page 550 of the Command and Programming Reference.
It should be noted that EViews offers two ways to calculate standard deviations, variances
and covariances. The simple standard deviation function, @stdev, calculates the sample
standard deviation, that is the square root of the sum-of-squares divided by n – 1 . To calcu-
late the population standard deviation, that is division by n, use the @stdevp function. Note
for symmetry purposes there is also a @stdevs which performs the same calculation as
@stdev.
The @var and @cov functions calculate the population variance and covariance respectively,
i.e., they divide through by n. To calculate the sample variance or covariance use the @vars
or @covs functions. Again, there are also @varp and @covp functions which do the same as
@var or @cov.
172—Chapter 6. Working with Data
While EViews expects lead and lag arguments to be integers, there is nothing to stop you
from putting non-integer values in the parentheses. EViews will automatically convert the
number to an integer; you should be warned, however, that the conversion behavior is not
guaranteed to be systematic. If you must use non-integer values, you are strongly encour-
aged to use the @round, @floor, or @ceil functions to control the lag or lead behavior.
In many places in EViews, you can specify a range of lead or lag terms. For example, when
estimating equations, you can include expressions of the form:
income(-1 to -4)
are equivalent methods of specifying the level of SALES and all lags from 1 to 4.
The @lag function can also be used to specify lags. Thus the expressions:
@lag(sales,1)
sales(-1)
are equivalent. Note one useful function of @lag is that it will take the lag of everything
within parenthesis. @lag can therefore be used to find the lag of an expression. Typing:
@lag((sales-income)/sales,4)
(sales(-4)-income(-4))/sales(-4)
EViews also has several built-in functions for working with difference data in either levels or
in logs. The “D” and “DLOG” functions will automatically evaluate the differences for you.
For example, instead of taking differences explicitly,
income - income(-1)
log(income) - log(income(-1))
Numeric Expressions—173
You can take higher order differences by specifying the difference order. For example, the
expressions:
d(income,4)
dlog(income,4)
If you wish to take seasonal differences, you should specify both the ordinary, and a sea-
sonal difference term:
d(income,1,4)
dlog(income,1,4)
These commands produce first order differences with a seasonal difference at lag 4. If you
want only the seasonal difference, specify the ordinary difference term to be 0:
d(income,0,4)
dlog(income,0,4)
Other time series functions provided by EViews include a number of percentage change type
functions. The simplest of these, @pc calculates a simple one-period percentage change in a
series. For example typing:
@pca(income)
Two special types of time series functions, moving functions and cumulative functions are
also available in EViews, and are described below.
Mathematical details of lags, leads, differences and percentage change functions are pro-
vided in Chapter 13. “Operator and Function Reference,” on page 545 of the Command and
Programming Reference.
The backwards functions, which take the form @cumb[stat], start at the end of the workfile,
or sample, and move backwards until the current observation.
174—Chapter 6. Working with Data
Note for both type of cumulative function the length of the window is different for each
observation. The cumulative functions may be thought of as perform “running total” type
calculations. Missing values are not propagated in the cumulative functions, i.e., observa-
tions with a value equal to NA are simply skipped.
The moving statistic functions have a shorter, user specified, window length. They provide
information on the n observations up to, and including, the current observation, where n is
chosen by the user.
The moving functions come in two types, those that propagate missing values and those
that do not. For the functions that do propagate missing values, which take the form
@mov[stat], if any of the observations within the window contain an NA the function will
return NA. The functions that do not propagate, which take the form @m[stat], will simply
skip any NA observations.
For more information on missing values see “Missing Values” on page 175.
As an example, you could find out the maximum value of INCOME from the start of the
workfile to each observation by typing:
show @cummax(income)
If the first, say, four observations of INCOME are 100, 120, 110, 140 then this command will
show a series as 100, 120, 120, and 140 as the first four observations.
If you wanted to know at each observation the average of the previous 3 years (including the
current year) SALES figures you could type:
show @movav(sales,3)
Note that the lag or lead operators can be used inside a moving statistic function to allow
you to control the exact start and end point of your window. For example, if you wanted to
know, at each observation, the sum of SALES from three years ago, two years ago and last
year (i.e. the sum of SALES(-1), SALES(-2) and SALES(-3)) you could type:
show @movsum(sales(-1),3)
Further details and a complete list of cumulative functions can be found in “Cumulative Sta-
tistic Functions” on page 553, and for moving functions in “Moving Statistic Functions” on
page 557 both in the Command and Programming Reference.
Ranking Series
EViews has an @ranks function which will generate a series based upon the ranking of
another series. Ranking can be either ascending or descending depending upon whether “a”
Numeric Expressions—175
or “d” is used as an option in the function. For example to create series, ARANK, which con-
tains the ascending ranks of the observations in the series SALES you could type:
series arank = @ranks(sales,a)
and to create a series containing the descending ranks you could type:
series drank = @ranks(sales,d)
EViews provides a number of different ways of handling ties in the ranking. For more details
see @ranks in “Descriptive Statistics” on page 550 of the Command and Programming Refer-
ence.
Missing Values
Occasionally, you will encounter data that are not available for some periods or observa-
tions, or you may attempt to perform mathematical operations where the results are unde-
fined (e.g., division by zero, log of a negative number). EViews uses the code NA (not
available) to represent these missing values.
For the most part, you need not worry about NAs. EViews will generate NAs for you when
appropriate, and will automatically exclude observations with NAs from statistical calcula-
tions. For example, if you are estimating an equation, EViews will use the set of observations
in the sample that have no missing values for the dependent and all of the independent vari-
ables.
There are, however, a few cases where you will need to work with NAs, so you should be
aware of some of the underlying issues in the handling of NAs.
First, when you perform operations using multiple series, there may be alternative
approaches for handling NAs. EViews will usually provide you with the option of casewise
exclusion (common sample) or listwise exclusion (individual sample). With casewise exclu-
sion, only those observations for which all of the series have non-missing data are used.
This rule is always used, for example, in equation estimation. For listwise exclusion, EViews
will use the maximum number of observations possible for each series, excluding observa-
tions separately for each series in the list of series. For example, when computing descriptive
statistics for a group of series, you have the option to use a different sample for each series.
If you must work directly with NAs, just keep in mind that EViews NAs observe all of the
rules of IEEE NaNs. This means that performing mathematical operations on NAs will gen-
erate missing values. Thus, each of the following expressions will generate missing values:
@log(-abs(x))
1/(x-x)
(-abs(x))^(1/3)
3*x + NA
exp(x*NA)
176—Chapter 6. Working with Data
For the most part, comparisons involving NA values propagate NA values. For example, the
commands:
series y = 3
series x = NA
series equal = (y = x)
series greater = (y > x)
will create series EQUAL and GREATER that contain NA values, since the comparison
between observations in a series involving an NA yields an NA.
Note that this NA handling behavior differs from EViews 4 and earlier in which NAs were
treated as ordinary values for purposes of equality (“=”) and inequality (“<>”) testing. In
these versions of EViews, the comparison operators “=” and “<>” always returned a 0 or
a 1. The change in behavior was deemed necessary to support the use of string missing val-
ues. In all versions of EViews, comparisons involving ordering (“>”, “<”, “<=”, “>=”)
propagate NAs.
It is still possible to perform comparisons using the previous methods. One approach is to
use the special functions @eqna and @neqna for performing equality and strict inequality
comparisons without propagating NAs. For example, you may use the commands:
series equal1 = @eqna(x, y)
series nequal = @neqna(x, y)
so that NAs in either X or Y are treated as ordinary values for purposes of comparison. Using
these two functions, EQUAL1 will be filled with the value 0, and NEQUAL will be filled with
the value 1. Note that the @eqna and @neqna functions do not compare their arguments to
NA, but rather facilitate the comparison of values so that the results are guaranteed to be 0
or 1. See also “Version 4 Compatibility Mode” on page 173 of the Command and Program-
ming Reference for settings that enable the previous behavior for element comparisons in
programs.
To test whether individual observations in a series are NAs, you may use the @isna func-
tion. For example,
series isnaval = @isna(x)
will fill the series ISNAVAL with the value 1, since each observation in X is an NA.
There is one special case where direct comparison involving NAs does not propagate NAs. If
you test equality or strict inequality against the literal NA value:
series equal2 = (x = NA)
series nequal2 = (y <> NA)
Series—177
EViews will perform a special test against the NA value without propagating NA values.
Note that these commands are equivalent to the comparisons involving the special func-
tions:
series equal3 = @eqna(x, NA)
series nequal3 = @neqna(y, NA)
will yield NAs. However, if the relational expression is used as part of a sample or IF-state-
ment, NA values are treated as FALSE.
smpl 1 1000 if x>y
smpl 1 1000 if x>y and not @isna(x) and not @isna(y)
are equivalent since the condition x>3 implicitly tests for NA values. One consequence of
this behavior is that:
smpl 1 1000 if x<NA
will result in a sample with no observations since less-than tests involving NAs yield NAs.
Very early versions of EViews followed the IEEE rules for missing data with one important
exception. In EViews 2 and earlier, multiplying any number by zero (including NAs) yielded
a zero. In subsequent versions, the value NA times zero equals NA. Thus, an earlier recom-
mended method of recoding (replacing) NA values in the series X no longer worked so that
the command for replacing NA values with the values in Y:
x = (x<>na)*x + (x=na)*y
works in EViews 2, but does not work subsequent versions. The @nan function has been
provided for this purpose.
x = @nan(x,y)
recodes NA values of X to take the values in the series Y. See “Operators” on page 546 of the
Command and Programming Reference.
Series
One of the primary uses of expressions is to generate new series from existing data or to
modify the values in an existing series. Used in combination with samples, expressions
allow you to perform sophisticated transformations of your data, saving the results in new
or existing series objects.
178—Chapter 6. Working with Data
The current discussion focuses on the basic numeric series object. Users who wish to work
with alphanumeric or advanced series features should see Chapter 7. “Working with Data
(Advanced),” on page 191 and Chapter 8. “Series Links,” on page 221.
To create or modify a series, select Quick/Generate Series… or click on the Genr button on
the workfile toolbar. EViews opens a window prompting you for additional information.
Basic Assignment
You can type the series name, followed by an
equal sign and then an expression. For every element of the sample, EViews will evaluate
the expression on the right-hand side of the equality, and assign the value to the destination
series on the left-hand side, creating the series if necessary.
will first create the Y series and fill it with NAs. Then, for every observation in the current
sample, EViews will fill each element of the Y series with the value of the expression. If Y
does exist, EViews will only replace Y values in the current sample with the value of the
expression. All observations not in the sample will be unchanged.
One special form of assignment occurs when the right-hand side of the assignment state-
ment is a constant expression:
y = 3
y = 37 * 2 + 3
EViews will simply assign the value of the constant to all of the observations in the sample.
Using Samples
By modifying the sample of observations used in assignment, you can splice together series
using multiple series assignment commands. For example, if we enter three assignment
commands with different samples: first
Upper window: y = z
Lower window: @all if z<=1 and z>-1
Series—179
and finally,
Upper window: y = -.9 + .1*z
Lower window: if z<=-1
we can generate Y as a piecewise linear function of the series Z. Note that the “@ALL” is
implicit in the latter two assignments.
While it is possible to perform these types of operations using loops and IF-statements (see
Chapter 6. “EViews Programming,” on page 117 of the Command and Programming Refer-
ence), we strongly urge you to use genr and sample statements where possible, since the
latter approach is much more efficient.
Dynamic Assignment
Since EViews evaluates the assignment expression for each observation in the sample, you
can perform dynamic assignment by using lagged values of the destination series on the
right side of the equality. For example, suppose we have an annual workfile that ranges from
1945 to 1997. Then if we enter:
Upper window: y = y + y(-1)
Lower window: 1946 1997
EViews will replace the Y series with the cumulative sum of Y. We begin with 1946, since we
do not want to transform the first value in the workfile. Then for each period, EViews will
take the current value of Y and add it to the lagged value of Y. The assignment is dynamic
because as we successively move on to the next period, the lagged value of Y contains the
cumulative sum.
Note that this procedure destroys the original data. To create a new series with the cumula-
tive sums, you will have to perform the assignment in two steps, first making a copy of the
original series, and then performing the dynamic assignment.
Implicit Assignment
You can make an implicit assignment by putting a simple formula on the left-hand side of
the equal sign. EViews will examine your expression and select, as the destination series,
the first valid series name on the left-hand side of the equality. Then for every observation in
the sample, EViews will assign values using the implicit relationship. For example, if you
enter:
log(y) = x
180—Chapter 6. Working with Data
EViews will treat Y as the destination series, and evaluate y=exp(x) for every observation
in the sample.
The following are examples of valid assignment statements where Y is the destination series:
1/y = z
log(y/x)/14.14 = z
log(@inv(y)*x) = z
2+y+3*z = 4*w
d(y) = nrnd
In general, EViews can solve for, or normalize, equations that use the following on the left-
hand side of the equality: +, –, *, /, ^, log(), exp(), sqr(), d(), dlog(), @inv().
Since Genr is not a general equation solver, there will be situations in which EViews cannot
normalize your equation. You cannot, for example, use the assignment statement:
@tdist(y, 3) = x
since @tdist is not one of the functions that EViews knows how to invert. Similarly, EViews
cannot solve for equations where the destination series appears more than once on the left
side of the equality. For example, EViews cannot solve the equation:
x + 1/x = 5
In both cases, EViews will display the error message “Unable to normalize equation”.
Note that the destination series can appear on both sides of the equality. For example:
log(x) = x
is a legal assignment statement. EViews will normalize the expression and perform the
assignment
x = exp(x)
so that X will be assigned the exponential of the original value of X. EViews will not solve
for the values of X satisfying the equality “LOG(X) = X”.
There are alternative forms for the assignment statement. First, if the series does not exist,
you must use either the series or the genr keyword, followed by the assignment expres-
sion. The two statements:
series y = exp(x)
genr y = exp(x)
Auto-series—181
are equivalent methods of generating the series Y. Once the series has been created, subse-
quent assignment statements do not require the series or the genr keyword:
smpl @all
series y = exp(x)
smpl 1950 1990 if y>300
y = y/2
This set of commands first sets the series to equal EXP(X) for all observations, then assigns
the values Y/2 for the subset of observations from 1950 to 1990 if Y>300.
Auto-series
Another important method of working with expressions is to use an expression in place of a
series. EViews’ powerful tools for expression handling allow you to substitute expressions
virtually any place you would use a series—as a series object, as a group element, in equa-
tion specifications and estimation, and in models.
We term expressions that are used in place of series as auto-series, since the transformations
in the expressions are automatically calculated without an explicit assignment statement.
Auto-series are most useful when you wish to see the behavior of an expression involving
one ore more series, but do not want to keep the transformed series, or in cases where the
underlying series data change frequently. Since the auto-series expressions are automatically
recalculated whenever the underlying data change, they are never out-of-date.
See “Auto-Updating Series” on page 191 for a more advanced method of handling series and
expressions.
Creating Auto-series
It is easy to create and use an auto-series—anywhere you might use a series name, simply
enter an EViews expression. For example, suppose that you wish to plot the log of CP
against time for the period 1953M01 to 1958M12. There are two ways in which you might
plot these values.
One way to plot these values is to generate an ordinary series, as described earlier in “Basic
Assignment” on page 178, and then to plot its values. To generate an ordinary series con-
taining the log of CP, say with the name LOGCP, select Quick/Generate series... from the
main menu, and enter,
logcp = log(cp)
in the command window. EViews will evaluate the expression LOG(CP) for the current val-
ues of CP, and will place these values into the series LOGCP. To view a line graph view of
the series, open the series LOGCP and select View/Graph/Line.
Note that the values of the ordinary series LOGCP will not change when CP is altered. If you
wish to update the values in LOGCP to reflect subsequent changes in CP, you will need to
issue another series or genr assignment statement.
Alternatively, you may create and use an auto-series by clicking on the Show button on the
toolbar, or selecting Quick/Show… and entering the command,
log(cp)
or by typing
show log(cp)
in the command window. EViews will open a series window in spreadsheet view:
Note that in place of an actual series name, EViews substitutes the expression used to create
the auto-series.
An auto-series may be treated as a standard series window so all of the series views and pro-
cedures are immediately available. To display a time series graph of the LOG(CP) auto-
series, simply select View/Graph... from the series window toolbar and click OK to create a
line graph:
Auto-series—183
All of the standard series views and procedures are also accessible from the menus.
Note that if the data in the CP series are altered, the auto-series will reflect these changes.
Suppose, for example, that we take the first four years of the CP series, and multiply theme
by a factor of 10:
smpl 1953m01 1956m12
cp = cp*10
smpl 1953m01 1958m12
The auto-series graph will automatically change to reflect the new data:
184—Chapter 6. Working with Data
In contrast, the values of the ordinary series LOGCP are not affected by the changes in the
CP data.
will display the auto-series containing the geometric moving average. To view a line graph of
the auto-series, select View/Graph... from the series window toolbar and click OK:
If the two workfile pages are of differing frequency, EViews will use the default frequency
conversion method for the series to convert the frequencies. There is no way to specify a dif-
ferent conversion method for auto-series. If you wish to fine-tune the frequency conversion,
you must create a series link (Chapter 8. “Series Links,” on page 221) or copy the series
from the other page. Notably, auto-series defined between panel and non-panel workfiles
may not frequency convert as intended so we recommend the use of links in this setting.
An auto-series across pages may only be used to refer to the series itself and may not be
used in an auto-series expression. You may not, for example, use an expression which takes
the log of an auto-series across pages as a regressor in an equation. You may, however, use
the auto-series in a series assignment, as in
series myser = log(otherpage\yourser)
Auto-series—185
Naming an Auto-series
The auto-series is deleted from your computer memory when you close the series window
containing the auto-series. For more permanent expression handling, you may convert the
auto-series into an auto-updating series that will be kept in the workfile, by assigning a
name to the auto-series.
Simply click on the Name button on the series toolbar, or select Object/Name... from the
main menu, and provide a name. EViews will create an auto-updating series with that name
in the workfile, and will assign the auto-series expression as the formula used in updating
the series. For additional details, see “Auto-Updating Series” on page 191.
you will create a group containing two series: the ordinary series CP, and the auto-series rep-
resenting the geometric moving average. We may then use the group object graphing rou-
tines to compare the original series with the smoothed series. Select View/Graph... from the
group window toolbar and click OK:
Using Auto-Series in
Estimation
One method of using
auto-series in estimation
is to allow expressions as
right-hand side variables.
Thus, you could estimate
an equation with log(x)
or exp(x+z) as an
explanatory variable.
EViews goes a step beyond this use of auto-series, by allowing you to use auto-series as the
dependent variable in estimation. Thus, if you want to regress the log of Y on explanatory
variables, you don’t have to create a new variable LOGY. Instead, you can use the expression
log(y)as your dependent variable.
186—Chapter 6. Working with Data
When you forecast using an equation with an auto-series dependent variable, EViews will, if
possible, forecast the untransformed dependent variable and adjust the estimated confi-
dence interval accordingly. For example, if the dependent variable is specified as log(y),
EViews will allow you to forecast the level of Y, and will compute the asymmetric confi-
dence interval. See Chapter 23. “Forecasting from an Equation,” on page 135 of User’s Guide
II for additional details.
Groups
EViews provides specialized tools for working with groups of series that are held in the form
of a group object. In “Importing Data” on page 137, we used groups to import data from
spreadsheets into existing workfiles. Briefly, a group is a collection of one or more series
identifiers or expressions. Note that a group does not contain the data in the individual
series, only references to the data in the series.
To create a group, select Object/New Object.../Group and fill in the dialog with names of
series and auto-series. Or you may select Show from the workfile toolbar and fill out the dia-
log. Alternatively, type the command group in the command window, followed by a name
to be given to the group and then the series and auto-series names:
group macrolist gdp invest cons
creates the group MACROLIST containing the series GDP, INVEST and CONS. Similarly,
group altlist log(gdp) d(invest) cons/price
creates the group ALTLIST containing the log of the series GDP, the first difference of the
series INVEST, and the CONS series divided by the PRICE series.
There are a few features of groups that are worth keeping in mind:
• A group is simply a list of series identifiers. It is not a copy of the data in the series.
Thus, if you change the data for one of the series in the group, you will see the
changes reflected in the group.
• If you delete a series from the workfile, the series identifier will be maintained in all
groups. If you view the group spreadsheet, you will see a phantom series containing
NA values. If you subsequently create or import the series, the series values will be
restored in all groups.
• Renaming a series changes the reference in every group containing the series, so that
the newly named series will still be a member of each group.
• There are many routines in EViews where you can use a group name in place of a list
of series. If you wish, for example, to use X1, X2, and X3 as right-hand side variables
in a regression, you can instead create a group containing the series, and use the
group in the regression.
Groups—187
To refer the n -th series in the group, simply append “( n )” to the group name. For example,
consider the MACROLIST group, defined above. The expression MACROLIST(1) may be used
to refer to GDP and MACROLIST(2) to refer to INVEST.
You can work with MACROLIST(1) as though it were any other series in EViews. You can
display the series by clicking on the Show button on the toolbar and entering MACRO-
LIST(1). You can include GDP in another group directly or indirectly. A group which con-
tains:
macrolist(1) macrolist(2)
We can also use the individual group members as part of expressions in generating new
series:
series realgdp = macrolist(1)/price
series y = 2*log(macrolist(3))
Note that in this latter example the series keyword is required, despite the fact that the
INVEST series already exists. This is true whenever you access a series as a member of a
group.
Other tools allow you to retrieve the number of series in a group using the @count group
data member:
scalar numgroup = macrolist.@count
To retrieve the names of each of the series, you may use the group data member
@seriesname. These tools are described in greater detail in “Group” on page 280 of the
Object Reference.
There are also functions that will calculate the mean of a group’s rows (@rmean), their stan-
dard deviation (@rstdev) and variance (@rvar).
The @rvalcount function can be used to find how many times a specific value occurs
within the rows of a group. For example:
series numvals = @valcount(macrolist,5)
will create a series where each row of that series will be the count of how many of the series
within the MACROLIST group contain the value “5” for that particular row. Note that the
value argument for this function can be a scalar or a series.
A full list of the group row functions can be found in “Group Row Functions” on page 561 of
the Command and Programming Reference.
will create a group, G1, with two series, the first series containing 1 where-ever union is
equal to “union” and zero elsewhere, the second series containing 1 where-ever union is
equal to “non-union” and zero elsewhere.
@expand may also be used on more than one series to give the cross-interaction of different
series. Thus if you have a second series called MARRIED that contains either “married” or
“single” then entering:
group g2 @expand(union,married)
will create a group, G2, with four series, the first containing 1 where-ever UNION is equal to
“union” and MARRIED is equal to “married”, the second series containing a 1 where-ever
UNION is equal to “union” and MARRIED is equal to “single”, and so on.
The @expand function can be used as part of a mathematical expression, so that a command
of:
group g3 2*@expand(union)
will create a group where the first series contains a 2 where-ever UNION is equal to “union”.
Further,
group g4 log(income)*@expand(married)
Groups—189
creates a group where the first series is equal to the values of the log of INCOME where-ever
MARRIED is equal to “married” and so on.
The of the most useful applications of the @expand function is when specifying an equation
object, since it can be used to automatically create dummy variables.
See also “Automatic Categorical Dummy Variables” on page 28 of User’s Guide II for addi-
tional discussion.
An Illustration
Auto-series and group processing provides you with a powerful set of tools for working with
series data. As we saw above, auto-series provide you with dynamic updating of expres-
sions. If we use the auto-series expression:
log(y)
the result will be automatically updated whenever the contents of the series Y changes.
A potential drawback of using auto-series is that expressions may be quite lengthy. For
example, the two expressions:
log(gdp)/price + d(invest) * (cons + invest)
12345.6789 * 3.14159 / cons^2 + dlog(gdp)
are not suited to use as auto-series if they are to be used repeatedly in other expressions.
You can employ group access to make this style of working with data practical. First, create
groups containing the expressions:
group g1 log(gdp)/price+d(invest)*(cons+invest)
group g2 12345.6789*3.14159/cons^2+dlog(gdp)
If there are spaces in the expression, the entire contents should be enclosed in parentheses.
You can now refer to the auto-series as G1(1) and G2(1). You can go even further by combin-
ing the two auto-series into a single group:
group myseries g1(1) g2(1)
and then referring to the series as MYSERIES(1) and MYSERIES(2). If you wish to skip the
intermediate step of defining the subgroups G1 and G2, make certain that there are no
spaces in the subexpression or that it is enclosed in parentheses. For example, the two
expressions in the group ALTSERIES,
group altseries (log(gdp)/price) 3.141*cons/price
Scalars
Scalar objects are different from series and groups in that they hold a single number instead
of data for each observation in the sample. Scalars are created by commands of the form:
scalar scalar_name = number
where you assign a number to the scalar name. The number may be an expression or special
functions that return a scalar.
To examine the contents of a scalar, you may enter the command show, followed by the
name of the scalar. For example:
scalar logl1 = eq1.@logl
show logl1
stores the log likelihood value of the equation object named EQ1 in a scalar named LOGL1,
and displays the scalar window.