Anda di halaman 1dari 8

A KALMAN FILTER BASED MODEL FOR ASSET PRICES AND ITS

APPLICATION TO PORTFOLIO OPTIMIZATION


Baeho Kim
Dept. of Management Science and Engineering
Stanford University
481 Terman Engineering Center,
CA 94305 USA
email: baehokim@stanford.edu
James A. Primbs
Dept. of Management Science and Engineering
Stanford University
444 Terman Engineering Center,
CA 94305 USA
email: japrimbs@stanford.edu
ABSTRACT
A portfolio optimization problem has an objective to maxi-
mize an investors wealth by investing in the optimal set of
risky assets. The goal of this paper is to develop a Kalman
lter based model for asset prices that can be used in con-
junction with a control theory oriented state space model
for portfolio optimization. To this end, we employ a Cap-
ital Asset Pricing Model (CAPM) with time-varying coef-
cients where the Kalman lter is used to estimate coef-
cients. We then connect this model to a formulation of the
stochastic receding horizon control framework. Together,
they provide a methodology for estimating an asset pric-
ing model and performing portfolio optimization. We test
this framework on numerical data to show that the opti-
mally controlled wealth process achieves a better perfor-
mance than the market portfolio by solving the portfolio
optimization problem in a reasonable amount of time.
KEY WORDS
Kalman lter, CAPM with time-varying coefcients, Port-
folio Optimization, Stochastic Receding Horizon Control
Model
1 Introduction
In general, portfolio optimization problems are stochastic
control problems since their objective is to maximize an
investors wealth (or utility) by investing in risky assets.
In this regard, it is natural that some of the quantities of
relevance in a given model may be neither known nor ob-
servable. Thus, the dynamics of risky asset prices should
be modeled as stochastic systems driven by noisy distur-
bances.
Such a setup often requires the use of a lter to es-
timate the state of the stochastic dynamic system of asset
prices. One optimal state space based estimation tool that
is widely used in statistics and engineering is the Kalman
lter. This lter is known to be able to support estimations
for past, present, and future states even when the precise
nature of the modeled systems is unknown. We can utilize
the Kalman lter, if a state space based approach is taken
to model the dynamics of risky asset prices.
In this paper, we introduce a state space based model
where the Kalman lter can be used in nance: the Cap-
ital Asset Pricing Model (CAPM) with time-varying coef-
cients as introduced in [6]. With a Kalman lter based
model of asset prices, we formulate the portfolio optimiza-
tion problem in a framework that allows for its solution via
stochastic receding horizon control [4]. This is a portfo-
lio optimization approach that can incorporate constraints
by repeatedly solving nite horizon optimization problems
as semi-denite programs. Kalman ltering together with
receding horizon control provides a complete state space
approach to the problem of asset modeling and portfolio
optimization.
The remainder of this paper is organized as follows.
Section 2 is devoted to the portfolio optimization problem
setup based on the CAPM with time-varying coefcients.
Section 3 presents our model framework which combines
the Kalman lter and the stochastic receding horizon con-
trol model. In Section 4, we perform numerical analysis by
solving a portfolio optimization problem. Finally, Section
5 concludes and offers directions for future work.
2 Problem Description
In this section, we set up an economically reasonable model
of asset prices and the corresponding wealth process that
are analytically and statistically tractable using the Kalman
lter. We then dene the portfolio optimization problem to
solve.
2.1 System Dynamics
Most of the standard time series models can be written in
the state space forms, and such state space models form a
exible class of stochastic processes. The main model to
be studied in this paper is the Capital Asset Pricing Model
(CAPM) with time-varying coefcients as the following
system of equations:
r
M
(k) =
M
+e
M
(1)
r
i
(k) =
i
(k) +
i
(k)r
M
(k) +e
i
(2)

i
(k + 1) =
i
(k) +
i
(3)

i
(k + 1) =
i
(k) +
i
(4)
where r
i
(k) is the excess return
1
of asset i between time k
and k +1. r
M
(k) is the excess return of market index port-
folio M at time k. To model the randomness in the system,
we assume the following independent noise structure:
e
M
N
_
0,
2
M
_
(5)
e
i
N
_
0,
2
ei
_
(6)

i
N
_
0,
2
i
_
(7)

