, A Solution Manual for:
Statistics and Data Analysis for
Financial Engineering: 2nd Edition
by David Ruppert and David Matteson
John L. Weatherwax∗
March 24, 2021
∗
1
,Introduction
Here you’ll find some notes that I wrote up as I worked through this excellent book. For
some of the problems I used R to perform any needed calculations. The code snippets for
various exercises can be found at the following location:
http://www.waxworksmath.com/Authors/N_Z/Ruppert/SNDAFFE_2nd_Edition/ruppert.html
I’ve worked hard to make these notes as good as I can, but I have no illusions that they
are perfect. If you feel that that there is a better way to accomplish or explain an exercise
or derivation presented in these notes; or that one or more of the explanations is unclear,
incomplete, or misleading, please tell me. If you find an error of any kind – technical,
grammatical, typographical, whatever – please tell me that, too. I’ll gladly add to the
acknowledgments in later printings the name of the first person to bring each problem to my
attention.
Acknowledgments
Special thanks to (most recent comments are listed first): Chenguang Wang, Reina Shintaku,
Ajay Julian, Som Sowmyan, Duc Truyen Dam, Martin Vedani, Patrick Ahearn, John Chung,
and Xu Ren for helping improve these notes and solutions.
Contents
1 Chapter 2 (Returns) 6
2 Chapter 3 (Fixed Income Securities) 17
3 Chapter 4 (Exploratory Data Analysis) 31
4 Chapter 5 (Modeling Univariate Distributions) 45
5 Chapter 6 (Resampling) 64
6 Chapter 7 (Multivariate Statistical Models) 71
4
,7 Chapter 8 (Copulas) 79
8 Chapter 9 (Regression: Basics) 93
9 Chapter 10 (Regression: Troubleshooting) 102
10 Chapter 11 (Regression: Advanced Topics) 109
11 Chapter 12 (Time Series Models: Basics) 118
12 Chapter 13 (Time Series Models: Further Topics) 137
13 Chapter 14 (GARCH Models) 154
14 Chapter 15 (Cointegration) 171
15 Chapter 16 (Portfolio Theory) 176
16 Chapter 17 (The Capital Asset Pricing Model) 185
17 Chapter 18 (Factor Models and Principal Components) 195
18 Chapter 19 (Risk Management) 207
19 Chapter 20 (Bayesian Data Analysis and MCMC) 220
20 Chapter 21 (Nonparametric Regression and Splines) 228
5
, 0.15
0.1
0.10
0.05
0.0
0.00
MRK return
FReturn
−0.1
−0.05
−0.10
−0.2
−0.15
−0.2 −0.1 0.0 0.1 −0.3 −0.2 −0.1 0.0 0.1 0.2
GMReturn MSFT return
Figure 1: Left: A scatter plot of the returns of Ford as a function of the returns of GM.
Left: A scatter plot of the returns of Merck as a function of the returns of Microsoft.
1 Chapter 2 (Returns)
R Lab
See the R script Rlab.R where the problem for this chapter are worked.
Problem 1 (GM and Ford returns)
In Figure 1 (left) we show the scatter plot of the returns of Ford as a function of the returns of
GM. We notice that these returns do appear to be correlated (they are distributed somewhat
symmetrically about a line) and the outliers of each stocks return do appear together.
Problem 2
In the accompanying R code we plot the two returns. The two sets of points lie almost exactly
on the line y = x. They have a correlation (using the R function cor) given by 0.9995408.
6
,Problem 3 (MSFT and MRK returns)
In Figure 1 (right) we show the scatter plot of the returns of Merck as a function of the
returns of Microsoft. We notice that these returns are much less correlated (they have a
correlation coefficient of 0.2710328) than the returns between GM and Ford (which have a
correlation coefficient of 0.6139335).
Problem 4
I get with a certainty of 51% that the value of the stock will be below $950000 at the close
of at least one of the 45 trading days.
Problem 5-8
I get that the hedge fund will make a profit with a probability of 0.38775. I get that the hedge
fund will suffer a loss with a probability of 0.58844. I get that the hedge funds expected
profit is given by 9922.63 but the expected return (in units of days) -0.01783836.
Problem 9
Based on the expression used to compute the logr variable the mean log-return for one year
is 0.05 or 5% and the standard deviation of the log-returns for one year is 0.2 or 20%
Prob1em 10
Looking at the plots generated many of them seem to “trend”. The trending is “real” in the
sense that the mean return each day is positive and each step should result in a larger price
(in expectation). The variance of this process is very large (as is true with financial data)
which adds noise to the time series.
Problem 11
That command simulates the prices of an geometric random walk where
Pt = P0 exp(rt + rt−1 + rt−2 + · · · + r1 ) .
7
,Problem 12
In the R code for this problem we plot the log-returns of McDonald’s as a function of the
return. The two are indistinguishable. The correlation between these two series is 0.9999536
indicating that the two types of returns move in the same manner.
Problem 13
Computing the mean and the standard deviation of the two series I get
[1] "returns: mean= 0.000503; std= 0.008900"
[1] "log-returns: mean= 0.000463; std= 0.008901"
Notice that the mean is smaller for the log-returns while the standard deviation looks about
the same.
Problem 14-15
We can use the R command t.test to compare these two series of numbers. Running that
we get the following
> t.test(x=rets, y=lrets, paired=TRUE)
t = 15.866, df = 1175, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
3.478409e-05 4.460108e-05
sample estimates:
mean of the differences
3.969258e-05
This indicates that the mean difference is significant between the two samples. The assump-
tions of the t-test are that the random variables come from a normal distributions. While
that is normally not strictly true in financial data sets the t-test is normally robust to de-
viations in the distribution of the inputs. There are some evidence that the log-returns will
have a smaller mean than the mean of the simple returns see
https://papers.ssrn.com/sol3/papers.cfm?abstract_id=1549328
8
,While the above t-test shows that there is a significant difference in the mean returns between
the two different ways of calculating them, this difference is very small (four-tenths of a basis
point) especially compared to the standard deviation of the returns (89 basis points). Thus
while statistically significant the observation made by the t-test may not be practically
significant.
The two returns seem close enough for small values to consider them equivalent.
Problem 16
Running the R code for this problem we run a Monte Carlo simulation and find an expected
profit from playing this game to be 0.060500 which is larger than zero and one should play
this game.
Problem 17
Running our Monte-Carlo simulation with these new rules gives an expected profit for playing
this game of 0.243000 which is also larger than zero and one should like to play this game
even more than before.
Exercises
Exercise 2.1
Part (a): To have a value less than $990 means that we must have a log return less than
990
log = −0.01005034 .
1000
To find this probability we evaluate
pnorm(−0.01005034, mean = 0.001, sd = 0.015)
to get the value 0.2306556.
Part (b): In five trading days our log return
√ will be normally distributed with a mean
5(0.001) = 0.005 and a standard deviation of 5(0.015) = 0.03354102. To be less than $990
we need to have a logarithm less than -0.01005034 (as computed above). Thus in this case
we need to evaluate
pnorm(−0.01005034, mean = 0.005, sd = 0.03354102)
to get the value 0.3268188.
9
,Exercise 2.2
110
To have a price greater than 110 we must have a log return greater than log 100
=
0.09531018 in one years time. This will happen with a probability of
1 − pnorm(0.09531018, mean = 0.1, sd = 0.2) = 0.509354 .
Exercise 2.3
The log-return for two years would√be a normal random variable with a mean of by 2(0.1) =
0.2 with a standard deviation of 2(0.15) = 0.212132. To have the price in two years be
larger than $90 means that the log return must be larger than log(90/80) = 0.117783. Using
the theory of normal random variables this will happen with a probability of 0.6508345. This
calculation is done in the following R code
m = 0.2
s = sqrt(2)*0.15
lr = log(90/80)
z = ( lr - m ) / s
1 - pnorm(z)
Exercise 2.4
For this problem we will need to recall the definitions of the net return
Pt − Pt−k
Rt (k) = , (1)
Pt−k
and the log return
rt (k) = log(1 + Rt (k)) . (2)
Using the above formulas we have that
P3 − P3−2 P3 − P1 98 − 95
R3 (2) = = = = 0.03061224 .
P3−2 P1 95
Then r3 (2) = log(1 + 0.03061224) = 0.03015304.
Exercise 2.5
Part (a): With dividends our single period net return Rt is given by
Pt + Dt − Pt−1
Rt = ,
Pt−1
10
, so that with the numbers for this problem we get
P 2 + D2 − P 1 54 + 0.2 − 52
R2 = = = 0.04230769 .
P1 52
Part (b): Next recall that with dividends the multiperiod gross returns 1 + Rt (k) is given
by
Pt + Dt Pt−1 + Dt−1 Pt−k+1 + Dt−k+1
1 + Rt (k) = ··· . (3)
Pt−1 Pt−2 Pt−k
Using the above we have
P 4 + D4 P 3 + D3 P2 + D2
1 + R4 (3) =
P3 P P
2 1
59 + 0.25 53 + 0.2 54 + 0.2
= = 1.147959 .
53 54 52
Thus R4 (3) = 0.1479588.
Part (c): For this part we will use
P 3 + D3 53 + 0.2
r3 = log(1 + R3 ) = log = log = −0.01492565 .
P2 54
Exercise 2.6
Part (a): Using the formula in the book for Rt (k) when we have dividends we have that
P 3 + D3 P 2 + D2
1 + R3 (2) = .
P2 P1
Using the numbers given in this exercise we compute the above to be R3 (2) = 0.01460689.
Part (b): Using the formula in the book for rt (k) when we have dividends we have that
r4 (3) = log(1 + R4 ) + log(1 + R3 ) + log(1 + R2 )
P 4 + D4 P 3 + D3 P2 + D2
= log + log + log
P3 P2 P
1
87 + 0.125 83 + 0.1 85 + 0.1
= log + log + log .
83 85 82
Evaluating this we find r4 (3) = 0.06300449.
Exercise 2.7
Part (a): The variable rt (4) would be a normal random variable with a mean 4(0.06) = 0.24
and a variance of 4(0.47) = 1.88 (assuming that the number 0.47 quoted is the one period
variance and not standard deviation).
11
Statistics and Data Analysis for
Financial Engineering: 2nd Edition
by David Ruppert and David Matteson
John L. Weatherwax∗
March 24, 2021
∗
1
,Introduction
Here you’ll find some notes that I wrote up as I worked through this excellent book. For
some of the problems I used R to perform any needed calculations. The code snippets for
various exercises can be found at the following location:
http://www.waxworksmath.com/Authors/N_Z/Ruppert/SNDAFFE_2nd_Edition/ruppert.html
I’ve worked hard to make these notes as good as I can, but I have no illusions that they
are perfect. If you feel that that there is a better way to accomplish or explain an exercise
or derivation presented in these notes; or that one or more of the explanations is unclear,
incomplete, or misleading, please tell me. If you find an error of any kind – technical,
grammatical, typographical, whatever – please tell me that, too. I’ll gladly add to the
acknowledgments in later printings the name of the first person to bring each problem to my
attention.
Acknowledgments
Special thanks to (most recent comments are listed first): Chenguang Wang, Reina Shintaku,
Ajay Julian, Som Sowmyan, Duc Truyen Dam, Martin Vedani, Patrick Ahearn, John Chung,
and Xu Ren for helping improve these notes and solutions.
Contents
1 Chapter 2 (Returns) 6
2 Chapter 3 (Fixed Income Securities) 17
3 Chapter 4 (Exploratory Data Analysis) 31
4 Chapter 5 (Modeling Univariate Distributions) 45
5 Chapter 6 (Resampling) 64
6 Chapter 7 (Multivariate Statistical Models) 71
4
,7 Chapter 8 (Copulas) 79
8 Chapter 9 (Regression: Basics) 93
9 Chapter 10 (Regression: Troubleshooting) 102
10 Chapter 11 (Regression: Advanced Topics) 109
11 Chapter 12 (Time Series Models: Basics) 118
12 Chapter 13 (Time Series Models: Further Topics) 137
13 Chapter 14 (GARCH Models) 154
14 Chapter 15 (Cointegration) 171
15 Chapter 16 (Portfolio Theory) 176
16 Chapter 17 (The Capital Asset Pricing Model) 185
17 Chapter 18 (Factor Models and Principal Components) 195
18 Chapter 19 (Risk Management) 207
19 Chapter 20 (Bayesian Data Analysis and MCMC) 220
20 Chapter 21 (Nonparametric Regression and Splines) 228
5
, 0.15
0.1
0.10
0.05
0.0
0.00
MRK return
FReturn
−0.1
−0.05
−0.10
−0.2
−0.15
−0.2 −0.1 0.0 0.1 −0.3 −0.2 −0.1 0.0 0.1 0.2
GMReturn MSFT return
Figure 1: Left: A scatter plot of the returns of Ford as a function of the returns of GM.
Left: A scatter plot of the returns of Merck as a function of the returns of Microsoft.
1 Chapter 2 (Returns)
R Lab
See the R script Rlab.R where the problem for this chapter are worked.
Problem 1 (GM and Ford returns)
In Figure 1 (left) we show the scatter plot of the returns of Ford as a function of the returns of
GM. We notice that these returns do appear to be correlated (they are distributed somewhat
symmetrically about a line) and the outliers of each stocks return do appear together.
Problem 2
In the accompanying R code we plot the two returns. The two sets of points lie almost exactly
on the line y = x. They have a correlation (using the R function cor) given by 0.9995408.
6
,Problem 3 (MSFT and MRK returns)
In Figure 1 (right) we show the scatter plot of the returns of Merck as a function of the
returns of Microsoft. We notice that these returns are much less correlated (they have a
correlation coefficient of 0.2710328) than the returns between GM and Ford (which have a
correlation coefficient of 0.6139335).
Problem 4
I get with a certainty of 51% that the value of the stock will be below $950000 at the close
of at least one of the 45 trading days.
Problem 5-8
I get that the hedge fund will make a profit with a probability of 0.38775. I get that the hedge
fund will suffer a loss with a probability of 0.58844. I get that the hedge funds expected
profit is given by 9922.63 but the expected return (in units of days) -0.01783836.
Problem 9
Based on the expression used to compute the logr variable the mean log-return for one year
is 0.05 or 5% and the standard deviation of the log-returns for one year is 0.2 or 20%
Prob1em 10
Looking at the plots generated many of them seem to “trend”. The trending is “real” in the
sense that the mean return each day is positive and each step should result in a larger price
(in expectation). The variance of this process is very large (as is true with financial data)
which adds noise to the time series.
Problem 11
That command simulates the prices of an geometric random walk where
Pt = P0 exp(rt + rt−1 + rt−2 + · · · + r1 ) .
7
,Problem 12
In the R code for this problem we plot the log-returns of McDonald’s as a function of the
return. The two are indistinguishable. The correlation between these two series is 0.9999536
indicating that the two types of returns move in the same manner.
Problem 13
Computing the mean and the standard deviation of the two series I get
[1] "returns: mean= 0.000503; std= 0.008900"
[1] "log-returns: mean= 0.000463; std= 0.008901"
Notice that the mean is smaller for the log-returns while the standard deviation looks about
the same.
Problem 14-15
We can use the R command t.test to compare these two series of numbers. Running that
we get the following
> t.test(x=rets, y=lrets, paired=TRUE)
t = 15.866, df = 1175, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
3.478409e-05 4.460108e-05
sample estimates:
mean of the differences
3.969258e-05
This indicates that the mean difference is significant between the two samples. The assump-
tions of the t-test are that the random variables come from a normal distributions. While
that is normally not strictly true in financial data sets the t-test is normally robust to de-
viations in the distribution of the inputs. There are some evidence that the log-returns will
have a smaller mean than the mean of the simple returns see
https://papers.ssrn.com/sol3/papers.cfm?abstract_id=1549328
8
,While the above t-test shows that there is a significant difference in the mean returns between
the two different ways of calculating them, this difference is very small (four-tenths of a basis
point) especially compared to the standard deviation of the returns (89 basis points). Thus
while statistically significant the observation made by the t-test may not be practically
significant.
The two returns seem close enough for small values to consider them equivalent.
Problem 16
Running the R code for this problem we run a Monte Carlo simulation and find an expected
profit from playing this game to be 0.060500 which is larger than zero and one should play
this game.
Problem 17
Running our Monte-Carlo simulation with these new rules gives an expected profit for playing
this game of 0.243000 which is also larger than zero and one should like to play this game
even more than before.
Exercises
Exercise 2.1
Part (a): To have a value less than $990 means that we must have a log return less than
990
log = −0.01005034 .
1000
To find this probability we evaluate
pnorm(−0.01005034, mean = 0.001, sd = 0.015)
to get the value 0.2306556.
Part (b): In five trading days our log return
√ will be normally distributed with a mean
5(0.001) = 0.005 and a standard deviation of 5(0.015) = 0.03354102. To be less than $990
we need to have a logarithm less than -0.01005034 (as computed above). Thus in this case
we need to evaluate
pnorm(−0.01005034, mean = 0.005, sd = 0.03354102)
to get the value 0.3268188.
9
,Exercise 2.2
110
To have a price greater than 110 we must have a log return greater than log 100
=
0.09531018 in one years time. This will happen with a probability of
1 − pnorm(0.09531018, mean = 0.1, sd = 0.2) = 0.509354 .
Exercise 2.3
The log-return for two years would√be a normal random variable with a mean of by 2(0.1) =
0.2 with a standard deviation of 2(0.15) = 0.212132. To have the price in two years be
larger than $90 means that the log return must be larger than log(90/80) = 0.117783. Using
the theory of normal random variables this will happen with a probability of 0.6508345. This
calculation is done in the following R code
m = 0.2
s = sqrt(2)*0.15
lr = log(90/80)
z = ( lr - m ) / s
1 - pnorm(z)
Exercise 2.4
For this problem we will need to recall the definitions of the net return
Pt − Pt−k
Rt (k) = , (1)
Pt−k
and the log return
rt (k) = log(1 + Rt (k)) . (2)
Using the above formulas we have that
P3 − P3−2 P3 − P1 98 − 95
R3 (2) = = = = 0.03061224 .
P3−2 P1 95
Then r3 (2) = log(1 + 0.03061224) = 0.03015304.
Exercise 2.5
Part (a): With dividends our single period net return Rt is given by
Pt + Dt − Pt−1
Rt = ,
Pt−1
10
, so that with the numbers for this problem we get
P 2 + D2 − P 1 54 + 0.2 − 52
R2 = = = 0.04230769 .
P1 52
Part (b): Next recall that with dividends the multiperiod gross returns 1 + Rt (k) is given
by
Pt + Dt Pt−1 + Dt−1 Pt−k+1 + Dt−k+1
1 + Rt (k) = ··· . (3)
Pt−1 Pt−2 Pt−k
Using the above we have
P 4 + D4 P 3 + D3 P2 + D2
1 + R4 (3) =
P3 P P
2 1
59 + 0.25 53 + 0.2 54 + 0.2
= = 1.147959 .
53 54 52
Thus R4 (3) = 0.1479588.
Part (c): For this part we will use
P 3 + D3 53 + 0.2
r3 = log(1 + R3 ) = log = log = −0.01492565 .
P2 54
Exercise 2.6
Part (a): Using the formula in the book for Rt (k) when we have dividends we have that
P 3 + D3 P 2 + D2
1 + R3 (2) = .
P2 P1
Using the numbers given in this exercise we compute the above to be R3 (2) = 0.01460689.
Part (b): Using the formula in the book for rt (k) when we have dividends we have that
r4 (3) = log(1 + R4 ) + log(1 + R3 ) + log(1 + R2 )
P 4 + D4 P 3 + D3 P2 + D2
= log + log + log
P3 P2 P
1
87 + 0.125 83 + 0.1 85 + 0.1
= log + log + log .
83 85 82
Evaluating this we find r4 (3) = 0.06300449.
Exercise 2.7
Part (a): The variable rt (4) would be a normal random variable with a mean 4(0.06) = 0.24
and a variance of 4(0.47) = 1.88 (assuming that the number 0.47 quoted is the one period
variance and not standard deviation).
11