Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Eviews5 / EViews5 / Docs / EViews 5 Users Guide.pdf
Скачиваний:
152
Добавлен:
23.03.2015
Размер:
11.51 Mб
Скачать

Series—137

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 recommended 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 “Basic Mathematical Functions” on page 575 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.

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 149 and Chapter 8, “Series Links”, on page 177.

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.

138—Chapter 6. Working with Data

You should enter the assignment statement in the upper edit box, and the relevant sample period in the lower edit box.

The assignment statement is actually an implicit loop over observations. Beginning with the first observation in the sample, EViews will evaluate the assignment statement for each included observation.

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.

For example, if there is no series named Y,

y = 2*x + 37*z

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 statement 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 Genr commands. For example, if we enter three Genr commands with different samples: first

Upper window: y = z

Lower window: @all if z<=1 and z>-1

y = y + y(-1) 1946 1997
y = -.9 + .1*z if z<=-1
y = -2 + 3*z if z>1

Series—139

followed by a Genr with, Upper window: Lower window:

and finally,

Upper window:

Lower window:

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 the Command and Programming Reference), 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:

Lower window:

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 cumulative 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:

140—Chapter 6. Working with Data

log(y) = x

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 lefthand 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”.

Using the Command Window

You can create series and assign values from the command window. First, set the workfile sample using the smpl statement, then enter the assignment statement.

Соседние файлы в папке Docs