i
N
_
0,
2
i
_
(8)
for i = 1, 2, . . . , n.
This is a promising model not only because it suc-
cessfully demonstrates the ltering techniques needed to
estimate models with variable parameters, but because the
CAPM is a well known and widely accepted model in -
nance and there is an abundance of data to experiment on.
Note that beta, the regression coefcient, used to be as-
sumed to be constant in the classic CAPM, but the evidence
based on numerous empirical studies has pointed to models
with time-varying rather than constant coefcients.
2
Sim-
ilarly, alpha, the regression intercept in the CAPM, may
also be modeled as a time-varying coefcient.
Having the capital asset pricing model (CAPM) with
time-varying intercept and slope, we assume the follow-
ing model of asset prices and self-nancing wealth process
W
u
(k):
S
i
(k + 1) = (1 +r
i
(k) +r
f
)S
i
(k) (9)
W
u
(k + 1) = (1 +r
f
)W
u
(k) +
n

i=1
r
i
(k)u
i
(k)
(10)
where u
i
(k) denotes the dollar amount invested in S
i
(k).
We assume that risk free rate r
f
is constant.
2.2 Problem Objective
Our objective is to maximize the expected value of the in-
nite sum of each W
u
(k), the wealth controlled by u(k),
in innite horizon. Additionally, we add some probabilis-
tic constraints to state or control variables. Hereupon, we
consider the following portfolio optimization problem:
max
u()
E
_

k=0
W
u
(k)
_
(11)
s.t. Value-at-Risk constraint
where W
u
(k) is the wealth dynamics as discrete time lin-
ear systems subject to state and control multiplicative noise
given by (10).
1
Excess returns are asset returns in excess of the risk-free rate. Excess
returns are negative in those periods in which returns are less than the
risk-free rate.
2
See [8] from Chapter 1 to Chapter 3.
3 Model Framework
Our goal in this paper is to select the optimal control actions
u(k) for k = 1, 2, . . . to solve innite horizon stochastic
control problem (11). To determine the optimal decisions,
we use the stochastic receding horizon control methodol-
ogy. For this purpose, we develop a Kalman lter based
model of the proper form to apply the stochastic receding
horizon control method directly.
3.1 Kalman Filter Based Model for Asset Prices
Kalman ltering addresses the general problem of trying
to estimate the state x R
n
of a discrete-time controlled
process that is governed by a linear stochastic difference
equation
x(k) = Ax(k 1) +Bu(k 1) +w(k 1) (12)
with a measurement z R
m
that is
z(k) = Hx(k) +v(k) (13)
where the random variables w(k) and v(k) represent the
process and measurement noise respectively. They are as-
sumed to be independent of each other, white, and with
normal distributions
w() N(0, Q) (14)
v() N(0, R) (15)
where Qis the process noise covariance matrix and Ris the
measurement noise covariance matrix. Of course, Q and R
might change with each time step or measurement.
We dene our state variables x
i
(k) R
2
as the time-
varying coefcients
x
i
(k) =
_

i
(k)

i
(k)
_
(16)
at each time k. These state space based variables can be es-
timated via the Kalman lter. In other words, the Kalman
lter can be implemented to estimate these state variables
which are alpha and beta of each asset return. Here, we
assume that the state variables follow the random walk
model.
From this perspective, the state equation is given as
_

i
(k + 1)

i
(k + 1)
_
=
_
1 0
0 1
_ _

i
(k)

i
(k)
_
+
_

i

i
_
(17)
and the measurement equation is given as
r
i
(k) =
_
1 r
M
(k)

_

i
(k)

i
(k)
_
+e
i
. (18)
In our setting, what we observe at time k are
S
i
(k). It is important to note that we observe S
i
(k) =
(1 +r
i
(k 1)) S
i
(k 1) at each time k, and this implies
that we actually observe r
i
(k 1) at time k. Consequently,
what we obtain from the Kalman lter at time k is
x
i
(k 1 | k) =
_

i
(k 1 | k)

i
(k 1 | k)
_
(19)
with the following parameters:
A =
_
1 0
0 1
_
, B = 0, (20)
H
k
=
_
1 r
M
(k)

, Q =
_

2
i
0
0
2
i
_
, R =
2
ei
.
(21)
where x
i
(k 1 | k) denotes the optimal unbiased estimate
of the coefcients given r(k 1) observed at time k.
This implies that we can estimate the value of
i
(k
1 | k) and

