A Simplified Approach to Understanding the Kalman Filter Technique

Similar documents
Memorandum on Impulse Winding Tester

P. Bruschi: Project guidelines PSM Project guidelines.

Estimating a Time-Varying Phillips Curve for South Africa

ECE-517 Reinforcement Learning in Artificial Intelligence

(This lesson plan assumes the students are using an air-powered rocket as described in the Materials section.)

Notes on the Fourier Transform

Lecture #7: Discrete-time Signals and Sampling

Role of Kalman Filters in Probabilistic Algorithm

Experiment 6: Transmission Line Pulse Response

A-LEVEL Electronics. ELEC4 Programmable Control Systems Mark scheme June Version: 1.0 Final

Signal Characteristics

Lab 3 Acceleration. What You Need To Know: Physics 211 Lab

Pulse Train Controlled PCCM Buck-Boost Converter Ming Qina, Fangfang Lib

A WIDEBAND RADIO CHANNEL MODEL FOR SIMULATION OF CHAOTIC COMMUNICATION SYSTEMS

EE 330 Lecture 24. Amplification with Transistor Circuits Small Signal Modelling

Errata and Updates for ASM Exam MLC (Fourteenth Edition) Sorted by Page

Comparing image compression predictors using fractal dimension

4.5 Biasing in BJT Amplifier Circuits

Table of Contents. 3.0 SMPS Topologies. For Further Research. 3.1 Basic Components. 3.2 Buck (Step Down) 3.3 Boost (Step Up) 3.4 Inverter (Buck/Boost)

MODELING OF CROSS-REGULATION IN MULTIPLE-OUTPUT FLYBACK CONVERTERS

Using Box-Jenkins Models to Forecast Mobile Cellular Subscription

ECMA-373. Near Field Communication Wired Interface (NFC-WI) 2 nd Edition / June Reference number ECMA-123:2009

EXPERIMENT #9 FIBER OPTIC COMMUNICATIONS LINK

Negative frequency communication

AN303 APPLICATION NOTE

10. The Series Resistor and Inductor Circuit

The student will create simulations of vertical components of circular and harmonic motion on GX.

Pointwise Image Operations

March 13, 2009 CHAPTER 3: PARTIAL DERIVATIVES AND DIFFERENTIATION

THE OSCILLOSCOPE AND NOISE. Objectives:

NCTM Content Standard/National Science Education Standard:

An off-line multiprocessor real-time scheduling algorithm to reduce static energy consumption

MAP-AIDED POSITIONING SYSTEM

5 Spatial Relations on Lines

Estimation of Automotive Target Trajectories by Kalman Filtering

Square Waves, Sinusoids and Gaussian White Noise: A Matching Pursuit Conundrum? Don Percival

ECMA st Edition / June Near Field Communication Wired Interface (NFC-WI)

The Relationship Between Creation and Innovation

A Segmentation Method for Uneven Illumination Particle Images

Teacher Supplement to Operation Comics, Issue #5

f t 2cos 2 Modulator Figure 21: DSB-SC modulation.

Modeling and Prediction of the Wireless Vector Channel Encountered by Smart Antenna Systems

Lecture September 6, 2011

Auto-Tuning of PID Controllers via Extremum Seeking

ACTIVITY BASED COSTING FOR MARITIME ENTERPRISES

Communications II Lecture 7: Performance of digital modulation

Chapter 2 Introduction: From Phase-Locked Loop to Costas Loop

Mobile Robot Localization Using Fusion of Object Recognition and Range Information

TRIPLE-FREQUENCY IONOSPHERE-FREE PHASE COMBINATIONS FOR AMBIGUITY RESOLUTION

The University of Melbourne Department of Mathematics and Statistics School Mathematics Competition, 2013 JUNIOR DIVISION Time allowed: Two hours

Explanation of Maximum Ratings and Characteristics for Thyristors

Revision: June 11, E Main Suite D Pullman, WA (509) Voice and Fax

PRM and VTM Parallel Array Operation

Lecture 4. EITN Chapter 12, 13 Modulation and diversity. Antenna noise is usually given as a noise temperature!

16.5 ADDITIONAL EXAMPLES

4 20mA Interface-IC AM462 for industrial µ-processor applications

Motion-blurred star image acquisition and restoration method based on the separable kernel Honglin Yuana, Fan Lib and Tao Yuc

Variation Aware Cross-Talk Aggressor Alignment by Mixed Integer Linear Programming

Control and Protection Strategies for Matrix Converters. Control and Protection Strategies for Matrix Converters

UPDATE FOR DESIGN OF STRUCTURAL STEEL HOLLOW SECTION CONNECTIONS VOLUME 1 DESIGN MODELS, First edition 1996 A.A. SYAM AND B.G.

Investigation and Simulation Model Results of High Density Wireless Power Harvesting and Transfer Method

Direct Analysis of Wave Digital Network of Microstrip Structure with Step Discontinuities

The design of an improved matched filter in DSSS-GMSK system

EE 40 Final Project Basic Circuit

BOUNCER CIRCUIT FOR A 120 MW/370 KV SOLID STATE MODULATOR

Day-of-the-week effects in selected East Asian stock markets

