Week 1 - EViews Practice Note
Week 1 - EViews Practice Note
Workshop 1
Estimate CAPM model with EViews
1
Introduction to EViews program
This note shows how the CAPM model can be estimated using the EViews program. Data for stock
prices, stock index and risk free rate can be downloaded from Yahoo Finance,
https://nz.finance.yahoo.com/. For an illustration, a dataset is provided, which includes the stock
prices of Contact Energy (CEN), Comvita (CVT) and NZX50, and the annual risk-free rate (RF)
quoted daily. As the student version of EViews restrict 1,500 observations per series, the range
of the sample data is restricted from 01/01/2008 to 26/09/2013.
1. EViews Installation
Eviews is an econometrics software that offers financial institutions, corporations, government
agencies, and academics access to powerful statistical, time series, forecasting, and modeling tools through
an innovative, easy-to-use object-oriented interface.
2
Choose the Dated type, data frequency and enter the sample range
3
Click to Finish, a pop-up windows will appear. If you want to link the data of the workfile with the
data in excel file so that it can automatically updated when data in excel file changes, click Yes, if
not click No. In our case, we choose No for simplicity. A final workfile can be seen as belows:
4
We normally calculate the logarithmic returns in Finance for analyses and research, which
accounts for the log normal distribution of the stock prices and the continuous compounding as
usually employed in finance models. The logarithmic returns at time t (i.e., current time) is the
difference between the logged price at time t and that at time (t-1) (i.e., one period prior to the
current time). As our data is in daily frequency, that is the difference between the today logged
prices and yesterday logged prices:
𝑃𝑡
𝑟𝑡 = ln(𝑝𝑡 ) − ln(𝑝𝑡−1 ) = ln( )
𝑃𝑡−1
Note that, the log function in EViews represents the natural logarithm, hence it is equivalent with
ln function in Excel.
In Eviews workfile, choose Genr, a pop-up window will appear and you can type the following to
calculate the returns of Contact Energy (CEN): r_cen = log(cen/cen(-1))
Similarly, for return of Comvita (CVT), r_cvt = log(cvt/cvt(-1)), return of NZX50, r_nzx =
log(nzx50/nzx50(-1))
For risk-free rate, as it is annual rate quoted daily, we need to convert it to the daily rate by
dividing the annual rate by 252 days since there are normally 252 trading days a year for stock
markets. Hence, r_fd=rf/252
2.4 Estimate the CAPM model
The CAPM model is represented in econometrics form as:
5
in which, 𝑟𝑖𝑡 is the return of asset i (can be individual asset or a portfolio) at time t. 𝑟𝑓𝑡 is the risk-
free rate at time t. 𝑟𝑀𝑡 is the return of market portfolio at time t. 𝜖𝑖𝑡 is the residuals and it can be
considered as the idiosyncratic risk or non-systematic risks resulted from the CAPM model, which
is the risk specifically related to asset i.
𝑟𝑖𝑡 − 𝑟𝑓𝑡 : Excess return of asset i at time t
To estimate the CAPM model for Contact Energy (CEN) for example, click to Quick in the main menu of
Eviews and choose Estimate Equation:
Type in the box: (r_cen-r_fd) c (r_nzx-r_fd). Note the method for the estimation is OLS so we leave the
option of Method as default (LS – Least Squares).
6
We obtain the estimation output for alpha, beta as follows:
The estimation output shows that Alpha = -0.000478 (i.e., - 0.0478%). The risk-adjusted performance of
Contact Energy is quite comparable with the NZX50 over the sample period. It is also statistically
insignificant with a p-value of 0.31 (>0.01), meaning alpha is not statistically significant from 0 at 1%
significant level. Beta is estimated to be 0.975, which is smaller 1, indicating that the Contact Energy is
7
slightly less risky than the NZX50. However, as the beta is very close to 1, the movement of Contact Energy
is very similar to the NZX50 (i.e., 1% increase in NZX50 is associated with 0.975 increase in the Contact
Energy).
EViews Code – Create the new program code by choosing File/New/Program in EViews. Save the EViews
code and the Data file in one folder and click the EViews code file to run:
'*************************************************************************************
'Program to estimate CAPM model
'*************************************************************************************
'Import the XLS data this code is generalized so that you can import file with more
than 1 sheet
%names = @tablenames("Week 1_Data.xls")
%n = @word(%names,1)
wfopen "Week 1_Data.xls" range=%n
for !i=2 to @wcount(%names)
%n = @word(%names, !i)
import "Week 1_Data.xls" range=%n
next