i
(k 1 | k) as ltered state variables at time k.
Thus, our best estimation can be computed as

i
(k) =
i
(k 1) +
i

i
(k 1 | k) +
i
(22)

i
(k) =
i
(k 1) +
i

i
(k 1 | k) +
i
(23)
by the Kalman lter after we observe S
i
(k) at time k.
3.2 Stochastic Receding Horizon Control Model
Consider an optimal control problem of the following form
max
u()
E
_

k=0
f
T
x(k)
_
s.t. x(0) = x
0
x(k + 1) = Ax(k) +Bu(k)
+

q
j=1
[C
j
x(k) +D
j
u(k)] w
j
(k)
P(a
T
x(k) +b
T
u(k) c) 1 d
where x(k) R
n
, u(k) R
m
, and w
j
(k) are iid ran-
dom variables for j = 1, . . . , q with E[w
j
(k)] = 0,
E[w
j
(k)w
l
(k)] = 0 for j = l, and E[w
j
(k)w
j
(k)] = 1.
Receding horizon control is a suboptimal approach to
control problems. In receding horizon control, at each time
step a nite horizon optimal control problem is solved and
the initial optimizing control action is implemented. This
process is repeated at each time step, leading to a feedback
control law. Figure 1 illustrates this approach.
A semi-denite programming formulation of reced-
ing horizon control for this class of problems is given in
[4]. Furthermore, [5] details how this can be used for port-
folio optimization problems. Rather than repeat that mate-
rial here, we refer the reader to [5] for details.
One of our key observations is that the system dynam-
ics of wealth process W
u
(k) dened in Section 2.1 can be
approximated in the form of stochastic RHC model intro-
duced in this section. This approximation is described in
Figure 2.
Note that the last approximation comes from the dis-
tribution of normal product between

i
(k 1 | k) +
i
Figure 1. Picture of Receding Horizon Control
and
M
+ e
M
. As discussed in [1], the product of X
1

N(
1
,
2
1
) and X
2
N(
2
,
2
2
) asymptotically tends to-
ward a normal random variable if
1

2
is small enough.
If the observation interval t is small enough, the
value of
M
becomes close to zero, so we can approxi-
mate this normal product as another normal random vari-
able with corresponding rst and second moments. We can
compute the approximated mean
M

i
(k 1 | k), and
variance

2
i
(k 1 | k)
2
M
+
2
M

2
i
+
2
M

2
i
of the nor-
mal product from its moment generating function. Here we
refer the reader to [1] for details. In addition, this approx-
imated normal random variable is independent of
i
and
e
i
by our construction. Therefore, by the mutual indepen-
dence among noises, the approximation to the stochastic
receding horizon control form of (24) can be justied in
distribution.
4 Numerical Analysis
In this section, we implement the model to test our frame-
work in conjunction with a portfolio optimization problem.
To perform the analysis, we use the empirical data
3
con-
taining the monthly simple excess returns of ten stocks and
the S&P 500 index. The monthly simple excess return of
the S&P 500 composite index is used as the market return
in our analysis. The sample period is from January 1990
to December 2003 for 168 observations. Out of the entire
sample period, we regard the data from January 1990 to
December 2002 as historical data. From January 2003 to
December 2003, we test the model to perform our portfo-
lio optimization based on monthly observations. Figure 3
illustrates the framework of the Kalman lter based Port-
folio optimization problem solving algorithm used in the
following analysis.
4.1 Parameter Estimation Based on Historical Data
Once a model is specied with some parameters and data
have been observed, we can evaluate the goodness of t of
3
One can download the le m-excess-c10sp-9003.txt from the web-
site http://faculty.chicagogsb.edu/ruey.tsay/teaching/fts2/.
W
u
(k + 1) = (1 +r
f
)W
u
(k) +
n

i=1
r
i
(k)u
i
(k)
= (1 +r
f
)W
u
(k) +
n

i=1
_
_
_
ri(k)
..

i
(k) +
i
(k) (
M
+e
M
)
. .
r
M
(k)
+e
i
_
_
_u
i
(k)
(1 +r
f
)W
u
(k) +
n