Accurate Tunable-Gain 1/x Circuit Using Capacitor Charging Scheme

EE201 Circuit Theory I Fall

How to Shorten First Order Unit Testing Time. Piotr Mróz 1

GaN-HEMT Dynamic ON-state Resistance characterisation and Modelling

Increasing Measurement Accuracy via Corrective Filtering in Digital Signal Processing

= f 8 f 2 L C. i C. 8 f C. Q1 open Q2 close (1+D)T DT 2. i C = i L. Figure 2: Typical Waveforms of a Step-Down Converter.

On the disappearance of Tuesday effect in Australia

Development of Temporary Ground Wire Detection Device

DAGSTUHL SEMINAR EPIDEMIC ALGORITHMS AND PROCESSES: FROM THEORY TO APPLICATIONS

Social-aware Dynamic Router Node Placement in Wireless Mesh Networks

Pattern compensation in SOA-based gates. Article (peer-reviewed)

Evaluation of Instantaneous Reliability Measures for a Gradual Deteriorating System

Universal microprocessor-based ON/OFF and P programmable controller MS8122A MS8122B

Answer Key for Week 3 Homework = 100 = 140 = 138

Digital Communications - Overview

SLAM Algorithm for 2D Object Trajectory Tracking based on RFID Passive Tags

2600 Capitol Avenue Suite 200 Sacramento, CA phone fax

Driver Modeling and Alignment for Worst-Case Delay Noise

Active Filters - 1. Active Filters - 2

A Hybrid Method to Improve Forecasting Accuracy in the Case of Sanitary Materials Data

A New Voltage Sag and Swell Compensator Switched by Hysteresis Voltage Control Method

LECTURE 1 CMOS PHASE LOCKED LOOPS

Deblurring Images via Partial Differential Equations

Volume Author/Editor: Simon Kuznets, assisted by Elizabeth Jenks. Volume URL:

MATLAB/SIMULINK TECHNOLOGY OF THE SYGNAL MODULATION

MEASUREMENTS OF VARYING VOLTAGES

Fuzzy Inference Model for Learning from Experiences and Its Application to Robot Navigation

HIGH THROUGHPUT EVALUATION OF SHA-1 IMPLEMENTATION USING UNFOLDING TRANSFORMATION

PREVENTIVE MAINTENANCE WITH IMPERFECT REPAIRS OF VEHICLES

Transmit Beamforming with Reduced Feedback Information in OFDM Based Wireless Systems

Undamped, Length Varying TLP Pulses Measurements and ESD Model Approximations

Lecture 11. Digital Transmission Fundamentals

Chapter 2 Summary: Continuous-Wave Modulation. Belkacem Derras

Double Tangent Sampling Method for Sinusoidal Pulse Width Modulation

Transcription:

Universiy of Richmond UR Scholarship Reposiory Finance Faculy Publicaions Finance 008 A Simplified Approach o Undersanding he Kalman Filer Technique Tom Arnold Universiy of Richmond, arnold@richmond.edu Mark J. Berus Jonahan Godbey Follow his and addiional works a: hp://scholarship.richmond.edu/finance-faculy-publicaions Par of he Corporae Finance Commons, and he Finance and Financial Managemen Commons Recommended Ciaion Arnold, Tom; Berus, Mark J.; and Godbey, Jonahan, "A Simplified Approach o Undersanding he Kalman Filer Technique" (008). Finance Faculy Publicaions. 8. hp://scholarship.richmond.edu/finance-faculy-publicaions/8 This Aricle is brough o you for free and open access by he Finance a UR Scholarship Reposiory. I has been acceped for inclusion in Finance Faculy Publicaions by an auhorized adminisraor of UR Scholarship Reposiory. For more informaion, please conac scholarshipreposiory@richmond.edu.

A Simplified Approach o Undersanding he Kalman Filer Technique Tom Arnold (Conac Auhor) The Robins School of Business Deparmen of Finance Universiy of Richmond Richmond, VA 373 O: 804-87-6399 F: 804-89-8878 arnold@richmond.edu Mark Berus Deparmen of Finance Lowder Business Building 45 Wes Magnolia Avenue, Suie 303 Auburn Universiy, AL 36849 O: 334-844-3004 F: 334-844-4960 berumj@auburn.edu and Jonahan Godbey Deparmen of Finance MSC 003 James Madison Universiy Harrisonburg, VA 807 O: 540-568-3074 F: 540-568-307 godbeyjm@jmu.edu Key Words: Kalman Filer, Time Series, Excel, Educaion, Fuures, Mone Carlo JEL: A, A3, C, G3 December, 007 Preliminary, do no cie wihou permission The auhors wish o hank Joseph Harman, Jimmy Hilliard, Karl Horak, Marcos M. Lopez de Prado, Jerry Sevens, wo anonymous referees, sudens a James Madison Universiy and he College of Sana Fe, and members of he Social Science Research Nework for helpful conversaions and commens.

