School of Social Sciences Economic Studies
M.Sc. International Business EC50001 Applied Business Statistics NOTES FOR EViews 9 Note: for illustration purposes we will be using the data in the GuideData.xls file you can find on MyDundee.
Starting Up EViews To start EViews on a computer in a computer lab within the university go to: Start All programs School Software Social Sciences ing and Finance Eviews 9
Importing Data There are several ways to import your data into EViews: from a text file (.txt), an Excel spreadsheet (.xls) or a previously created EViews workfile (.wf1). Direct input is also possible, but will not be covered here. 1. Creating an empty workfile. From the main toolbar select: File New Workfile…
Page 1
A “Workfile Create” window will popup. Use the drop-down list on the top left corner of this window to specify the Workfile structure type. The most common choices will be: (a) Unstructured/Undated: This is the most general format for importing data and the one we will use for this module. You only need to specify the number of observations in the Data range space. (b) Dated – regular frequency: This format is preferred when working with time-series data. You need to specify the data frequency from the drop-down list and specify the Start date and End date: Some examples are: Annual: Start date: 1990 , End date: 2000 Quarterly: Start date: 1990:1 , End date: 2000:4 Monthly: Start date: 1990:1 , End date: 2000:12 (c) Balanced : This format is designed to work with data that are organized in a structure: multiple units observed for multiple years. Here you need to provide both the frequency and start/end dates for the time dimension and the number of units in the (number of cross sections).
Note: If you wish to give your workfile a name at this point then enter the name in the lower left corner of the Workfile Create window. When details are complete Click OK. You will see a Workfile Window inside the EViews workspace, containing two objects: c and resid.
Page 2
2. Importing data into an the workfile from Excel: Assuming data is in column format with variable names in the first row, follow the steps: (i) Select from the main toolbar: File Import Import from file…
(ii)
In the “Open” window that pops up, locate the Excel file you wish to import and click Open. (To try this on your own you can use the GuideData.xls file from the module’s website on MyDundee.) Usually EViews does a good job recognizing the beginning and ending of the data in a spreadsheet, so you will rarely need to change the defaults.
Page 3
In the popup window click either “Yes” or “No” (this option will have limited effect for the purposes of this module). Additional objects, x and y in our case, should now appear in the Workfile window as shown below:
Saving and Loading EViews Workfiles To save the current workfile go to the main menu and select: File Save This will save both the data in the workfile and any additional variables you create or results you produce (see below). If you forget to save the workfile and just close down EViews you will be prompted as to whether or not you wish to save your work. To open an EViews workfile you have previously saved go to the main menu and select: File Open EViews Workfile… In the Open window that pops up, locate the .wf1 file you wish to import and click Open. The Workfile window will popup showing all of the objects (variables, graphs, equations, etc.) stored in the workfile. To quickly check the contents of an object, just double-click on the object name. To rename an object, right-click on the object and select Rename. Enter the new name in the window that pops up. To delete an object from the workfile, right-click the object and select delete.
Page 4
Data Analysis with EViews Now that you have created your workfile you can start to investigate the power and ease of EViews. Outlined below are some of the basics. a. Graphing a series There are a number of ways this can be done. The simplest way is to go to the main menu (NB: the menu of the main EViews window, not the Workfile window) and select: Quick Graph… To create a scatter plot of y and x type x y (variable names separated by a space) in the Series List window that pops up and click OK.
EViews has a long list of plot types that it can produce but we are currently interested in a scatter plot. Selecting Scatter under the Graph type area of the Graph Options window that pops up will produce the following plot:
Page 5
Notice that the Graph window has a number of buttons and menu items located at the top. To save the graph as a separate object in your Workfile click on the Name button from this list and provide a suitable name for the graph. Then click OK. If you save your Workfile now, the next time you load it (the Workfile) you will be able to double click on the newly-created graph object and view it.
b. Transforming/Creating new variables To create a new variable click on the Genr button located at the top of the Workfile window. In the Generate Series by Equation window that pops up type in the required equation/formula for the new variable in the following format: new_series_name = equation to generate new series For example: to multiply the x variable by 2: mynewvariable = 2*x to take the natural logarithm of x: logx = log(x) to raise x to the power 2: xsquare = x^2 to take the square root of x: sqrtx = sqr(x) to take the absolute value of x: absx = abs(x) to create the exponential of x: expx=exp(x)
You are free to pick the name you give to the new variable, but it is a good practice to use informative names, as it is done from the second example onwards. Some care is required however: if you type in x = log(x) then the x variable in the Workfile will be replaced by the log of x - i.e. the original variable is overwritten by the new variable (this can create a big mess if at some point you forget that you have done such an overwriting).
c. Selecting a group of variables In some instances it may be convenient to select a group of variables to analyse (e.g. getting a correlation matrix or creating a scatter plot). To do so, highlight the required variables using click/shift-click or click/ctrl-click. Once all of the required series are highlighted right-click on top of a selected variable and then on Open as Group…
Page 6
A Group window will open with the variables listed and with its own buttons and menu items located at the top.
These buttons allow a range of operations to be carried out on the group of variables. For example, to create a scatter plot of x and y, click on View Graph… on the Group window’s menu. You will need to go through some additional steps to create the scatter plot, but these are intuitive and very similar to the ones described under point a. of this section.
d. Summary statistics of a variable To get the summary statistics (mean, variance, etc.) of a single variable, double-click on the variable’s name on the Workfile window. This will open the Series window with its own buttons and menu located at the top.
Page 7
Clicking on View Descriptive Statistics & Tests Stats Table in the Series window’s menu will produce a table of summary statistics for the variable.
The Series menu will allow a range of analyses to be carried out apart from simple summary statistics: simple hypothesis tests, graphing and many more.
e. The command area The command area is the white space below the main menu in the EViews window. This is where you can type in various commands, carry out calculations (in lieu of a calculator), etc. For example, typing: scalar average = ( 1 + 2 + 3 + 4) / 4
and hitting enter will create a single valued object named ‘average’ and add it to the Workfile.
Page 8
To view the contents of this scalar simply double-click the object in the Workfile window and look at value of the Scalar window that pops up.
Page 9
Linear Regression Models with EViews a. Estimating a model From the EViews main menu select: Quick Estimate Equation…
In the Equation Estimation window you have to type the specification of your model as: dependent_variable c idependent_variable1 idependent_variable2 … (variable names separated by spaces) For example, to regress y on a constant and x type: ycx
and click OK. Notes: (i) If you wish to estimate a model without a constant term then omit c in the model specification. (ii) You can also transform variables in the specification of the model to be estimated: log(y) c x x^2
(iii) You can change the estimation method although for EC50001 it will always be Least Squares. (iv) If you wish to estimate the model using a subset of the full dataset then you can change the sample range at the bottom of the window.
Page 10
Once you click OK, the Equation window appears containing the standard output from OLS estimation of the model which can then be reported, analysed, etc.
Note: You can save the specification of your model as an object in the Workfile by clicking on Name in the Equation window menu.
b. Further Analysis through the Estimation window menus Residual plot The residuals from the most recent estimation are stored in the object labelled resid in the Workfile window. Note that this series will be overwritten with the residuals from any subsequent estimation.
Page 11
From the Equation window’s menu select: View Actual,Fitted,Residual Residual Graph
Here the residuals are graphed by observation number which is fine for time-series data and checking for the presence of autocorrelation. To visually check for heteroskedasticity or nonlinearity, we need to plot the residuals against the independent variable(s). This is a scatter plot and, given that we have both the residuals and the independent variable(s) in the Workfile window, we do can such a plot using the instructions given under “Data Analysis with EViews”, part a. of this document. Such a plot is given below:
Note that, as usual, you can save the residual graph as an object in the Workfile by clicking on the Name button of the Graph window. On the Estimation window select View Estimation Output to return to the estimation output.
Page 12
Testing hypotheses on the estimated coefficients This section covers hypothesis tests other than the standard significance tests which can be done from the estimation output (as we have seen in class). On the Equation window select: View Coefficient Diagnostics Wald Test-Coefficient Restrictions… In the Wald Test window that pops up type in the hypothesis (restrictions) to be tested. For example, to test whether the coefficient associated with x is statistically different from 100 we need to type: c(2) = 100
After clicking OK we obtain the following output in the Equation window:
EView uses a t-test to test this simple hypothesis and reports the associated p-value. This simple hypothesis can also be tested using an F-test and produces the same p-value. The Chisquare test is similar to the F-test but makes no degrees-of-freedom correction (this is why the p-value is slightly different).
Page 13
For t-hypotheses testing use commas to separate the individual coefficient values. For example, in a multiple linear regression model we could test tly the hypotheses implied by the command: c(2)=5, c(3)=6, c(4)=0
Finally, note that the estimates of the coefficients are stored in the object labelled c in the Workfile window. The order in which they appear corresponds to the order in which the constant and the explanatory variables appear in the specification of the model in the Equation window. In the example above c(1) would be the constant, c(2) would be the coefficient of the first explanatory variable and so on.
Page 14