i=1
_
_
_(
i
(k 1 | k) +
i
. .
i(k)
) + (

i
(k 1 | k) +
i
. .
i(k)
)(
M
+e
M
) +e
i
_
_
_u
i
(k)
= (1 +r
f
)W
u
(k) +
n

i=1

i
(k 1 | k)u
i
(k)
+
n

i=1
_
_
_
_
_

i
+e
i
+ (
N(

i(k1|k),
2

i
)
..

i
(k 1 | k) +
i
) (
N(
M
,
2
M
)
..

M
+e
M
)
. .
N(
M

i(k1|k),

2
i
(k1|k)
2
M
+
2
M

i
+
2
M

i
)
_
_
_
_
_
u
i
(k)
D
= (1 +r
f
)W
u
(k) +
n

i=1
_

i
(k 1 | k) +
M

i
(k 1 | k)
_
u
i
(k)
+
n

i=1
_
_

2
i
+
2
ei
+

2
i
(k 1 | k)
2
M
+
2
M

2
i
+
2
M

2
i
u
i
(k)
_
w
i
(k)
. .
N(0,1)
. (24)
Figure 2. Derivation of the Wealth Dynamics in Stochastic RHC Model Form.
Figure 3. The framework of a recursive Kalman lter based
portfolio optimization problem solving algorithm
the model. Usually, the estimated time-varying parameters
are obtained via the recursive maximum likelihood method.
In this respect, the application of Kalman ltering methods
to the parameter estimation of our model has the great ad-
vantage that it allows the underlying state variables to be
handled as completely unobservable.
We start examining the appropriate log-likelihood
function with our framework using the Kalman lter. Con-
sequently, assuming x(0 | 0) and P(0 | 0) are the initial
values, and taking the logarithms, we have
log[L(y;
i
,
i
,
ei
)]
=
T
2
log(2)
1
2
T

k=1
_
log(V (k)) +
v
2
(k)
V (k)
_
(25)
where
y(k) = r
M
(k 1) (26)
v(k) = y(k) H x(k | k) (27)
N(0, V (k)).
Based on our state space based model described in
Section 2.1, the Kalman lter has the following relation-
1990 1992 1994 1996 1998 2000 2002
0.1
0.05
0
0.05
0.1
PFE
years
F
i
l
t
e
r
e
d

S
t
a
t
e

V
a
l
u
e
s
Filtered (t|t)
1990 1992 1994 1996 1998 2000 2002
0
0.5
1
1.5
2
years
F
i
l
t
e
r
e
d

S
t
a
t
e

V
a
l
u
e
s
Filtered (t|t)
(a) Pzer, Inc.
1990 1992 1994 1996 1998 2000 2002
0.1
0.05
0
0.05
0.1
F
years
F
i
l
t
e
r
e
d

S
t
a
t
e

V
a
l
u
e
s
Filtered (t|t)
1990 1992 1994 1996 1998 2000 2002
0
0.5
1
1.5
2
years
F
i
l
t
e
r
e
d

S
t
a
t
e

V
a
l
u
e
s
Filtered (t|t)
(b) FORD MOTOR COMPANY
1990 1992 1994 1996 1998 2000 2002
0.1
0.05
0
0.05
0.1
GM
years
F
i
l
t
e
r
e
d

S
t
a
t
e

V
a
l
u
e
s
Filtered (t|t)
1990 1992 1994 1996 1998 2000 2002
0
0.5
1
1.5
2
years
F
i
l
t
e
r
e
d

S
t
a
t
e

V
a
l
u
e
s
Filtered (t|t)
(c) General Motors Cooperation
1990 1992 1994 1996 1998 2000 2002
0.1
0.05
0
0.05
0.1
RD
years
F
i
l
t
e
r
e
d

S
t
a
t
e

V
a
l
u
e
s
Filtered (t|t)
1990 1992 1994 1996 1998 2000 2002
0
0.5
1
1.5
2
years
F
i
l
t
e
r
e
d

S
t
a
t
e

V
a
l
u
e
s
Filtered (t|t)
(d) Royal Dutch Petroleum Company
1990 1992 1994 1996 1998 2000 2002
0.1
0.05
0
0.05
0.1
XOM
years
F
i
l
t
e
r
e
d

S
t
a
t
e

V
a
l
u
e
s
Filtered (t|t)
1990 1992 1994 1996 1998 2000 2002
0
0.5
1
1.5
2
years
F
i
l
t
e
r
e
d