A Simplified Approach o Undersanding he Kalman Filer Technique The Kalman Filer is a ime series esimaion algorihm ha is applied exensively in he field of engineering and recenly (relaive o engineering) in he field of finance and economics. However, presenaions of he echnique are somewha inimidaing despie he relaive ease of generaing he algorihm. This paper presens he Kalman Filer in a simplified manner and produces an example of an applicaion of he algorihm in Excel. This scaled down version of he Kalman filer can be inroduced in he (advanced) undergraduae classroom as well as he graduae classroom.

INTRODUCTION: Many models in economics and finance depend on daa ha are no observable. These unobserved daa are usually in a conex in which i is desirable for a model o predic fuure evens. The Kalman Filer has been used o esimae an unobservable source of jumps in sock reurns, unobservable noise in equiy index levels, unobservable parameers and sae variables in commodiy fuures prices, unobservable inflaion expecaions, unobservable sock beas, and unobservable hedge raios across ineres rae conracs. In he field of engineering a Kalman Filer (Kalman, 960) is employed for similar problems involving physical phenomena. The echnique is appearing more frequenly in he fields of finance and economics. However, undersanding he echnique can be very difficul given he available resource maerial. When viewing chaper hireen of Hamilon s Times Series Analysis ex (994), one can undersand why he opic of Kalman Filers is generally reserved for he graduae classroom. However, as we will demonsrae, he echnique is no quie as difficul as one may perceive iniially and has similariies o sandard linear regression analysis. Consequenly, if placed in he correc conex, i is accessible o he undergraduae suden. In order o make he Kalman Filer more accessible, an Excel applicaion is developed in his paper o work he suden hrough he mechanics of he process. In he firs secion, a derivaion of he Kalman Filer algorihm is presened in a univariae conex and a connecion is made beween he algorihm and linear regression. In he second secion, he Kalman Filer is combined wih Maximum Likelihood Esimaion (MLE) o creae an ieraive process for parameer esimaion. In he hird See Berus, Beyer, Godbey and Hinkelmann (006), Berus, Denny, Godbey and Hinkelmann (006), Burmeiser and Wall (98), Burmeiser, Wall, and Hamilon (986), Faff, Hillier, and Hillier (000), Fink, Fink, and Lange (005), Godbey and Hilliard (forhcoming), and Schwarz (997).

secion, an Excel applicaion/example of using he Kalman Filer/MLE ieraive rouine is performed. SECTION : DEVELOPING THE KALMAN FILTER ALGORITHM There are wo basic building blocks of a Kalman Filer, he measuremen equaion and he ransiion equaion. The measuremen equaion relaes an unobserved variable (X ) o an observable variable (Y ). In general, he measuremen equaion is of he form: Y = m * X + b + ε () To simplify he exposiion, assume he consan b is zero and m remains consan hrough ime eliminaing he need for a subscrip. Furher, ε has a mean of zero and a variance of r. Equaion () becomes: Y = m * + ε () X The ransiion equaion is based on a model ha allows he unobserved variable o change hrough ime. In general, he ransiion equaion is of he form: X + = a * X + g + θ (3) Again, o simplify he exposiion, assume he consan g is zero and a remains consan hrough ime eliminaing he need for a subscrip. Furher, θ has a mean of zero and a variance of q. Equaion (3) becomes: X + = a * X + θ (4) To begin deriving he Kalman Filer algorihm, inser an iniial value, X 0 ino equaion (4) (he ransiion equaion) for X. X 0 has a mean of μ 0 and a sandard deviaion of σ 0. I should be noed: ε, θ, and X 0 are uncorrelaed (Noe: hese variables are also uncorrelaed relaive o lagged variables). Equaion (4) becomes: X P (5) = a * X 0 + θ 0 3

where, X P is he prediced value for X X P is insered ino equaion () (he measuremen equaion) o ge a prediced value for Y, call i Y P : [ a 0 + θ 0 ] Y P = m * X P + ε = m * * X + ε (6) When Y acually occurs, he error, Y E, is compued by subracing Y P from Y : Y E Y Y P = (7) The error can now be incorporaed ino he predicion for X. To disinguish he adjused prediced value of X from he prediced value of X in equaion (5), he adjused prediced value is called X P-ADJ : X P ADJ = X = X = X P P P = X P + k Y E + k[ Y Y P ] + k[ Y m X P ε] [ m k] + k Y k ε (8) where k is he Kalman gain, which will be deermined shorly The Kalman gain variable is deermined by aking he parial derivaive of he variance of X P-ADJ relaive o k in order o minimize he variance based on k (i.e. he parial derivaive is se o zero and hen one finds a soluion for k ). For ease of exposiion, le p be he variance of X P (echnically, p equals: ( a 0 ) + q0 σ ). The soluion for he Kalman gain is as follows (see Joseph (007) for a numerical example): Var ( X P ADJ ) = p [ m k] + k r (9) Var ( X ) k P ADJ = [ m k ] p + * k r = 0 m (0) 4

