1 / 49

EViews Training

EViews Training. Data Objects: Data Functions. Note: Information for examples in this tutorial can be found in these files. Data: Data.xlsx Results: Results.wf1 Practice Workfile: Data.wf1. Data and Workfile Documentation. Data.wf1 and Data.xlsx have the following data:

avon
Download Presentation

EViews Training

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EViews Training Data Objects: Data Functions Note: Information for examples in this tutorial can be found in these files. • Data: Data.xlsx • Results: Results.wf1 • Practice Workfile: Data.wf1

  2. Data and Workfile Documentation • Data.wf1 and Data.xlsx have the following data: • Workfile Page: Timeseries (Data.xlsx tab Timeseries): quarterly, Q1 1980 – Q1 2012 • GDP – real GDP data (billions of dollars) from the Bureau of Economic Analysis. • PCE – real consumption data (billions of dollars) from the Bureau of Economic Analysis. • Inv – real private sector investments (billions of dollars) from the Bureau of Economic Analysis. • G – real government spending (billions of dollars) from the Bureau of Economic Analysis. • y – a series that grows over time (trend series).

  3. Data Functions • EViews has a large number of built-in functions that allow you to perform data manipulation. • EViews functions are typically denoted by the symbol “@”. • This tutorial reviews some typical functions used for data manipulation, such as: • Random numbers • Statistical Functions • Commonly Used Time Series Functions

  4. Generating Random Numbers

  5. Generating Random Numbers (Series): Example 1 • You can generate a series of (pseudo) random numbers drawn from a variety of distributions. • There are a number of ways to generate a random series. Generating a random series: Example 1 • Open EViewsworkfileData.wf1. • Select Quick→ Generate Series from the main menu. • Type y1 = nrndin the dialog box and press Enter.

  6. Generating Random Numbers (Series): Example 1 (cont’d) • The result is shown here. • As seen, this generates a series y1, which is normally distributed with mean 0 and standard deviation equal to 1.

  7. Generating Random Numbers (Series): Example 2 Generating a random series: Example 2 • Type in the command window: series z=nrnd • Press Enter. • This creates a new series z, which is normally distributed with mean 0 and standard deviation equal to 1. • Alternatively, you can create a random series by typing in the command window.

  8. Generating Random Numbers (Series): Example 3 Generating a random series: Example 3 • Type in the command window: smpl@all series newdata = 0smpl1980q2 @lastnewdata=newdata(-1)+@mean(d(gdp))+@stdev(d(gdp))*nrnd • Press Enterafter each command line. • Note: for an explanation of statistical functions @mean, @stdev, or d(gdp), see Descriptive Statisticsin this tutorial. • Suppose you want to simulate a random walk process with distribution properties similar to the observed distribution of an existing series (for example,gdp):

  9. Generating Random Numbers (Series): Example 3 (cont’d) • Here we show both the new series (newdata) and the GDP series. • As seen, the command has generated a series newdata, which follows the same distribution process as the gdpseries. • Note that the commands instruct EViews to first create a new series (newdata) consisting of zeros. • Then, from the second observation (1980q2) onwards it sums the preceding observation with the mean and standard deviation of differenced gdp(multiplied by a normal random variable).

  10. Generating Random Numbers (Series):Common Functions/Commands • EViews has a number of functions/commands that allow you to draw from a variety of distributions. • The most commonly used functions/commands are summarized below. Common Commands/Functions

  11. Generating Random Numbers (Series):PDF and CDF • It is also very easy to generate the pdf and cdf of a random variable. Generating a random series together with its pdf and cdf: • Type in the command window: smpl@all series d1=@ruinf(0,2) show d1 @dunif(d1,0,2) @cunif(d1,0,2) • Press Enterafter each command line.

  12. Generating Random Numbers (Series):PDF and CDF (cont’d) • The result is shown here. • As you can see, EViews displays all three columns: the actual new random variable we created (d1), its density function (in the second column) and its cumulative distribution function (third column).

  13. Functions for Descriptive Statistics

  14. Descriptive Statistics • EViews has extensive built-in descriptive statistical functions. • These descriptive statistical functions take an optional sample as an argument. • The default sample is the current workfile range.

  15. Descriptive Statistics Common Commands/Functions Common Commands/Functions

  16. Descriptive Statistics Functions: Example 1 Descriptive Statistics Functions: Example 1 • Type in the command window: series x1=@mean(gdp) • Press Enter. • This creates a new series x1 which has all elements equal to the mean of GDP. • Suppose you want to create a series x1, which is equal to the mean of the “gdp” series.

  17. Descriptive Statistics Functions: Example 2 Descriptive Statistics Functions: Example 2 • Type in the command window: smpl 1980q1 1989q4 series x2=@mean(gdp, "1980q1 1989q4") smpl 1990q1 1999q4 series x2=@mean(gdp, "1990q1 1999q4") smpl 2000q1 @last series x2=@mean(gdp, "2000q1 @last") smpl @all • Press Enter after each command line. • As a next example, consider creating another series x2, which is equal to the mean of the “gdp” series, defined over several sub-samples:

  18. Descriptive Statistics Functions: Example 2 (cont’d) • The result is shown here. For ease of exposition, we plot the graph of the series. • As you can see, EViews has created a step-wise function defined over the various samples as we specified in the command line.

  19. Descriptive Statistics Functions: Example 3 Descriptive Statistics Functions: Example 3 1a. One way to do this is to type the following in the command window : series new=(gdp+pce+inv)/3 1b. Another way, would be to type in the command window group row functions: group groupdatagdppceinv This creates a new group (named “groupdata”) with containing the three series. 2b. Now type the following command in the command window: series new=@rmean(groupdata) This creates a series which is computed by taking the mean of all the three series for each row. • Press Enter after each command line. • Suppose you want to create a variable which is the average (or sum) of multiple series.

  20. Descriptive Statistics Functions: Example 4 Descriptive Statistics Functions: Example 4 • Let’s first define the sample over which descriptive stats are computed. Type in the command window: smpl 1980m01 1990m12 • Next, let’s create a vector vby typing in the command window: vector(3) v • Next, define the vector elements to gather the desired statistics, by typing in the command window: v(1)=@mean(gdp) v(2)= @varp(gdp) v(3)= @covs(gdp,pce) • Press Enter after each command line. • Suppose you want to collect descriptive statistics in a vector (or matrix).

  21. Descriptive Statistics Functions: Example 4 (cont’d) Explanations of commands/functions for Example 4 • Note that the optional sample argument may only be used if the results are assigned to a series. For example: series y=@mean(x[,s]) – where s is the sample, allows you to define the sample as the last argument of the descriptive statistic function. • If results are assigned into a matrix, vector or scalar object (as in example above), the sample needs to be defined explicitly before using the descriptive statistical functions.

  22. Common Time-Series Functions (Lags/Leads, Differences, Percent Change, Moving Statistics, Trends)

  23. Lags & Leads Common Commands/Functions • It is easy to work with lags/leads and other time series functions in Eviews. • You do not need to generate series of lags/leads in many places in EViews; simply write the command for them when needed (i.e., when estimating a regression).

  24. Lags & Leads:Example 1 Lags & Leads: Example 1 • Type in the command window: smpl @all show gdpgdp(-4) • Press Enter. • Note that this creates a new group which contains both thegdpseries and its fourth lag (we requested that both series appear) • If you would like to save the group, click the button and name the group. • Create and show the 4th lag of the variable gdp.

  25. Lags & Leads:Example 2 Lags & Leads: Example 2 • Type in the command window: show gdpgdp(2) • Press Enter. • Note that this creates a new group which contains both the gdp series and its 2nd lead (we requested that both series appear) • We have saved and named the group (group 04). • Create and show the 2nd lead of the variable gdp.

  26. Lags & Leads:Example 3 Lags & Leads: Example 3 • Type in the command window: show gdp(0 to -3) • Press Enter. • Note that this creates a new group which contains the gdp series and all lags from 1 to 3. • The group is saved as group 05. • You can just as easily create a number of lags in EViews • For example, you may show the actual value and all first three lags of gdp.

  27. Lags & Leads:Example 4 Lags & Leads: Example 4 • Type in the command window: series newseries=@lag((gdp-inv)/gdp,4) • Press Enter. • Note that the new series is first computed as: (gdp-inv)/gdp. • Then, the fourth lag is taken. • You can also create a series as a lagged transformation of other series.

  28. Differences:Example 1 Differences : Example 1 • Type in the command window: show d(gdp) • Press Enter. • Note that for comparison purposes here we have shown both the d(gdp) series and another series where the difference is computed manually (gdp-gdp(-1)). As seen, they are the same. • EViewshas several build-in functions for working with differenced data (levels and logs).

  29. Differences:Example 2 Differences : Example 2 • Type in the command window: show dlog(gdp) • Press Enter. • Log-difference:

  30. Differences:Example 3 Differences : Example 3 • Type in the command window: show d(gdp,3) • Press Enter. • EViews also allows you to take higher order differences (of levels and logs):

  31. Differences:Example 4 Differences : Example 4 • Type in the command window: show dlog(gdp,4) • Press Enter. • Higher-order differences in logs

  32. Seasonal Differences • You can also take seasonal differences after specifying both ordinary and seasonal difference terms:

  33. Percent Change • EViews also has a number of functions dealing with percent changes. Common Functions

  34. Percentages:Example 1 Percentages : Example 1 • Type in the command window: show @pc(gdp) Note that @pc shows the percent change in percent. If you would like to compute it in decimals, type in the command window: show @pch(gdp) • Press Enter. • Note that we instructed EViews to display both series (@pc(gdp) and @pch(gdp)) in the same group. The group is saved as group06. • Calculate the percent change in gdp from the previous period.

  35. Percentages:Example 2 Percentages : Example 2 • Type in the command window: show @pca(gdp) • Press Enter. • Note this computes the annualized percent change in the quarterly (one-period) gdp data. • This is the same as: 100*((1+@pch(gdp))4-1). • Calculate the annualized one-period percent change in gdp.

  36. Percentages:Example 3 Percentages : Example 3 • Type in the command window: show @pcy(gdp) • Press Enter. • Note this computes the one-year percent change ingdpdata. • In quarterly data (which is the case here), this is the same as: 100*(gdpt+4-gdpt/gdpt). • Calculate the year-over-year percent change in gdp.

  37. Cumulative Statistic Functions Common Functions • Cumulative functions perform “running-total”-type calculations. • For these functions the length of the window changes with each observation.

  38. Cumulative Statistic Functions: Example 1 Cumulative Statistic: Example 1 • Type in the command window: show @cumsum(y,"1980Q3 1981Q4") • Press Enter. • Note that to facilitate comparisons, we have shown both the original (y) series and the new cumulative sum defined over the specific sample. • The cumulative sum series is calculated by adding the values from the start of the sample to the current value. • The cumulative sum starts at the beginning of the sample (1980Q3) and ends at the end of the sample (1981Q4). Original series@cumsum(y,s) • Show the cumulative sum for series y over a pre-defined sample.

  39. Cumulative Statistic Functions: Example 2 Cumulative Statistic: Example 2 • Type in the command window: show @cumbsum(y,"1980Q3 1981Q4") • Press Enter. • The backward cumulative sum series is calculated by adding the values from the end of the sample to the current value. • Note that, unlike the previous example, the backward cumulative sum starts at the end of the sample (1984Q1) and ends at the start of the sample (1980Q3). Original series@cumbsum(y,s) • Show the cumulative backward sum for series y over a pre-defined sample.

  40. Cumulative Statistic Functions: Example 3 Cumulative Statistic: Example 3 • Type in the command window: show @cummean(y,"1980Q3 1981Q4") • Press Enter. • The cumulative mean series is calculated from the start of the sample (1980Q3) until the current observation. Original series@cummean(y,s) • Show the cumulative mean of series y over a pre-defined sample.

  41. Cumulative Statistic Functions: Example 4 Cumulative Statistic: Example 4 • Type in the command window: show @cumstdev(y,"1980Q3 1981Q4") • Press Enter. • The cumulative standard deviation is calculated from the start of the sample (1980Q3) until the current observation. Original series@cumstdev(y,s) • Show the cumulative standard deviation of series y over a pre-defined sample.

  42. Moving Statistic Functions • These types of functions have shorter, fixed, user-specified window lengths. • They provide information on n observations (including the current observation). • The window length n is chosen by the user. • If the original data has missing values (NA), results may or may not propagate NA.

  43. Moving Statistic Functions (cont’d) Common Functions

  44. Moving Statistic Functions: Example 1 Moving Statistic: Example 1 • Type in the command window: show @movav(y,4) • Press Enter. • Note that the 4-period backwards moving average is computed as: (X+X(-1)+X(-2)+X(-3))/4. Original series@movav(y,n) • Show a 4-period moving average for series y.

  45. Moving Statistic Functions: Example 2 Moving Statistic: Example 2 • Type in the command window: show @movav(y(-1),4) • Press Enter. • The 4-period backwards moving average is computed as: (X+X(-1)+X(-2)+X(-3))/4. This is then lagged by one period as we specified. Original series@movav(y(-1),n) • You can combine operators (functions) to perform more complex examples. • Suppose you would like to show the 4-period moving average for series y lagged by one period.

  46. Moving Statistic Functions: Example 3 Moving Statistic: Example 3 • Type in the command window: show @movsum(y,5) • Press Enter. • Note that the 5-period backward moving sum is generated by adding: (X+X(-1)+X(-2)+X(-3)+X(-4)). Original series@movsum(y,5) • Show a 5-period backward moving sum for series y.

  47. Moving Statistic Functions: Example 4 Moving Statistic: Example 4 • Type in the command window: show @movsum(y(2),5) • Press Enter. • Note that the 5-period backward moving sum is now centered at the observation which falls in the middle of the interval. • It is computed by adding: (X(-1)+X(-2)+X+X(+1)+X(+2)). Original series@movsum(y(2),5) • Show a centered 5-period backward moving sum for series y.

  48. Trends • It is very easy to generate trends in EViews by using a number of built-in functions. Common Functions

  49. Trends: Examples Generating Trends: • Type in the command window: series trend1=@trend series trend2=@trend+1 • Press Enterafter each command. • Note that @trend creates a series that begins at 0; while @trend+1 has initial value of 1. Trend1 Trend2 • Create two trend series one with initial value 0 and the other one 1.

More Related