Homework 2
The data is available here in
Matlab and as a text
file. Save the data file into a directory, say C:\bus810. The commands to load
the data are then:
>>
cd c:\bus810
>>
load usbondret.mat
If you want to do some
analysis in Excel, just import the data using the text file.
There are five columns of 510
rows each. The data starts on
The Matlab file includes a
variable “usbondretdates” which is the datenumber (utterly meaningless). You
can find out the date using the command:
>>
datestr(usbondretdates)
If you want the date in
readable form for the 25th observation, type the command
>>
datestr(usbondretdates(25))
The commands to compute:
The covariance matrix of the
data from rows 100 to 205 is:
>>
CovMat=cov(usbondret(100:205,:))
CovMat
=
1.0e-003 *
0.0056
0.0115 0.0142 0.0160
0.0181
0.0115
0.0254 0.0322 0.0371
0.0429
0.0142
0.0322 0.0423 0.0502
0.0600
0.0160
0.0371 0.0502 0.0624
0.0779
0.0181
0.0429 0.0600 0.0779
0.1094
The eigenvalues and
eigenvectors of this coviance matrix:
>>
[EigMat,EigVec]=eig(CovMat)
EigMat
=
0.3802
-0.7259 -0.4810 0.2820
0.1329
-0.6525
0.1971 -0.4332 0.5034
0.3072
0.6143
0.4988 0.1037 0.4368
0.4151
-0.2280
-0.4246 0.6915 0.1505
0.5167
0.0190
0.0721 -0.3035 -0.6735
0.6699
EigVec
=
1.0e-003 *
0.0001 0 0 0 0
0
0.0003 0 0 0
0 0
0.0014 0 0
0 0 0
0.0134 0
0 0 0 0
0.2300
If you want to use the princomp.m file, I have posted it online here (ssh!).