( p m + r ) ( X P, Y P ) ( Y ) p m Cov k = = () Var Noice, he Kalman gain is equivalen o a β-coefficien from a linear regression wih X P as he dependen variable and Y P as he independen variable. No ha one would have a sufficien se of daa o perform such a regression, bu he idea ha a β- coefficien is se o reduce error in a regression is equivalen o he idea of he Kalman gain being se o reduce variance in he adjused prediced value for X. The nex sep is o use X P-ADJ in he ransiion equaion (equaion (4)) for X and sar he process over again o find equivalen values when =. However, before ending his secion, i is imporan o noe he advanages of X P-ADJ over X P. Recall, he variance for X P is p. Subsiuing equaion () ino equaion (9), he variance of X P-ADJ is: Var P ( X P ADJ ) = p + k r () r + p m The porion of he equaion ha perains o he variance of X P, i.e. p, has a brackeed erm ha is less han one (and is furher reduced because he less han one quaniy is squared). This means he porion of he variance aribued o esimaing X has been reduced by using X P-ADJ insead of X P. For reference, he Kalman Filer algorihm is summarized in he able below: (INSERT TABLE HERE) 5

In he nex secion, i will be necessary o use he mean and variance of X P-ADJ and of Y P. Alhough, some of hese quaniies have already been calculaed, all are presened below for reference purposes wih he ime index variable incorporaed ( = o T) and he adjused prediced values for X incorporaed ino Y P : E [ X ] = E[ X + k Y ] = E[ X ] + k ( Y E[ Y ]) Var E P ADJ P E P * (3) [ X P ADJ ] p = + k r (4) r + p m [ Y ] E[ m ( X ) + ] = m E[ X ] P = ε (5) P ADJ P ADJ P [ YP ] = Var[ X P ADJ ] m r Var + (6) Noe: ε echnically appears wihin equaion (3) wihin he Y E erm and wihin equaion (5), however, hese error erms are independen of each oher. In oher words, equaion (5) and (6) refer o an updaed or adjused version of he Y P erm in equaions (3) and (4). Consequenly, he error erms corresponding o Y P wihin he wo ses of equaions are uncorrelaed. In he classroom seing, i is imporan o keep he applicaion in a univariae seing iniially o allow he suden o follow he logic of he filer. Furher, i is suggesed ha he insrucor reinforce he logic of he algorihm using Table in conjuncion wih an assignmen (such as he assignmen developed in secion hree of his paper) or a quiz. Because his presenaion is no relian on many expecaion calculaions and only one variance calculaion, i is a more palaable inroducion of he Kalman Filer han wha many exs presen. Consequenly, his presenaion works bes as an inroducion o he echnique which can evenually lead o he more sophisicaed presenaions available in many ime series exs. If he insrucor only requires an 6

inroducion o he Kalman Filer echnique wih he abiliy o creae an assignmen hen his presenaion of he algorihm will be sufficien wihou a ex. SECTION : APPLYING MAXIMUM LIKELIHOOD ESTIMATION TO THE KALMAN FILTER The Kalman Filer provides oupu hroughou he ime series in he form of esimaed values for an unobservable variable: X P-ADJ wih a mean and a variance defined in equaions (3) and (4). Furher, he observable variable has a ime series of values and a disribuion based on is prediced value, Y P, which has a mean and variance defined by equaions (5) and (6). Wha he Kalman Filer canno deermine are unknown model parameers in he measuremen equaion, ε, in equaion () (noe: m is a consan and assumed known) and unknown parameers in he ransiion equaion, a and θ, in equaion (4). Consequenly, i is necessary o have a means of esimaing hese parameers and when esimaed, allow he Kalman Filer o generae he ime series of he unobservable variable ha is desired. If we assume ha he disribuion for each Y P is serially independen and normally disribued wih a mean and variance as defined by equaions (5) and (6); noe: he mean and variance boh incorporae he mean and variance of he unobservable variable X P-ADJ, a join likelihood funcion emerges: = T = π Var [ Y ] P T e T = ( Y E[ Y ]) Var P [ Y ] P (7) 7

