29
MPhil computer package lesson: getting started with Eviews Ryoko Ito ([email protected], [email protected], www.itoryoko.com ) 1. Creating an Eviews workfile 1.1. Download Wage data.xlsx from my homepage: http://www.itoryoko.com/Wage%20data.xlsx and open the excel file. 1.2. Notice that this data is not dated. We have 3296 observations.

MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito ([email protected],

  • Upload
    dodat

  • View
    228

  • Download
    0

Embed Size (px)

Citation preview

Page 1: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

MPhil computer package lesson: getting started with Eviews

Ryoko Ito ([email protected], [email protected], www.itoryoko.com )

1. Creating an Eviews workfile

1.1. Download Wage data.xlsx from my homepage: http://www.itoryoko.com/Wage%20data.xlsx and open the excel file.

1.2. Notice that this data is not dated. We have 3296 observations.

Page 2: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

1.3. Open Eviews (Eviews 7 or Eviews 8 will do).

1.4. Then from the toolbar at the top of the screen, go: “File” “New” “Workfile”

Page 3: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

1.5. Under the heading “Workfile structure type”, from the dropdown box, choose “Unstructured/Undated”.

1.6. In the “Observations” field, enter 3297. (One extra observation point is added on purpose for now.) Then press “OK”.

Page 4: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

1.7. You’ll see a new workfile window created like this.

2. Creating series

2.1. Next, we generate series (variables) we want. They are exper, male, school, and wage. In the command area (the white long space at the top), type in: series exper Then press enter. Do the same for series male series school series wage and press enter each time. You’ll see the variables we wanted being created in the workfile window.

Page 5: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

2.2. In the workfile window, select the series exper, male, school, and wage simultaneously by holding down the Ctrl key and clicking on these variable names. Then right click and go: “Open” “as Group”.

2.3. You’ll see all variables opened in one window called “Group”. The variables are filled with “NA” and there is no data yet. The data field filled with “NA” are currently locked. To insert data, select “Edit +/-“ in the Group window. You’ll find that the NA fields are now unlocked.

Page 6: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

2.4. Go to the Wage data.xlsx file. Then copy and paste data from Excel to Eviews using the usual Ctrl + C and Ctrl V.

2.5. Then press “Edit +/-“ button again to lock the variables.

2.6. Notice that, at the last observation points contain no data (“NA”). Leave this for now and close the Group window by clicking “x” on the right top corner.

2.7. When you see the message “Delete Untitled GROUP?”, just choose “Yes”. (If you choose “Name” or “Store”, you’ll get the option to save the Group in the workfile.)

Page 7: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

3. Changing the number of observations or sample range

3.1. To eliminate the last observation point that we don’t need: - Click anywhere around the field that says “Range: 1 3297 – 3297 obs”. - In the Workfile Structure window, change the “Observations” field from 3297 to 3296. - Then press “OK”.

3.2. When the message “Resize involves removing 1 observations. Continue ?” appears, choose “Yes”.

Page 8: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

3.3. At the moment, the sample range we are working on is the entire sample range (all of 3296 observations). Suppose we want to work (e.g. run regression, plot data, see summary statistics) on a subset of this data, 200th – 500 th observations, say. To do this, - Click anywhere around the field that says “Sample: 1 3296 – 3296 obs”. - In the Sample window, change the “Sample range pairs” field from “@all” to “200 500”. - Then press “OK”.

3.4. Now we see that the workfile is active only at 200th – 500th observations.

Page 9: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

4. Plotting data

4.1. To plot wage data, double click on “wage” to get the Series window in the SpreadSheet view. Then in the Series window, go: “View” “Graph…”.

4.2. The Graph Options window appears, so select “OK”. Then we see the wage data between 200th – 500th observations. (BUT you can change the sample range by moving the cursor at the bottom of the plot.)

Page 10: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

5. Descriptive statistics

5.1. Some of the basic summary statistics of wage data can be obtained by clicking (in the same wage series window): “View” “Descriptive Statistics & Tests” “Histogram and Stats”. (Notice that there are other options like “Correlogram…”, “Unit-Root Test…” and “Simple Hypothesis Tests” available along the way. You can play with them later.)

5.2. Then the plot view changes to summary statistics.

Page 11: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

5.3. You can go back to the SpreadSheet view by clicking “View” “SpreadSheet”.

6. Data transformation

6.1. Put the sample range back to “@all”. (Otherwise the data transformation procedure that follows below will apply only to the selected subset of data.)

Page 12: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

6.2. Suppose we want to log-transform wage data, and call it lwage. To do this, in the command area, type in: “series lwage = log(wage)” and press enter. Then you’ll see a new variable called lwage in the workfile window. (Double click lwage to see it.)

6.3. (You can do other data transformation in the command area. For example: - exponential transformation: “series e_wage = exp(wage)” - adding up variables: “series wage_lwage = wage + lwage” and so on.)

Page 13: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

7. OLS regression

7.1. Note that the built-in variable “resid” and coefficient “c” are currently empty (filled with NA and zeros). They are where the regression residuals and estimated coefficients go to.

7.2. Suppose we want to regress wage on a constant + exper +male + school by the OLS regression. To do this, type in “ls wage c exper male school” in the command area Then press enter. An Equation window will pop-up, giving the estimation results and diagnostic statistics.

Page 14: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

7.3. Check the “resid” variable and “c” coefficient. They are no-longer empty. They contain regression residuals and coefficient estimates (which appear in the Equation window).

7.4. In the Equation window, there are different options for inspecting the regression residuals (i.e. the resid variable). To see this, in the Equation window, go: “View” “Actual, Fitted, Residual” etc. Along the way, also find that there are other options for diagnostics (e.g. Coefficient Diagnostics, Residual Diagnostics). You can play with them later.

Page 15: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

7.5. Whatever you do in the above step, to get back to the original estimation output view, go: “View” “Estimation Output”.

7.6. Try to close the Equation window by clicking “x”. But suppose we want to keep this estimation output. When the message “Delete Untitled EQUATION?”, click “Name”.

Page 16: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

7.7. Give it a name in the “Name to identify object” field. Say, “eq01”. Then click “OK”.

7.8. The equation will be stored as “eq01” in the workfile window. By double clicking it, you’ll get the equation window again.

Page 17: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

7.9. Instead of saving the estimation output as an Equation, you can also “Freeze” the estimation output. To do this, in the Equation window, click “Freeze”. Then a Table window showing the estimation output appears.

7.10. However, in the Table window, we can no longer see options for inspecting the estimation residuals and diagnostic etc. The frozen Table window is useful when you are doing a lengthy model selection procedure by changing the equation slightly. It’s easier to freeze your Equation window instead of saving the Equation window by naming it each time you change your model specification slightly.

7.11. We can inspect residuals also via the resid variable. For example: - Double click on “resid” variable - Click “View” “Correlogram”.

Page 18: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

7.12. Suppose we want to see the autocorrelation structure of resiuals in the level. Then click “OK”.

7.13. You’ll see the correlogram picture and diagnostics. (You can also see the summary statistics and perform unit-root test on the resi variable etc in this window, as described earlier.)

Page 19: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

8. Using Eviews Help option

8.1. Suppose you want to know what ”Q-stat” means. You can find out by the Eviews help option. To get Eviews Help window, just press “F1”. (Or, manually, in the main Eviews window toolbar, click “Help “Eviews Help Topics …”.)s

8.2. Then type in “q stat” in the search field, say. Double clicking on “Residual Diagnostics” will explain a lot about “Q-Stat.

8.3. Whenever you wonder how to do things or what things mean or how things are computed in Eviews, “F1” is very useful. Eviews Help window is a very good read.

9. Plot two series together

9.1. Suppose you want to see if there is some relationship between the regression residuals and the dependent variable (wage). To plot residuals against wage, first save the current residuals as a new variable called “resa” by tying: “series resa = resid” in the command area.

9.2. Then open “resa” and “wage” as a Group.

Page 20: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

9.3. Then, in the Group window, go “View” “Graph…” to get the Graph Options window.

9.4. In the Graph Options window, under the “Graph type” section, choose “Scatter”. Then press “OK”.

Page 21: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

9.5. You’ll find that “resa” and “wage” appear to be related.

9.6. To swap axes, in the Group window, go “View” “Graph…”. Then under the “Option Pages” section, click “Axes & Scaling” “Data scaling”. In the “Series axis assignment” section: - click on “1 Bottom” to select the variable that is currently the x-axis. (Wage in the picture below.) - then choose “Left” button option from the right-hand side options. - then press “OK”.

Page 22: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

9.7. See that the axes are swapped. (Note that along the above step, there are a lot of other options to manipulate the graph. You can play with them later.)

10. Relationship between variables

10.1. Suppose we want to see covariance / correlation between “resa” and “wage”. In their Group window, go “View” “Covariance Analysis …”.

Page 23: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

10.2. Then you’ll see a lot of options in the Covariance Analysis window. Just press “OK”. You’ll get a covariance matrix in the Group window.

10.3. Suppose you want to check for Granger causal relationship between two variables, “resa” and “wage”, say. Then in their Group window, go “View” “Granger Causality…”. Choose lags, then press “OK”.

10.4. Note that in the above step, there are lots of other options for checking and testing relationships between the variables. You can play with them later.

Page 24: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

11. In-sample fitted values

11.1. If we want to get in-sample fitted values of the dependent variable (wage) from the previous regression we performed: - Go back to the workfile window - Open “eq01” (or whatever you called it to save the previous Equation window). - In the Equation view, click “Forecast”. - Options appear (e.g. “forecast name” etc). Just click “OK”.

11.2. Then the Equation window turns into a plot. This shows the in-sample fitted values of “wage” (called “wagef”) and + - 2 s.e. around it. Note that, in the Workfile window, a new variable called “wagef” appears, which stores the in-sample fitted values of wage.

11.3. Remember, you can always go back to the original estimation output view in the Equation window by going “View” “Estimation Output”.

Page 25: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

12. Coefficient restrictions

12.1. Suppose we want to test whether the coefficients on the “male” and “school” variables take the same value. They are the 3rd and 4th coefficients in my original Equation window (displayed below).

12.2. To test this coefficient restriction, in the Equation window, go: “View” “Coefficient Diagnostics” “Wald Test – Coefficient Restrictions…”. (Note that, along this step, there are lots of other testing options like the “Likelihood ratio test” and options for “Residual Diagnostics” etc. You can play with them later.)

Page 26: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

12.3. In the “Wald Test” window that pops up, type in: “c(3) = c(4)” and press “OK”. (Note that this command is consistent with the order of my covariates in the Equation window. To test whether the coefficients on the i-th and j-th variables are the same, type in: “c(i) = c(j)”.)

12.4. Then the Wald test results come up in the same Equation window.

Page 27: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

13. Saving your workfile

13.1. To save your workfile, in the Workfile window, click “Save” and save it.

14. Advanced stage: programming your own model (Not covered in class but you can try on your own)

14.1. Suppose you have your own model, which Eviews may or may not have as part of its buit-in models and functions. In that case you can build your own Eviews program to estimate it. We’ll see one example here: GARCH model for financial data. GARCH is a very popular model for studying high-frequency financial data. The model specifications are found in, for instance, - In the Eviews Help option (press “F1”) and search keywords like “arch” will bring up explanations. - http://www.cmat.edu.uy/~mordecki/hk/engle.pdf (Prof. Engle’s note on GARCH) - http://en.wikipedia.org/wiki/Autoregressive_conditional_heteroskedasticity

14.2. Download an Eviews workfile, Dow.wf1, and a program file called garch.prg from my homepage: http://www.itoryoko.com/Dow.wf1 http://www.itoryoko.com/garch.prg

14.3. To open Dow.wf1 in Eviews, in the Eviews window, go: - “File” “Open” “Eviews Workfile” go to the location of “Dow.wf1” and open it. - “File” “Open” “Programs…” go to the location of “garch.prg” and open it.

Page 28: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

14.4. The workfile contains two variables “close” and “open”. They are daily Dow index (time series) recorded at market opening and closing (available from Yahoo! Finance https://uk.finance.yahoo.com/ ). The sampling length is quite long (but I can’t remember what it was.)

Page 29: MPhil computer package lesson: getting started with Eviewsitoryoko.com/Eviews instructions.pdf · MPhil computer package lesson: getting started with Eviews Ryoko Ito (ri239@cam.ac.uk,

14.5. If you press “Run” in the Program window of the garch.prg file, Eviews will think for a few seconds. Then it will fit Gaussian GARCH(1,1) model to the Dow return data constructed by log-differencing the closing index. The estimation results come up as the Logl object with diagnostic statistics.

14.6. You can change model specification (you can create very advanced model specifications) by editing commands in the Program window.

14.7. You can learn what each line of command in the garch.prg means by resorting to Eviews Help option (just click “F1” button). Search keywords like “logl” will give you lots of good tips.

END Good luck!