S
t
a
t
e

V
a
l
u
e
s
Filtered (t|t)
(e) Exxon Mobil Corporation
1990 1992 1994 1996 1998 2000 2002
0.1
0.05
0
0.05
0.1
SP5
years
F
i
l
t
e
r
e
d

S
t
a
t
e

V
a
l
u
e
s
Filtered (t|t)
1990 1992 1994 1996 1998 2000 2002
0
0.5
1
1.5
2
years
F
i
l
t
e
r
e
d

S
t
a
t
e

V
a
l
u
e
s
Filtered (t|t)
(f) S&P 500 Index
Figure 4. The result of ltering based on the historical data using the Kalman Filter
(a) Estimated parameters for S&P 500.

M

M
0.00303 0.04386
(b) Estimated Parameters for Asset Prices.
Asset
i

i
e
i
i(T)

i(T)
PFE < 10
5
0.06872 0.06499 0.01131 0.65191
F < 10
5
< 10
5
0.08016 0.00271 1.11152
GM < 10
5
< 10
5
0.08235 0.00086 1.02464
RD < 10
5
< 10
5
0.04914 0.00408 0.78501
XOM < 10
5
0.00804 0.03799 0.00511 0.48596
Table 1. Estimated parameters by maximum likelihood es-
timation.
ships:
x(k | k) = x(k 1 | k)

P(k | k) =

P(k 1 | k) +Q
Q =
_

2

0
0
2

_
R =
2
e
H(k) =
_
1 r
M
(k 1)

v(k) = z(k) H x(k | k)
V (k | k) = H(k)

P(k | k)H(k)
T
+R
K(k) =

P(k | k)H(k)
T
_
H(k)PH(k)
T
+R
_
1
x(k | k) = x(k | k) +K(k) (z(k) H(k) x(k | k))

P(k | k) = (I
2
K(k)H(k))

P(k | k)
Applying the maximum log-likelihood method, the
estimated parameters using fmincon() function in MAT-
LAB 7.0.4 are presented in Table 1. We then treat the t-
ted values as the initial values to perform Kalman ltering.
Figure 4 is a graphical illustration of the recursively ltered
state variables for the movements of 5 asset prices (plus the
index) corresponding to the historical data. Note that, as
shown in Table 1, the estimated
i
s are fairly small com-
pared to the values of ltered

i
s. This implies that our
normal product approximation given by (24) can be empir-
ically justied.
4.2 State Estimation from the Kalman Filter
Once we obtain the estimated parameters for the distribu-
tion of state variables, we can apply the Kalman ltering
technique to estimate the state of alpha and beta based on
recursive observations.
Figure 5 describes the recursively ltered state vari-
ables based on monthly observations for one year. Note
that these results are also from the actual empirical data.
2 4 6 8 10 12
0
0.002
0.004
0.006
0.008
0.01
0.012
time
f
i
l
t
e
r
e
d

i (
t
)
PFE
F
GM
RD
XOM
(a) Filtered
i
(k | k)
2 4 6 8 10 12
0.4
0.5
0.6
0.7
0.8
0.9
1
1.1
1.2
1.3
time
f
i
l
t
e
r
e
d

i (
t
)
PFE F GM RD XOM
(b) Filtered