The idea behind he likelihood funcion is ha he observable daa emerges from his joinly normal disribuion. Consequenly, he parameers o be esimaed wihin he disribuion are chosen in a manner ha maximizes he value of he likelihood funcion (i.e. provides he highes probabiliy ha he observed daa acually occur). To simplify calculaions using he likelihood funcion, i is common o use he naural logarihm of he likelihood funcion (i.e. he log-likelihood funcion): ( ) T * ln π T ln [ Var[ Y ] P = = T ( Y E[ YP ]) Var[ Y ] P (8) As menioned previously, he parameers of ineres are ε, a, and θ which may be consans or defined by a disribuion (he parameers of he disribuion ha generaes he variable hen become he parameers of ineres insead of he variable). Furher simplifying assumpions may be employed, for example, he variance of ε and θ will be consan hrough ime (i.e. q = q and r = r ). The parial derivaive of he log-likelihood funcion wih respec o each parameer is calculaed and se o zero in order o maximize he log-likelihood funcion. Afer a se of parameers is esimaed (hese are called maximum likelihood esimaes or MLEs), he Kalman Filer algorihm is applied again which will produce new ime series of Y P and X P-ADJ wih associaed disribuions. The likelihood esimaion is hen performed again producing new MLEs which will again ener ino he Kalman Filer. This ieraive process will coninue unil he value of equaion (8) does no improve by a significan amoun (say 0.000). In his conex, equaion (8) is ofen referred o as he score. The use of maximum likelihood esimaion in conjuncion wih he Kalman Filer in an ieraive fashion is referred o as he Expecaion Maximizaion (EM) algorihm (see Brockwell and Davis (00)). 8

Noice, he EM algorihm is criical in he final esimaion of he unobserved daa, however, i is no essenial o undersanding he Kalman Filer process. Consequenly, one can choose o rea he EM algorihm in a cursory fashion depending on he level of he class. In he nex secion, he Kalman Filer wih he EM algorihm are applied ogeher in Excel. The applicaion allows he suden o work hrough he Kalman Filer process, define he MLE equaion, and hen execue he enire sysem using Excel s Solver funcion. The Solver funcion performs he EM algorihm wih minimal inpu from he suden. SECTION 3: A NUMERICAL EXAMPLE IN EXCEL The remaining porion of his presenaion is a simple example of he EM algorihm. This example presens an ieraive compuaion of he Kalman Filer and he maximum likelihood esimaion when he observaions can be viewed as incomplee daa. In paricular, o illusrae he usefulness of he Kalman filer, we analyze is applicaion in a pricing model framework for a commodiy spo and fuures marke. 3. Descripion of he Example Consider an agen who paricipaes in he oil marke. This marke paricipan may buy and sell oil in wo differen markes; he spo marke and he fuures marke. When buying (selling) oil in he spo marke, he rader is looking o ake (lose) immediae possession of oil. Alernaively, if he agen does no have an immediae need for oil, bu does a someime in he fuure, he rader may arrange oday o ake ownership of oil a he laer dae by purchasing a fuures conrac oday. The value of his fuures conrac oday of course will hen depend on he curren spo price of oil, he ime period of he 9

agreemen and some ime value of money facor (we simplify he ime value of money facor o only incorporae he risk-free rae). Tha is, he relaionship beween he spo price (S ) and fuures price (F ) is given by F ( rτ ) = S exp. (9) where, r is he annual risk-free rae and τ is he ime o mauriy of he conrac measured in years Equaion (9) has an imporan pracical funcion for he crude oil marke. Spo marke crude oil does no have a single organized rading floor and herefore does no have an observable spo price. Crude oil fuures, however, do acively rade on an organized exchange and are observable. Given he relaionship beween he spo price and he fuures price in equaion (9), raders can use he Kalman Filer o accuraely infer spo price levels of crude oil. To esimae hese unobserved spo prices we need he pricing relaion from equaion (9) and he underlying dynamics of he spo prices. For simpliciy, assume he spo price follows geomeric Brownian moion: ds = μ S0d + σs 0dZ (0) [ 0 d] dz ~ N, () where, d is an infiniesimally small sep forward in ime Because dz is disribued normally wih a zero mean and a variance of d, ds also follows a normal disribuion: [ S d ( S ) d] ds ~ N μ σ () 0, Alhough correc in is presen form, i is much easier o uilize a linear form of he relaionship by aking he naural logarihm of boh sides of equaion (9) and adding 0 0

an error erm ( ε is an error erm wih E[ ε ] = 0 and Var [ ε ] = q measuremen equaion for he Kalman Filer ( F ) = ln( S ) + rτ + ε ). We now have he ln (3) For noaional ease le X ln( S ) and Y ln( F ) where indicaes a poin in ime. The measuremen equaion is similar o equaion () wih Y equal o ln(f ), X equal o ln(s ), b equal o rτ, and a similarly defined error erm. By Io s lemma (if dx = a*d + b*dz and Q = f(x), hen dq = [a*q X + 0.5*b *Q XX + Q ]*d + b*q X *dz, subscrips indicae parial derivaives; see Arnold and Henry (003) for a more expansive explanaion of Io s lemma in he conex of asse prices): dx = ( μ.5σ ) d + σdz 0 (4) Equaion (4) implies ha S S exp ( 0. σ ) = 0 μ 5 τ + σ where τ = 0. By 0 dz aking equaion (4) and changing d o discree ime, Δ, he ransiion equaion for he Kalman Filer is defined. X ( μ 0.5* σ ) Δ + = X + * θ (5) where E[ θ ] = 0 and Var[ θ ] = σ Δ μ 0.5* σ. This is similar o equaion (3) wih a equal o one and g equal o ( )* Δ To perform he Kalman Filer algorihm, we only need iniial values for X 0, μ, and σ wihin he ransiion equaion along wih a ime series of he observable fuures prices. 3. Mone Carlo Simulaion

To illusrae he esimaion abiliy of he Kalman filer, we conduc a Mone Carlo experimen. To begin, we will produce a spo price ime series for crude oil using a random number generaor, and parameer values for equaion (5). Nex, hese spo prices will be used in equaion (9), along wih parameer values for he risk free rae and he ime o mauriy, o consruc a ime series of fuures prices. Once hese fuures prices are obained, we will use only hese fuures prices along wih equaions (9) and (5) o esimae he simulaed spo prices using he Kalman filer. Lasly, we will compare he Kalman esimaed spo prices wih he simulaed spo prices o show how accurae he Kalman filer esimaes he unobservable (or laen) variable. To produce a numerical example in Excel, begin he wih an iniial spo price of $50.00. The price moves forward in ime by he process: S {( μ 0. σ ) Δ + ΔZ } = S exp σ. (6) 5 To generae a random number for S in Excel, use he following command: =NORMINV(RAND(), (µ-0.5*σ^)*δ, σ*sqrt(δ)) wih applicable values for µ, σ, and Δ. Once hese values are obained, subsiue hese values ino equaion (6) o produce a ime series for he spo price, S. Afer generaing his series of prices, we may obain he fuures prices by muliplying each spo price by (e (r*τ) ). Figure illusraes he seps described above wih µ = 0% annually, σ = 5% annually, Δ = /5, r = 4% annually, and τ =. (INSERT FIGURE HERE) To se up he Kalman Filer, i is necessary o undersand wha is acually known: ln(f 0 ) = 3.950, F 0 = $5.04, r = 4%, Δ = 0.093, and τ =. Take he expecaion of

he measuremen equaion, E[ln(F = 0 )] = E[ln(S = 0 )] + r*τ, and solve for E[ln(S = 0 )] based on he known parameers (i.e. E[ln(S 0 )] = 3.950 4%* = 3.90). The variance of ln(s 0 ) is assumed o be zero. I is helpful o rewrie he measuremen and ransiion equaions wih known values o deermine wha parameers sill need o be esimaed. ln ( F ) = ln( S ) + 4% *. 00 + ε where E[ ε ] = 0 and Var [ ] = q Consequenly, q, needs o be esimaed in he measuremen equaion. ε (7) ln Var ( S ) = ln( S ) + ( μ 0.5* σ )*0. 093 + [ θ ] = σ *0. 093 θ where E[ θ ] = 0 and (8) Consequenly, µ and σ need o be esimaed in he ransiion equaion. The selecion of iniial values for hese parameers o be esimaed can be performed somewha sraegically depending on one s knowledge of he sysem. In heory, he values can be any se of numbers consisen wih he numerical aribues of he parameers (e.g. variance parameers should no be negaive). However, an exensive discussion of his issue is no presened here, bu is cerainly a worhy opic of discussion in he classroom. To perform he Excel example, he iniial parameer esimaes are µ = 5%, σ = 3%, and q = 0%. Figure exends he spreadshee in Figure o demonsrae he Kalman Filer applicaion. (INSERT FIGURE HERE) 3

Wih he Kalman Filer enered, he EM Algorihm for he maximum likelihood esimaion requires wo addiion columns o calculae he equivalen of equaion (8) (cell M of Figure 3). Figure 3 illusraes he calculaions assuming 00 observaions. (INSERT FIGURE 3 HERE) Nex, he Solver funcion is implemened o maximize he log-likelihood funcion. The Solver funcion is a selecion wihin he Excel Tools menu. Should Solver no be available, i can be loaded by selecing Solver under he Add-In menu which is wihin he Tools menu (Noe: when loading Solver, he original Excel compac disk will be requesed). Wihin he Solver applicaion, he goal is o maximize he log-likelihood funcion (cell M) by adjusing he unknown parameers (cells G, G5, and G6) while mainaining he consrain ha any variance parameers remain posiive (cells G and G6). By implemening Solver wih he above condiions, Excel will ierae beween he Kalman Filer soluions and he maximizaion of he log-likelihood funcion (he EM Algorihm). The soluions for he paricular se of daa generaed for his paper are µ = 8.9835%, σ = 4.354%, and q = 0.000% wih a log-likelihood funcion value of 97.84. The parameer values are close o he acual parameer values used o generae he daa: µ = 0.00%, σ = 5.00%, and q = 0.00%. One should be aware ha differen ses of randomly generaed daa produce differen soluions. The soluions can vary grealy and many imes depend on how well he random number generaor performs a a given ime (his senimen has been echoed by ohers who have used his example in a classroom seing). 4

Consequenly, i is advisable for he insrucor o es he randomly generaed daa prior o giving i o he suden. Because his is an exercise for he suden o undersand he Kalman Filer and no an exercise abou daa or modeling issues, i is bes for he suden s esimaed daase of he unobserved variable (Column F) o mach up well wih he echnically unobserved daase (Column D). There are wo advanages o his: ) he suden can now judge via a benchmark how well heir esimaion of he unobserved ime series performs (Column D can be made available o he suden prior o or afer he esimaion of he Kalman Filer depending on he insrucor s objecives) and ) he suden gains confidence in execuing he echnique and gains confidence in he echnique iself assuming a correc model. In realiy, one never acually compares he esimaed unobserved daa wih acual unobserved daa. However, because he conrolled environmen developed here allows such a comparison, he insrucor should ake advanage of i. The exercise illusraed in Figures hrough 3 is available from he auhors upon reques. The Kalman Filer series in his exercise mached he acual generaed series so well, ha a graph comparing he wo series is no very meaningful for he purposes of his paper as he wo series simply overlay on op of each oher. However, when used in he classroom, sudens find a graph illusraing he near perfec overlay of prediced daa over acual (echnically unobserved) daa very compelling. The mean error beween he wo price series is $0.00005 wih a sandard deviaion of $0.0034. Furher, he observable daa, he fuures prices, when compared o he Kalman Filer prediced fuures price have an average error of -$0.0086 wih a sandard deviaion of $.990. 5

