Asset Pricing Models: RMSE Plots in EViews
Stephan Jank
Mai 2006
Department of Statistics, Econometrics and Empirical Economics
Prof. Dr. Joachim Grammig
University of Tübingen
1 Introduction
To visualize the performance of asset pricing models predicted mean returns are often plotted against
realized mean returns. This manual explains how to produce these plots using the statistical software
EViews. The manual will show this by the example of the CAPM. We will reproduce the results of
Grammig and Schrimpf (2006)’s estimation of CAPM, which they use as an benchmark model in their
paper. The necessary data can be obtained through the homepage of the course “Financial Economet-
rics”.
2 Estimation of the CAPM
The estimation of the CAPM by GMM can be done by a set of orthogonality conditions displayed in
the box below. For details on GMM estimation by EViews see Heid (2005): “Estimating Asset Pricing
Models by GMM using EViews”.
Box 1:
(c(1) + c(2) * mkt_r2) * s1b1_r - 1 = 0
..
.
(c(1) + c(2) * mkt_r2) * s5b5_r - 1 = 0
param c(1) 1 c(2) 1
@inst c
Note, that the variable mktex_r2 is demeaned market return. You can generate this series by clicking
on Quick/Generate Series and then type the following commands:
mkt\_r2 = mkt\_r [Sample: 1963Q1 1998Q3]
mkt_r2= mkt_r2-@mean(mkt_r2).
Estimating the system of moment conditions displayed in Box 1 you should receive the following first-
stage estimation results.
Coefficient t-statistic
b0 0.97 86.39
bm 0.93 0.53
3 Fitted Mean Returns vs. Realized Mean Returns
To asses the goodness of fit of a model fitted mean returns are plotted against realized mean returns. The
predicted returns Ri for each portfolio can be calculated from
1 − cov(m, Ri )
E(Ri ) = . (1)
E(m)
To generate this plot in EViews a small program has to be written. For writing programs in EViews
you have to click on File/New/Program. Then save the program in your folder and give it a name i.e.
GRAPH_XY.prg.
1
At the beginning of your program you have to define the sample you are using. You can do this by
the command smpl. In our case the sample is 1963:1 1998:3. The command smpl defines a global
sample period, which is valid for all following commands.
To calculate the predicted returns we will need the stochastic discount factor mt+1 . In the case of CAPM
the stochastic discount factor mt+1 equals b0 + bm rm , with rm being the market return. The second line of
your program (See Box 2) generates this estimated discount factor for the whole sample and calls this
series md. To calculate md use the coefficients obtained from your GMM estimation.
In the next line of your program the command matrix (26,3) matr1 generates a 26 × 3 matrix. You
will need this matrix later to collect fitted mean returns and actual mean returns of our 25 portfolios and
plot them against each other. At this time you can run your provisional program. To do so click on the
button Run in the upper left corner. After running the program the new variable md should appear in
your work file. It should contain the estimated discount factors for all sample periods. Further a 26 × 3
matrix with blank fields will appear in your work file. Box 2 summarized the steps until now.
Box 2:
smpl 1963:1 1998:3
series md = 0.967420 + 0.930442*mkt_r2
matrix (26,3) matr1
In the next step you will fill in the elements of the matrix. The first column will contain the 25 realized
mean returns. The second column will contain the 25 fitted mean returns calculated by equation (1).
The third column will contain 25 values for drawing a 45◦ line in your plot. To draw this line in your
plot you will need an additional 26th row in our matrix matr1.
The realized mean returns are simply the means of our 25 sample portfolios. In EViews you can cal-
culate the mean of a series using the command @mean(.). Calculate the realized means element by
element and arrange them in the matrix matr1 like shown in Box 3. Note, that the first line of Box 3
(’---Realized Mean Returns---) is simply a comment. In EViews comments are made by using ’
at the beginning of the line.
Box 3:
’ Realized Mean Returns
matrix matr1(1,1) = @mean(s1b1_r) - 1
..
.
matrix matr1(25,1) = @mean(s5b5_r) - 1
Calculate the fitted mean returns according to equation (1) and arrange them in the second column of
the matrix matr1. Box 4 shows how equation (1) is translated into EViews programming language.
2
Box 4:
’ Fitted Mean Returns
matrix matr1(1,2) = ( 1 - @cov(md, s1b1_r) ) / @mean(md) - 1
..
.
matrix matr1(25,2) = ( 1 - @cov(md, s5b5_r) ) / @mean(md) - 1
The third column of matr1 contains the values to draw the 45◦ line in our plot. If the asset pricing
model fits perfectly, predicted mean returns would equal realized mean returns and therefore would all
lie on the 45◦ line. For this reason calculate the values for the 45◦ line simply by @mean(s1b1_r) - 1
and arrange them according to Box 5 into the third column of matr1. Finally, an additional data point
is needed to draw the 45◦ line through the origin. This auxiliary point has to lie in the negative area and
will “stretch” the 45◦ line though the intersection of x- and y-axis. This auxiliary data point is written
into the 26th row of matrix matr1. In our example set all values of the 26th row to -0.01. This data point
will later not be visible, since our plot will only show positive values. In Box 5 you see the programming
steps until now.
Box 5:
’ Auxiliary Calculation for 45◦ Line
matrix matr1(1,3) = @mean(s1b1_r) - 1
..
.
matrix matr1(25,3) = @mean(s5b5_r) - 1
matrix matr1(26,1) = -0.01
matrix matr1(26,2) = -0.01
matrix matr1(26,3) = -0.01
The following commands are to generate and formate the graph: First of all, the command delete
graph1* deletes a possibly existing graph graph1 in your work file. The command is simply used to
overwrite graph1 if you use the program repeatedly. Therefore if you want to keep your graphic in your
work file you will have to rename it. The command matr1.xy plots the elements of matrix matr1 in
an xy-plot. The first column C1 of matr1 will be at the x-axis and the second C2 and third column C3
will be plotted at the y-axis. The command freeze(graph1) saves the graphic as graph1. With the
following commands you can now change the appearance of our newly generated graphic graph1.
The command graph1.scale(b) range(0, 0.04) sets the minimum of the x-axis to 0 and the max-
imum to 0.04. The b in brackets stands for “bottom” and denotes the x-axis. You can proceed in the
same way for the y-axis using the letter l, which stands for “left”. Now the auxiliary data point to draw
the 45◦ line will not be visible in your graphic.
3
A grid is added to your graphic by the command graph1.axis(.) grid. Again use the letter b and l
for the x- and y-axis.
The data points (elements) in your plot are formatted with setelem(.). The first elements in your plot
are the fitted mean returns. symbol(1) will produce a small circle for each data point. Deactivate the
connecting line with linepattern(none). The second element in your graphic is the 45◦ line. You
can choose color and width of this line by the commands linecolor(.) and linewidth(.). The fol-
lowing commands simply add a legend and a caption to your graph. For further details see the “EViews
5 Command and Programming Reference”.
Finally, display the graph by the command show graph1. Running your program now should produce
a RSME plot like shown in Figure 1.
Box 6:
delete graph1*
freeze(graph1) matr1.xy
graph1.scale(b) range(0, 0.04)
graph1.scale(l) range(0, 0.04)
graph1.axis(b) grid
graph1.axis(l) grid
graph1.setelem(1) symbol(1) linepattern(none)
graph1.setelem(2)linecolor(black) linewidth(1)
graph1.name(1) Realized Mean Return
graph1.name(2) Fitted Mean Return
graph1.name(3) 45◦ Line
graph1.addtext(t) CAPM: Fitted vs. actual Mean Returns
show graph1
4
Figure 1: Fitted vs. Actual Mean Returns
References
G, J., A. S (2006): “Consumption-Based Asset Pricing with a Reference Level: New
Evidence from the Cross-Section of Stock Returns,” ZEW Discussion Paper, No. 06-032.
H, B. (2005): “Estimating Asset Pricing Models by GMM using EViews,” Manual of the Department
of Statistics, Econometrics, and Empirical Economics (Prof. Dr. Joachim Grammig); University of
Tübingen.