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

Appendix E. Workfile Functions

EViews workfile functions provide information about each observation of a workfile based on information contained in the structure of the workfile.

These functions can be viewed in two ways. First, they are simply virtual series available within each workfile that can be used wherever a regular series might be used. Alternatively, they may be thought of as special functions that take two additional implicit arguments: the workfile within which the function is being used, and the observation number within this workfile for which to return a value.

Since workfile functions are based on the structure of a workfile, they may only be used in operations where a workfile is implicitly involved. They may be used in statements that generate workfile series, in statements that set the workfile sample, and in expressions used in estimation. They cannot be used when manipulating scalar variables or vectors and matrices in EViews programs.

Basic Workfile Information

The @OBSNUM function provides information on basic observation numbering for the workfile, returning the observation number of the current observation in the workfile:

@OBSNUM: returns the observation number of the current observation in the workfile.

The observation number starts at one for the first row, and increments by one for each subsequent row of the workfile.

For example:

series idnum = @obsnum

creates a series IDNUM that contains sequential values from one to the number of observations in the workfile.

Additional functions provide scalar values associated with the workfile and default workfile sample:

@ELEM(x, arg): returns the value of the series x at observation or date arg. If the workfile is undated, arg should be an integer corresponding to the observation ID as given in @OBSNUM. If the workfile is dated, arg should be a string representation of a date in the workfile, enclosed in double quotes. Note that @ELEM is not available in panel structured workfiles.

590—Appendix E. Workfile Functions

@OBSRANGE: returns number of observations in the current active workfile range (0 if no workfile in memory).

@OBSSMPL: returns number of observations in the current active workfile sample (0 if no workfile in memory).

Dated Workfile Information

Basic Date Functions

There is a set of functions that provides information about the dates in your dated workfiles. The first two functions return the start and end date of the period of time (interval) associated with the current observation of the workfile:

@DATE: returns the start date of the period of time of the current observation of the workfile.

@ENDDATE: returns the end date of the period of time associated with the current observation of the workfile.

Each date is returned in a number using standard EViews date representation (fractional days since 1st Jan 1AD, see “Dates” beginning on page 129).

A period is considered to end during the last millisecond contained within the period. In a regular frequency workfile, each period will end immediately before the start of the next period. In an irregular workfile there may be gaps between the end of one period and the start of the following period due to observations that were omitted in the workfile.

The @DATE and @ENDDATE functions can be combined with the EViews date manipulation functions to provide a wide variety of calendar information about a dated workfile.

For example, if we had a monthly workfile containing sales data for a product, we might expect the total sales that occurred in a given month to be related to the number of business days (Mondays to Fridays) that occurred within the month. We could create a new series in the workfile containing the number of business days in each month by using:

series busdays = @datediff(@date(+1), @date, "B")

If the workfile contained irregular data, we would need to use a more complicated expression since in this case the we can not assume that the start of the next period occurs immediately after the end of the current period. For a monthly irregular file, we could use:

series busdays = @datediff(@dateadd(@date, 1, "M"), @date, "B")

Similarly, when working with a workfile containing daily share price data, we might be interested in whether price volatility is different in the days surrounding a holiday for which the market is closed. We can use the first formula given above to determine the

Dated Workfile Information—591

number of business days between adjacent observations in the workfile, then use this result to create two dummy variables that indicate whether a particular observation is before or after a holiday day.

series before_holiday = (busdays > 1)

series after_holiday = (busdays(-1) > 1)

We could then use these dummy variables as exogenous regressors in the variance equation of a GARCH estimation to estimate the impact of holidays on price volatility.

In many cases, you may wish to transform the date numbers returned by @DATE so that the information is contained in an alternate format. EViews provides workfile functions that bundle common translations of date numbers to usable information. These functions include:

@YEAR: returns the four digit year in which the current observation begins. It is equivalent to “@DATEPART(@DATE, "YYYY")”.

@QUARTER: returns the quarter of the year in which the current observation begins. It is equivalent to “@DATEPART(@DATE, "Q")”.

@MONTH: returns the month of the year in which the current observation begins. It is equivalent to “@DATEPART(@DATE, "MM")”.

@DAY: returns the day of the month in which the current observation begins. It is equivalent to “@DATEPART(@DATE, "DD")”.

@WEEKDAY: returns the day of the week in which the current observation begins, where Monday is given the number 1 and Sunday is given the number 7. It is equivalent to “@DATEPART(@DATE, "W")”.

@STRDATE(fmt): returns the set of workfile row dates as strings, using the date format string fmt. See “Date Formats” on page 132 for a discussion of date format strings.

@SEAS(season_number): returns a dummy variable based on the period within the current year in which the current observation occurs, where the year is divided up according to the workfile frequency. For example, in a quarterly file, “@SEAS(1)”, “@SEAS(2)”, “@SEAS(3)”, and “@SEAS(4)” correspond to the set of dummy variables for the four quarters of the year. These expressions are equivalent (in the quarterly workfile) to “@QUARTER=1”, “@QUARTER=2”, “@QUARTER=3”, and “@QUARTER=4”, respectively.

@ISPERIOD(arg): returns a dummy variable for whether the observation is in the specified period, where arg is a double quoted date or period number. Note that in dated workfiles, arg is rounded down to the workfile frequency prior to computation.

592—Appendix E. Workfile Functions

Additional information on working with dates is provided in “Dates” beginning on page 129.

Trend Functions

One common task in time series analysis is the creation of variables that represent time trends. EViews provides two distinct functions for this purpose:

@TREND(["base_date"]): returns a time trend that increases by one for each observation of the workfile. The optional base_date may be provided to indicate the starting date for the trend.

@TRENDC(["base_date"]): returns a calendar time trend that increases based on the number of calendar periods between successive observations. The optional base_date may be provided to indicate the starting date for the trend.

The functions @TREND and @TRENDC are used to represent two different types of time trends that differ in some circumstances.

In a regular frequency workfile, @TREND and @TRENDC both return a simple trend that increases by one for each observation of the workfile.

In an irregular workfile, @TREND provides an observation trend as before, but @TRENDC now returns a calendar trend that increases based on the number of calendar periods between adjacent observations. For example, in a daily irregular file where a Thursday has been omitted because it was a holiday, the @TRENDC value would increase by two between the Wednesday before and the Friday after the holiday, while the @TREND will increase by only one.

Both @TREND and @TRENDC functions may be used with an argument consisting of a string containing the date at which the trend has the value of zero. If this argument is omitted, the first observation in the workfile will be given the value of zero.

The decision of which form of time trend is appropriate in a particular context should be based on what role the time trend is playing in the analysis. When used in estimation, a time trend is usually used to represent some sort of omitted variable. If the omitted variable is something that continues to increase independently of whether the workfile data is observed or not, then the appropriate trend would be the calendar trend. If the omitted variable is something that increases only during periods when the workfile data is observed, then the appropriate trend would be the observation trend.

An example of the former sort of variable would be where the trend is used to represent population growth, which continues to increase whether or not, for example, financial markets are open on a particular day. An example of the second sort of variable might be some type of learning effect, where learning only occurs when the activity is actually undertaken.

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