Alhough he opic of his paper is o only presen he Kalman Filer echnique, i is necessary o menion how he Kalman Filer is acually applied empirically. The Kalman Filer provides a esing environmen for differen model specificaions for he unobserved variables o be compared. Some of he issues ha emerge include: esing wheher model parameers remain consan hroughou he ime series if he parameers do change hroughou he ime series, in wha manner do he parameers change does he model acually do an adequae job a forecasing do paricular ime series elemens emerge, such as, auocorrelaion Ulimaely, he bes (and hopefully correc) model fis he observable daa wih he leas amoun of error. The exercise presened in his paper can be as simple or complex as he insrucor desires. Alhough considered a ime series echnique which places he exercise in he realm of economerics, he exercise is suiable for a course devoed o esimaing asse pricing models in finance or simply as an exercise in an Excel modeling course. CONCLUSION: The exising presenaions of he Kalman Filer echnique are dauning despie he relaive ease in which he filer is implemened. Par of he problem is he marix noaion (avoided in his presenaion), bu equally o blame, is ha mos of he scaled down examples are applied in engineering and no in erms of economic/financial analysis. By providing an accessible example in Excel, he Kalman Filer becomes a powerful analyical ool. 6

The example in his paper has been presened successfully as a sand alone assignmen in which he sudens follow he paper and produce heir own Mone Carlo simulaion o be esimaed wih a Kalman Filer. The example in his paper has also been used in conjuncion wih oher maerial o simply illusrae he Kalman Filer echnique. Echoing some of he feedback received regarding his paper, o implemen as a lecure, i is suggesed ha he insrucor generae he Mone Carlo simulaion prior o he lecure. I is imporan, paricularly for a suden s iniial inroducion o his maerial, ha he echnique perform well and no be subjec o problems wih he randomly generaed se of daa. A comparison beween he filer generaed unobservable variables and he acual unobservable variables is insrucive, bu can be omied a he insrucor s discreion. Alhough his paper has been successfully assigned as a sand-alone assignmen, when giving an assignmen, we sugges providing he suden wih only he observable generaed daa (afer i has been pre-esed o make cerain he generaed daa leads o appropriae soluions). If desired, muliple ses of he generaed daa wih differen parameer figures can be creaed o make individual assignmens. As par of he soluions o he assignmen, he insrucor can make he acual unobservable daa available o he suden o see how well he filer performed. The programming for he filer is minimal, however, he abiliy o grasp he idea of a laen variable is he ruly novel par of he classroom presenaion. Consequenly, his maerial is bes suied for advanced undergraduae (economeric or financial modeling) classes because of he inroducion of a laen variable. Alernaively, he maerial can simply be used as an Excel programming assignmen by allowing he 7