i
(k | k)
Figure 5. Recursively estimated state variables from
Kalman lter based on discrete observations.
4.3 Solving Portfolio Optimization Problems
At each time step, we need to determine the optimal control
strategy u
i
(k) based on the ltered state variables which
come from the past observations. In the following analysis,
we suppose that the initial investment W
u
(0 | 0) = $100,
and the annual risk free rate r
f
= 5%.
In our scenario, the performance of the market turns
out to be decent. If we had not expected the skyrocketing
market performance in advance and failed to catch up to the
market, leaving with a huge gap, our optimization problem
may become unsolvable and the controller would put zero
weight to every risky asset thereafter. This requires us to
impose a clever constraint which comes from our CAPM
assumption. Note that we are observing that every asset has
strictly positive beta from the Kalman lter. This implies
that if the market is expected to do well, we need to be more
aggressive. Instead, if the market is expected to do poorly,
we need to be more conservative. Viewed in this light, we
use the following value-at-risk constraint:
P(W
u
(i | k) (k) I(i | k)) 0.95 (28)
where I( | ) is the market index and (k) = 0.95
W
u
(0|k)
I(0|k)
. This constraint follows from what has been said
that (k) becomes larger when we need to be more aggres-
sive, and (k) becomes smaller when it is better to be more
conservative. Note that this constraint can also be inter-
preted as the following return constraint:
P
_
W
u
(i | k)
W
u
(0 | k)
0.95
I(i | k)
I(0 | k)
_
0.95. (29)
To solve this portfolio optimization problem by the
stochastic receding horizon control (RHC) method, we
used the SeDuMi
4
with the front-end SeDuMi Interface.
Figure 6 presents an optimal control strategy for
our portfolio optimization problem and its corresponding
wealth process with the constraint (29). We can easily no-
tice that the optimally controlled wealth process does even
better than the market under the optimal strategy. However,
there exists a trade-off, of course: we need to short some
amount of risk-free asset to accomplish this strategy.
5 Conclusion
Over the past decades the nancial literature has abounded
with constant coefcient models just to make it easy to an-
alyze the stochastic dynamic system of asset prices. How-
ever, this naive assumption has been criticized by many em-
pirical analysts.
Given the CAPM with time-varying coefcients as
our state space based asset pricing model, we applied
a Kalman lter based state estimation technique to our
model. Anchored to the recursive Kalman ltering mecha-
nism, we performed a numerical analysis on portfolio op-
timization problems using the stochastic receding horizon
control technique. Since we set up a state space based
model for asset prices, the wealth process governed by the
optimally controlled strategy could be obtained based on
discrete observations after the estimated conditional distri-
bution on the control space given the ltered state values
are computed from the Kalman lter.
In future work, we may even relax our assumption
on the constant risk-free rate r
f
by allowing it to be time-
varying as well. For example, if we model the short term
risk free rate dynamics as a state space model, we can es-
timate the state of r
f
at each time step via ltering tech-
nique based on the discrete observations of bond market.
Another possible extension can be made by incorporating
the time-varying CAPMcoefcients into the stochastic sys-
tem dynamics of receding horizon controller. In this case,
4
Self-Dual-Minimization package (SeDuMi) is developed by Jos F.
Sturm for MATLAB users. SeDuMi implements the self-dual embedding
technique for optimization over self-dual homogeneous cones. SeDuMi
is an add-on MATLAB, which makes it possible to solve optimization
problems with linear, quadratic, and semi-deniteness constraints.
2 4 6 8 10 12
10
20
30
40
50
60
70
80
time
O
p
t
i
m
a
l

u
i (
t
)
PFE
F
GM
RD
XOM
(a) Optimal Control Strategy
0 2 4 6 8 10 12
90
100
110
120
130
140
150
160
time
W
e
a
l
t
h
Controlled Wealth
Market Portfolio
Riskfree Portfolio
(b) Controlled Wealth Process
Figure 6. Result of Portfolio Optimization.
the approximation we made becomes more complicated, so
we may need to linearize the equation using the extended
Kalman lter or possibly use a particle lter as a general
approach.
References
[1] Cecil C. Craig, On the Frequency Function of XY,
Ann Math Statist, 1936, 7:1-15.
[2] Andrew C. Harvey, Forecasting, Structural Time Se-
ries Models and the Kalman Filter, (Cambridge Uni-
versity Press, 1989)
[3] Peter S. Maybeck, Stochastic Models, Estimation,
and Control, Volume 1, (Academic Press Inc., 1979)
Chapter 1.
[4] James A. Primbs, Stochastic Receding Horizon Con-
trol of Constrained Linear Systems with State and
Control Multiplicative Noise, To appear in the pro-
ceedings of the 2007 American Control Conference,
2007.
[5] James A. Primbs, Portfolio Optimization Applica-
tions of Stochastic Receding Horizon Control, To ap-
pear in the proceedings of the 2007 American Control
Conference, 2007.
[6] Ruey S. Tsay, Analysis of Financial Time Series, Sec-
ond Edition, (Wiley, 2005)
[7] Welch and Bishop, An Introduction to the Kalman Fil-
ter, (UNC-Chapel Hill, 2006)
[8] Curt Wells, The Kalman Filter in Finance, (Kluwer
Academic Publishers, 1996)

Anda mungkin juga menyukai