0% found this document useful (0 votes)
674 views8 pages

Week 1 - EViews Practice Note

Uploaded by

Chip choi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
674 views8 pages

Week 1 - EViews Practice Note

Uploaded by

Chip choi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

125.

811 Advanced Risk Analytics

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.

Download student lite version from: http://www.eviews.com/download/student11/


2. Working with EViews using GUI (Graphical User Interface)
2.1 Create EViews workfiles
When EViews is opened a pop-up will appear and you can choose the option “Create a new
EViews workfile”. Otherwise, you can choose File/New/Workfile

2
Choose the Dated type, data frequency and enter the sample range

2.2 Import data to Eviews workfiles


Choose File/Import/Import from file…, then navigate to the excel file needed to be imported:

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:

2.3 Calculate the daily return series and risk-free rate

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

𝑟𝑀𝑡 − 𝑟𝑓𝑡 : Excess return of market portfolio M at time t

𝛼: Alpha or Jensen Alpha, representing the risk-adjusted performance measure of asset i


𝛽𝑖 : Beta of asset i, representing the systematic risk, or the sensitivity of asset i towards
the market movement

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).

3. Using EViews programing code (for reference)


The Student version of EViews does not allow using EViews programing code however, the code is
provided here for your reference if you have the University or Enterprise version of EViews.

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
'*************************************************************************************

'Change path to program path


%path=@runpath
cd %path

'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

'Calculate the return series


genr r_cen = log(cen/cen(-1))
genr r_cvt = log(cvt/cvt(-1))
genr r_nzx = log(nzx50/nzx50(-1))

'Convert annual risk-free rate to daily risk-free rate


genr r_fd = rf/252

'Estimate CAPM model for CEN and CVT


Equation cen_capm.ls (r_cen-r_fd) c (r_nzx-r_fd)
Equation cvt_capm.ls (r_cvt-r_fd) c (r_nzx-r_fd)

You might also like