suden o program he filer in an effor o esimae he unobservable daa (which he insrucor can provide in his insance) hrough he observable daa. The exercise allows he suden o program he filer and provides a suiable conex for using Excel s Solver funcion. A he graduae level (drawing from feedback received from graduae sudens who downloaded earlier versions of he paper), he maerial is suiable for a course on ime series analysis or advanced financial modeling. In fac, he paper can be assigned as background reading in a docoral course for undersanding he Kalman Filer prior o reading empirical research based on he Kalman Filer. In his conex, he paper is no very exensive because i does no address many of he economeric issues associaed wih ime series analysis. Ye, i is sill a useful resource paricularly for sudens who are unfamiliar wih he opic. 8

REFERENCES: Arnold, T. and S. Henry. (003) Visualizing he sochasic calculus of opion pricing wih Excel and VBA. Journal of Applied Finance 3 (): 56 65. Berus, M., S. Beyer, J. Godbey and C. Hinkelmann. (006) Marke behavior and equiy prices: wha can he S&P 500 index derivaives markes ell us? working paper. Berus, M., T. Denny, J. Godbey and C. Hinkelmann. (006) Noise and equiy prices: evidence from he sock index fuures marke. working paper. Brockwell, P. and R. Davis. (00) Inroducion o Time Series and Forecasing ( nd Ediion) (New York: Springer-Verlag). Burmeiser, E. and K. Wall. (98) Kalman filering esimaion of unobserved raional expecaions wih an applicaion o he German hyperinflaion. Journal of Economerics 0: 55-84. Burmeiser, E., K. Wall, and J Hamilon (986) Esimaion of unobserved expeced monhly inflaion using Kalman Filering. Journal of Business and Economic Saisics 4, 47-60 Faff, R.W., D. Hillier, and J. Hillier. (000) Time varying bea risk: an analysis of alernaive modeling echniques. Journal of Business Finance & Accouning 7(5): 53-554. Fink, J., K.E. Fink, and S. Lange. (005) The use of erm srucure informaion in he hedging of morgage-backed securiies. The Journal of Fuures Markes 5(7): 66-678. Godbey, J. and J.E. Hilliard. (forhcoming) Hedging long-erm commimens under sochasic convenience yield: a minimum variance approach. Quaniaive Finance. Hamilon, J. (994) Time Series Analysis (Princeon, New Jersey: Princeon Universiy Press). Joseph, P. (007) Kalman Filers, available on he inerne: hp://ourworld.compuserve.com/homepages/pdjoseph/kalman.hm Kalman, R. (960) A new approach o linear filering and predicion problems. Journal of Basic Engineering 8: 34 45. Schwarz, E. (997) The sochasic behavior of commodiy prices implicaions for valuaions and hedging. Journal of Finance 5, 93-973. 9

TABLE : The Kalman Filer Process Predic fuure unobserved variable (X + ) based on he curren esimae of he unobserved variable, call i X (+)P : X = a X + g + θ ( ) P P ADJ + * Noe: X 0P-ADJ = X 0 which is N(μ 0, σ 0 ) Use he prediced unobserved variable o predic he fuure observable variable (Y + ), call i Y (+)P : When he fuure observable variable acually occurs, calculae he error in he predicion: Generae a beer esimae of he unobserved variable a ime ( + ) and sar he process over for ime ( + ): Noe: k + is he Kalman gain and is se o minimize he variance of X (+)P-ADJ; p + is he variance of X (+)P : Y ε + = m X + b + ( ) P * ( + ) P + + Y = Y Y ( ) E ( + ) ( + )P + X = X + k Y k ( ) P ADJ ( + ) P ( + ) ( + )E + p m + + = = ( p+ m + r ) Cov ( X ( + ) P, Y( + ) P ) Var( Y ) ( + ) P These equaions are based on he more general measuremen and ransiion equaions, equaions () and (3) respecively. 0

FIGURE : Mone Carlo Generaion of he Observed and Unobserved Time Series in Excel A B C D E Acual Parameers: Mean: 0% Annually 3 Volailiy: 5% Annually 4 Risk-free rae: 4% Annually 5 Mauriy of Fuures:.00 Years 6 Time Incremen 0.093 a Years 7 Curren Spo Price: $50.00 8 9 Time (in weeks): Securiy Price: Fuures Price: Ln(Securiy): Ln(Fuures): 0 0 $50.00 b $5.04 c 3.90 d 3.950 e 5.58 f $ 53.68 3.943 3.983 5.97 $ 55.3 3.9697 4.0097 3 3 56.04 $ 58.3 4.060 4.0660 4 4 55.5 $ 57.50 4.08 4.058 a Cell Formula: =/5 b Cell Formula: =B7 c Cell Formula: =B0*EXP($B$4*$B$5) d Cell Formula: =LN(B0) e Cell Formula: =LN(C0) f Cell Formula: =B0*EXP(NORMINV(RAND(),($B$-0.5*$B$3^)*$B$6,$B$3*SQRT($B$6))) Noe: Column D conains he unobserved ime series and Column E conains he observed ime series. Furher, i may be necessary o copy he Mone Carlo daa in column B over iself. Highligh he daa, arge he daa over iself, and hen use he menu sequence: Edi/Pase Special/Values. This will save he Mone Carlo daa wihou having he simulaion updae iself every ime a new Excel command is execued (his is an Excel defaul seing).

FIGURE : Kalman Filer Applicaion for he Mone Carlo Daa E F G H I J K Measure Eq h(): 0% 3 4 Trans Eq 5 Mu: 5% 6 Sigma: 3% 7 8 9 Ln(Fuures): Pred. ln(s): Pred. ln(f): Error: P(): K(): Var(): a 0 3.950 3.90 b 0.0000 3.983 3.945 c 3.9539 d 0.09 e 0.000 f 0.093 g 0.009 h 4.0097 3.984 3.9564 0.0533 0.0039 0.0375 0.0038 3 4.0660 3.960 3.9603 0.057 0.0057 0.054 0.0054 4 4.058 3.9337 3.9679 0.0839 0.0074 0.0688 0.0069 a This is he variance of he prediced naural logarihm of he spo price. I is se a zero for = 0. b Cell Formula: =E0 - $B$4*$B$5 c Cell Formula: =F0 + ($G$5 0.5*$G$6^)*$B$6 + J*H d Cell Formula: =F0 + ($G$5 0.5*$G$6^)*$B$6 + $B$4*$B$5 e Cell Formula: =E G f Cell Formula =K0 + $G$6^*$B$6 g Cell Formula: =I/(I+$G$) h Cell Formula: =I*(-J) Noe: Cells B4, B5, and B6 refer o he spreadshee in Figure.

FIGURE 3: Applying Maximum Likelihood Esimaion o he Kalman Filer F G H I L M Measure Eq log-like: 5.4068 a h(): 0% 3 4 Trans Eq 5 Mu: 5% 6 Sigma: 3% 7 8 9 Pred. ln(s): Pred. ln(f): Error: P(): MLE(): MLE(): 0 3.90 3.945 3.9539 0.09 0.000.45 b -0.004 c 3.984 3.9564 0.0533 0.0039.3-0.037 3 3.960 3.9603 0.057 0.0057.35-0.059 4 3.9337 3.9679 0.0839 0.0074.57-0.038 a Cell Formula: = -00*LN(*PI())/ + SUM(L:L0) + SUM(M:M0) b Cell Formula: = -LN(I + $G$)/ c Cell Formula: = -(H^/(I + $G$))/ 3