hmm filtering and parameter estimation of an electricity spot price model

10
HMM ltering and parameter estimation of an electricity spot price model Christina Erlwein a, , Fred Espen Benth b , Rogemar Mamon c a Department of Financial Mathematics, Fraunhofer Institute for Industrial Mathematics ITWM, Kaiserslautern, Germany b CMA, Centre of Mathematics for Applications, University of Oslo, Oslo, Norway c Department of Statistical and Actuarial Sciences, University of Western Ontario, London, Ontario, Canada abstract article info Article history: Received 25 September 2007 Received in revised form 15 January 2010 Accepted 16 January 2010 Available online 4 February 2010 JEL classication: C51 Q40 Keywords: Adaptive lters Forecasting Hidden Markov model Parameter estimation Electricity spot price In this paper we develop a model for electricity spot price dynamics. The spot price is assumed to follow an exponential OrnsteinUhlenbeck (OU) process with an added compound Poisson process. In this way, the model allows for mean-reversion and possible jumps. All parameters are modulated by a hidden Markov chain in discrete time. They are able to switch between different economic regimes representing the interaction of various factors. Through the application of reference probability technique, adaptive lters are derived, which in turn, provide optimal estimates for the state of the Markov chain and related quantities of the observation process. The EM algorithm is applied to nd optimal estimates of the model parameters in terms of the recursive lters. We implement this self-calibrating model on a deseasonalised series of daily spot electricity prices from the Nordic exchange Nord Pool. On the basis of one-step ahead forecasts, we found that the model is able to capture the empirical characteristics of Nord Pool spot prices. © 2010 Elsevier B.V. All rights reserved. 1. Introduction Over the last two decades, electricity markets in many countries have become deregulated where spot and futures contracts are available for trade. Compared to standard nancial products, electricity spot prices show distinctive stochastic properties which call for new models. Electricity is a non-storable commodity, which leads to a strong dependency on supply and demand curves and therefore to high seasonal differences in prices. This seasonality shows daily, weekly and annual patterns. Additional empirically observed features of electricity prices include mean-reversion and frequently occurring spikes. These stochastic properties have led to different approaches for modelling electricity prices. Lucia and Schwartz (2002) proposed a two-factor mean-reverting model for spot prices with a deterministic component for the seasonal pattern. Another approach was taken by Deng (2000), Benth et al. (2003) and Cartea and Figueroa (2005), where the characteristics of spot prices are captured with mean-reversion dynamics driven by Lévy (jump) processes. A threshold autoregressive model which accounts for possible shifts in the speed of mean-reversion and the jump arrival intensity was developed by Rambharat et al. (2005). A jump-diffusion model for hourly spot prices was proposed in Culot et al. (2006).A day-ahead forecast of hourly electricity prices is performed by Conejo et al. (2005) with a combination of a wavelet decomposition and ARIMA models. They apply their model to data from mainland Spain. Through the wavelet transform the variance of the time series can be reduced and an ARIMA model leads to more accurate forecasts than a direct use of ARIMA models. Geman and Roncoroni (2006) introduce a model to capture trajectorial and statistical properties of electricity prices with a class of discontinuous processes. The model is tted to the US market, where it captures specic jump characteristics. A comprehensive and detailed description of electricity price models can be found in González et al. (2005). The calibration and parameter estimations in these models, however, can be problematic due to limited historical data and a large number of parameters. Spikes in spot electricity prices can be better captured by regime- switching models than by a Poisson jump model, see de Jong (2006). Different regime-switching models for electricity prices were developed in Deng (2000) and De Jong and Huisman (2002). Most regime- switching models distinguish between two regimes, one normaland one jumpregime. A third regime was introduced by Huisman and Mahieu (2003) for the change from jumpto normalregime. Elliott et al. (2003) developed a Markov model for electricity spot prices, where the number of online generators is represented by a Markov process in discrete time and parameters are estimated using an EM algorithm. A more general version of regime-switching models is hidden Markov models (HMM). Generally, an HMM is a double-embedded stochastic Energy Economics 32 (2010) 10341043 Corresponding author. Department of Financial Mathematics, Fraunhofer Institute for Industrial Mathematics ITWM, 67663 Kaiserslautern, Germany. Tel.: + 49 631 316004266; fax: + 49 631 316005266. E-mail address: [email protected] (C. Erlwein). 0140-9883/$ see front matter © 2010 Elsevier B.V. All rights reserved. doi:10.1016/j.eneco.2010.01.005 Contents lists available at ScienceDirect Energy Economics journal homepage: www.elsevier.com/locate/eneco

Upload: independent

Post on 21-Nov-2023

0 views

Category:

Documents


0 download

TRANSCRIPT

Energy Economics 32 (2010) 1034–1043

Contents lists available at ScienceDirect

Energy Economics

j ourna l homepage: www.e lsev ie r.com/ locate /eneco

HMM filtering and parameter estimation of an electricity spot price model

Christina Erlwein a,⁎, Fred Espen Benth b, Rogemar Mamon c

a Department of Financial Mathematics, Fraunhofer Institute for Industrial Mathematics ITWM, Kaiserslautern, Germanyb CMA, Centre of Mathematics for Applications, University of Oslo, Oslo, Norwayc Department of Statistical and Actuarial Sciences, University of Western Ontario, London, Ontario, Canada

⁎ Corresponding author. Department of Financial Matfor Industrial Mathematics ITWM, 67663 Kaiserslaute316004266; fax: +49 631 316005266.

E-mail address: [email protected]

0140-9883/$ – see front matter © 2010 Elsevier B.V. Adoi:10.1016/j.eneco.2010.01.005

a b s t r a c t

a r t i c l e i n f o

Article history:Received 25 September 2007Received in revised form 15 January 2010Accepted 16 January 2010Available online 4 February 2010

JEL classification:C51Q40

Keywords:Adaptive filtersForecastingHidden Markov modelParameter estimationElectricity spot price

In this paper we develop a model for electricity spot price dynamics. The spot price is assumed to follow anexponential Ornstein–Uhlenbeck (OU) process with an added compound Poisson process. In this way, themodel allows for mean-reversion and possible jumps. All parameters are modulated by a hidden Markovchain in discrete time. They are able to switch between different economic regimes representing theinteraction of various factors. Through the application of reference probability technique, adaptive filters arederived, which in turn, provide optimal estimates for the state of the Markov chain and related quantities ofthe observation process. The EM algorithm is applied to find optimal estimates of the model parameters interms of the recursive filters. We implement this self-calibrating model on a deseasonalised series of dailyspot electricity prices from the Nordic exchange Nord Pool. On the basis of one-step ahead forecasts, wefound that the model is able to capture the empirical characteristics of Nord Pool spot prices.

hematics, Fraunhofer Institutern, Germany. Tel.: +49 631

e (C. Erlwein).

ll rights reserved.

© 2010 Elsevier B.V. All rights reserved.

1. Introduction

Over the last two decades, electricity markets in many countrieshave become deregulated where spot and futures contracts areavailable for trade. Compared to standard financial products,electricity spot prices show distinctive stochastic properties whichcall for new models. Electricity is a non-storable commodity, whichleads to a strong dependency on supply and demand curves andtherefore to high seasonal differences in prices. This seasonality showsdaily, weekly and annual patterns. Additional empirically observedfeatures of electricity prices include mean-reversion and frequentlyoccurring spikes. These stochastic properties have led to differentapproaches for modelling electricity prices. Lucia and Schwartz(2002) proposed a two-factor mean-reverting model for spot priceswith a deterministic component for the seasonal pattern. Anotherapproach was taken by Deng (2000), Benth et al. (2003) and Carteaand Figueroa (2005), where the characteristics of spot prices arecaptured with mean-reversion dynamics driven by Lévy (jump)processes. A threshold autoregressive model which accounts forpossible shifts in the speed of mean-reversion and the jump arrivalintensity was developed by Rambharat et al. (2005). A jump-diffusion

model for hourly spot prices was proposed in Culot et al. (2006). Aday-ahead forecast of hourly electricity prices is performed by Conejoet al. (2005) with a combination of a wavelet decomposition andARIMA models. They apply their model to data from mainland Spain.Through the wavelet transform the variance of the time series can bereduced and an ARIMA model leads to more accurate forecasts than adirect use of ARIMAmodels. Geman and Roncoroni (2006) introduce amodel to capture trajectorial and statistical properties of electricityprices with a class of discontinuous processes. The model is fitted tothe US market, where it captures specific jump characteristics. Acomprehensive and detailed description of electricity price modelscan be found in González et al. (2005). The calibration and parameterestimations in these models, however, can be problematic due tolimited historical data and a large number of parameters.

Spikes in spot electricity prices can be better captured by regime-switching models than by a Poisson jump model, see de Jong (2006).Different regime-switchingmodels for electricitypriceswere developedin Deng (2000) and De Jong and Huisman (2002). Most regime-switching models distinguish between two regimes, one ‘normal’ andone ‘jump’ regime. A third regime was introduced by Huisman andMahieu (2003) for the change from ‘jump’ to ‘normal’ regime. Elliott etal. (2003) developed a Markov model for electricity spot prices, wherethe number of online generators is represented by a Markov process indiscrete time and parameters are estimated using an EM algorithm. Amore general version of regime-switching models is hidden Markovmodels (HMM). Generally, an HMM is a double-embedded stochastic

1035C. Erlwein et al. / Energy Economics 32 (2010) 1034–1043

process composed by an observation series and an underlying processdefined by its number of states and transition probabilities. HMM wasapplied to electricitymarkets byYu and Sheblé (2006) for describing thestructure of the electricitymarket and inGonzález et al. (2005), using anInput/Output HMM in analysing electricity prices. In this paper wedevelop an HMM for forecasting electricity spot prices. We assume thatthe electricity spot price is only a partial observation. Pieces ofinformation, which are difficult to quantify, such as behavioural aspectsof buyers and sellers, unforeseen weather, and production issues,amongst others, are hidden in this observation process. This hiddeninformation is modelled by a Markov chain in discrete time, whichgoverns the parameters of our model.

One main problem in forecasting prices in the electricity market isthe estimation of parameters since daily prices can be very volatile andjumps can occur throughout the year. Our HMM is a mean-revertingmodel with jumps, where the parameters evolve according to theunderlying discrete-timeMarkov chain. The proposedmodel is able tocapture the main features (seasonality, mean-reversion and jumps)that characterise electricity spot prices. The main contribution of thispaper is the derivation of the recursive formulae for optimal modelparameter estimation. Adopting a change of reference measuretechnique by Elliott (1994) in estimating parameters under an HMMdiscrete-time setting, we provide recursive parameter estimatesupdated via a self-tuning algorithm. In contrast to the HMM approachby Yu and Sheblé (2006) we directly model the electricity spot pricewithin anHMMsetting,whereas Yu and Sheblé focus onmodelling thestructure of the electricity market. They estimate parameters forelectricity demand and online generation capacity in different states.Also, González et al. (2005) define in their Input–Output HMMspecificfactors (load, hydro generation, and nuclear generation) which areused as input variables and influence the hourly spot price. For theiranalysis of the Spanish electricity market they choose a time period asa training set and the following period as a test set. Ourmodel uses theonline algorithm to update optimal parameter estimates through time.When new market information is available, the parameter values areupdated accordingly. The hidden factors in our model symbolisehidden market information, which cannot be observed. Therefore ourmodel provides a more flexible framework for forecasting electricityspot prices, various hidden information of the electricity market andthe economy can be captured by the hidden process.

We apply our model to the Nordic electricity market, which isknown for its volatile nature. Compared to more stable markets likethat of Singapore or that of the US, the Nordic market shows morefrequently occurring jumps since power production relies heavily onhydro power. As water levels in the reservoirs are an importantdeterminant in electricity generation, prices in the Nordic markethave high seasonal variations and spikes. Our recursive algorithm foroptimal parameter estimates is applied on a data set obtained fromthe Nordic exchange Nord Pool and one-step ahead daily spot priceforecasts are calculated. The forecasts in a 2- and 3-state HMM settingfollow the actual data closely. Furthermore within the framework ofour model, we price expected spots on delivery, which can betransferred to Forward pricing and easily adopted by practitioners.

The paper is organised as follows: in Section 2 we describe themodel framework and the underlying stochastic process. Section 3details the derivation of the filters for the state of the Markov chainand related quantities through a change of probability measure. InSection 4 these adaptive filters are used to find optimal estimates ofthe model parameters recursively. These recursive formulae arederived by employing the Expectation-Maximisation (EM) algorithmand relating the parameters in the model to the processes of theMarkov chain. The implementation of this model is shown in Section 5together with an application dealing with the pricing of forwardcontracts. The data set consists of daily spot prices from the Nordicpower exchange Nord Pool. Before the filters are applied, the actualdata set is deseasonalised.We found that a 2-state and 3-state Markov

chain-based model produces one-step ahead forecasts with smallprediction errors. The performance of a regime-switching model issignificantly better than that of the no-regime-switching model. Ourproposed model and optimal parameter estimation capture manysalient features of the electricity spot market. The last section presentssome conclusions and remarks.

2. Model description

The spot price model for electricity is composed of twocomponents: one deterministic function D(k) to capture seasonaltrends, and X(k), an Ornstein–Uhlenbeck process with addedcompound Poisson process and Markov-modulated parameters. TheOrnstein–Uhlenbeck process models the mean-reversion of electricityprices observed in the market. The random price fluctuations aremodelled by a Brownian motion W to include the ‘normal’ variationswhen the market is quiet and a jump process Y for the spikes. Theobservation process is defined on the underlying probability space (Ω,F , P). Throughout the entire discussion we denote all vectors by boldsmall letters and all matrices by bold capitalised letters.

Let zk be a homogeneous Markov chain with finite state in discretetime (k=0, 1,…) and state space {e1, e2,…, en}, where ei=(0, ..., 0, 1,0, ..., 0)⊺ and ⊺ denotes the transpose of a vector. Different states of theMarkov chain represent different regimes of the market which aredetermined by the interaction amongst many variables such as thecurrent state of supply and demand and strategic behaviour of marketagents. Let F k

0=σ{z0,…, zk} be the σ-field generated by z0,…, zk, andF z be the completion of F k

0. Under the probability measure P theMarkov chain z has dynamics zk+1=Πzk+vk+1, where Π denotesthe transition probability matrix of the Markov chain and vk+1 is amartingale increment with E[vk+1|F k

zk]=0. In Fabra and Toro (2005),the autoregressive Markov switching model has time varyingtransition probabilities. Here, the transition probabilities are setconstant within each run of the algorithm but are updated when newinformation arrives. The spot price dynamic is given by

S kð Þ = D kð Þ exp Xkð Þ: ð1Þ

We model the seasonal component D(k) with a sinusoidal functionwith positive trend. Sinusoidal functions are applied in various studiesfor capturing seasonal components. Pilipović (1998)models seasonalityeffects for spot prices from various markets through a sinusoid withannual and semiannual parameters. A sinusoidal seasonal functionwithweekly, semi-weekly and annual components was used in Culot et al.(2006) and Kluge (2006). Furthermore, sinusoidal terms as well asdummy variables were introduced in de Jong (2006)whilst Geman andRoncoroni (2006) include a cosine function in themean trend for the USmarket. Here, we choose a sinusoidal function that has yearly andweekly components because the electricity demand on the Nordicmarket shows seasonal patterns for colder andwarmer times of the yearas well as for weekend- and weekday-demands. Weron et al. (2004)show through awavelet decomposition technique that the annual cycleon the Nord Pool market can be approximated by a sinusoidal functionwith linear trend. Benth and Šaltytė-Benth (2005) show thatNorwegiantemperature data can be modelled by a cosine function. The Nord Poolmarket is temperature driven, the load is directly linked to thetemperature. The seasonal component is given by

D kð Þ = ak + ∑3

h=1ðbh sin sh

2π365

k� �

+ ch cos sh2π365

k� �

+ dh sin sh2π7

k� �

+ eh cos sh2π7

k� �Þ + g

ð2Þ

for s1=1, s2=2 and s3=4 to cover yearly, weekly, half a year, mid-week and quarterly yearly and weekly patterns and the constants a, bh,

1036 C. Erlwein et al. / Energy Economics 32 (2010) 1034–1043

ch, dh, eh and g are to be determined. The modelling approach in Chenand Jiang (2006) emphasises the influenceof system-wide load capacityratio and system-wide generation forced outages on spot prices. Ourdeterministic function can be extended by practitioners if additionalmarket information on capacity and generation is available. Here wechoose to include seasonal components due to the high seasonalvariations on the Nordicmarket. The stochastic process Xt has dynamics

dXt = α ztð Þ β ztð Þ−Xtð Þdt + σ ztð ÞdWt + dYt ð3Þ

where the level β, speed of mean-reversion α and volatility σ are allgovernedby theMarkov chain zt. Since zt is anyoneof theunit vectors ei,the parametersα,β andσhave the representations ⟨·,·⟩withα(zt)=⟨α,zt⟩, β(zt)=⟨β, zt⟩ and σ(zt)=⟨σ, zt⟩, where ⟨·,·⟩ is the usual Euclideanscalar product. The jump process Yt is given by

dYt = JdNt ; ð4Þ

where Nt is a Poisson process with constant intensity λ. When a jumpoccurs, its magnitude J is a random variable with a probability densityfunction that depends on the Markov chain zt meaning that differentregimes have different jump size distributions. The conditionaldistribution of the jump sizes is J|zt∼N(μJ(zt), σJ

2(zt)). The intensity λdoes not changewhen a switching of regimes occurs. The seasonality ofjump intensity is still taken into account, since the jump size is evolvingaccording to the state of the Markov chain. The global filtration isdefined by F=FW∨FY∨F z, where the filtration generated by theBrownian motion is denoted by FW and the filtration generated by thejump process component is FY. The global filtration includes thefiltration generated by the observation process FX=σ(X1, X2, …).

3. Filtering

In this section we derive adaptive filters for processes of theMarkov chain z. We use a change of measure technique, so we are ableto derive recursive filters under a new ideal measure, where we haveindependent observations.

3.1. Change of measure

We define our observation process as the logarithm of thedeseasonalised electricity spot prices, which is given by thecontinuous-time solution of Eq. (3), i.e.,

Xt = lnS tð ÞD tð Þ

= Xse−∫t

sα zuð Þdu + ∫tse

−∫tuα zvð Þdvα zuð Þβ zuð Þdu

+ ∫tse

−∫tuα zvð Þdvσ zuð ÞdWu + ∫t

se−∫t

uα zvð ÞdvdYu:

ð5Þ

The parameters α, β, σ and the jump-size Jt of the compoundPoisson process component are governed by a Markov chain zt indiscrete time. The Markov chain is considered to be constant over theinterval [s, t]. Prior to discretising Eq. (5) we approximate it in order tosimplify the integral parts with process zt inside the integrals in theexplicit solution. We get

Xt = Xse−α zsð Þ t−sð Þ + β zsð Þ 1−e−α zsð Þ t−sð Þ� �

+ σ zsð Þe−α zsð Þt∫tse

α zsð ÞudWu

+ ∑Nt

m=Ns + 1e−α zsð Þ t−τmð ÞJm ztð Þ:

ð6Þ

The random time of occurrence of the mth jump is denoted by τm.For the derivation of the filters of related processes of the Markov

chain z and in finding optimal parameter estimates we work under areference probability measure P. To do this we need a discrete-timeversion of our observation process. Discretising Eq. (6) by applyingthe Euler approximation leads to

Xk + 1 = Xke−α zkð ÞΔk + β zkð Þ 1−e−α zkð ÞΔk

� �

+ σ zkð Þffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi1−e−2α zkð ÞΔk

2α zkð Þ

shk + 1 + ∑

NΔk

m=1e−α zkð Þ Δk−τmð ÞJm zkð Þ

ð7Þ

where {hk+1} is a sequence of IID standard normal random variables.Note the following connection for the discretisation of the jump term:

∫kl e

−α zkð Þ k−uð ÞdYu = ∑Nk + 1

m=Nk + 1e−α zkð Þ k−τmð ÞJm zkð Þ =|{z}

in distr:

e−α zkð Þ k−lð Þ ∑Nk−l

m=1eα zkð Þτm Jm zkð Þ;

where τm are the jumping times in the interval (0,k− l].We calculate our filters under a reference probability measure

P. Under this measure z is still a Markov chain with dynamics zk+1=Πzk+vk+1 and Xk are independent observations. To perform a changeof measure we examine the discretised observation process. Wechoose a measure change that does not affect the compound Poissonprocess component of the observation process. We construct areference probability measure P by applying a discrete time versionof Girsanov's theorem. The measure P is defined through the Radon–Nikodym derivative d

�P

dP jF k = Λk = ∏kl = 1ψl so that the process {Λ l} is

a P-almost surely positive martingale with filtration F and EP[Λ]=1.Following the technique developed in Elliott et al. (1995) we back

out the real-worldmeasure from the reference probabilitymeasure bydefining dP

d�PjF k = Λk = ∏k

l = 1�ψl with

�ψl : =exp½−1

dXle

−α zlð ÞΔl + β zlð Þ 1−e−α zlð ÞΔl� �+ ∑

NΔl

m=1e−α zlð Þ Δl−τmð ÞJm zlð Þ

" #Xl + 1

d

− 12d2

Xle−α zlð ÞΔl + β zlð Þ 1−e−α zlð ÞΔl� �

+ ∑NΔl

m=1e−α zlð Þ Δl−τmð ÞJm zlð Þ

" #2� ð8Þ

with d = σ zlð Þffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi1−e−2α zlð ÞΔl

2α zlð Þ

sand Λ0=1, {ψl: ψaℕ+} and {Λ l: laℕ}.

The process {Λl} is a F -martingale under P and ΛΛ=1.Therefore we found an equivalent probability measure used to

calculate adaptive filters for processes involving the Markov chain.With Bayes' theorem, a filter for an adapted process Hk is given by

E Hk jFXk

h i=

�E Hk

�Λk jFX

k

h i�E

�Λk jFX

k

h iwhere Hk is any scalar F -adapted process, H0 is F0

X measurable. The H-process has the form Hk=Hk−1+al+⟨bl, Vl⟩+glf(yl) where a, b and gare F -predictable, f is a scalar-valued function and Vk=zk+Πzk−1.

Write η(Hk):=Ē[HkΛk|F kX], so that E Hk jFX

k

� �= η Hkð Þ

η 1ð Þ . We can derive

recursive filters for the term η(Hk−1zk−1). This conditional expectationis related to the desired term η(Hk−1) through ⟨1, η(Hkzk)⟩=η(Hk),where 1 is a vectors of 1s. Therefore, Hk's filter has the representation

E Hk jFXk

� �= ⟨1;η Hkzkð Þ⟩

⟨1;η zkð Þ⟩.

We derive filters for the state of the Markov chain, number ofjumps G, occupation time O and auxiliary process T. Let Gk

sr denote thenumber of times the Markov chain zk jumps from state r to state s upto time k. Suppose the occupation time is denoted by Ok

r which gives

1037C. Erlwein et al. / Energy Economics 32 (2010) 1034–1043

the amount of time up to k for which zk has been in state er. Filters forthese quantities are derived following Elliott (1994). A recursiverelation for ηk(Hkzk), whose proof can be found in Elliott (1994),Theorem (5.3), is given by

ηk Hkzkð Þ = ∑n

i=1Γi ykð Þ½⟨ei;ηk−1 Hk−1zk−1ð Þ⟩Πei + ⟨ei;ηk−1 akzk−1ð Þ⟩Πei

+ diag Πeið Þ−Πei⊗Πeið Þηk−1 bk⟨ei; zk−1⟩

+ηk−1 gk⟨ei; zk−1⟩

f ykð ÞΠei�ð9Þ

where Γi is defined by

Γi = exp ½− 1d2i

Xle−αiΔl + βi 1−e−αiΔl

� �+ ∑

NΔl

m=1e−αi Δl−τmð ÞJim

" #Xl + 1

− 12d2i

Xle−αiΔl + βi 1−e−αiΔl

� �+ ∑

NΔl

m=1e−αi Δl−τmð ÞJim

" #2�: ð10Þ

With Hk=1 in Eq. (9), the state estimator is recursively given by

ηk zkð Þ = ∑n

i=1Γi zkð Þ⟨ei;ηk−1 zk−1ð Þ⟩Πei: ð11Þ

For the jump process G from state r to state s of the Markovprocess, defined as Gsr

k = ∑kl = 1⟨zl−1; er⟩⟨zl; es⟩, we have

ηk Gsrk zk

= ∑

n

i=1Γi zkð Þ⟨ηk−1 Gsr

k−1zk−1

; ei⟩Πei

+ Γr zkð Þηk−1 ⟨zk−1; er⟩ð Þπsres;

ð12Þ

by replacing H with G in Eq. (9).Now consider the occupation time of z defined by Or

k =∑k

l = 1⟨zl−1; er⟩. With Hk=Okr , Eq. (9) implies

ηk Orkzk

= ∑

n

i=1Γi zkð Þ⟨ηk−1 Or

k−1zk−1

; ei⟩Πei

+ Γr zkð Þ⟨ηk−1 zk−1ð Þ; er⟩Πer :

ð13Þ

To complete the calculation of the optimal model parameter esti-mates we also need an auxiliary process T, defined by Tr

k fð Þ = ∑kl = 1

⟨zl−1; er⟩ f Xlð Þ where f is a function of the form f(X)=Xl, f(X)=Xl2,

f(X)=Xl+1 or f(X)=Xl+12 ,1≤ l≤k. With Hk=Tk

r in Eq. (9),

ηk Trk fð Þzk

= ∑

n

i=1Γi zkð Þ⟨ηk−1 Tr

k−1 fð Þzk−1

; ei⟩Πei

+ Γr zkð Þ⟨ηk−1 zk−1ð Þ; er⟩f Xkð ÞΠer :

ð14Þ

4. Optimal parameter estimates

In this section we derive maximum likelihood estimates for theparameters of the observation process Xt in Eq. (6), where theparameters are governed by a Markov chain zt.

First we derive the probability density function (pdf) of the processXt. The parameters are said to be constant over the interval [s, t], 0≤s≤ t.The observation process without jumps is normally distributed withmean μx=β+(Xs−β)e−α(t− s) and variance σ2

x = σ2

2α 1−e−2α t−sð Þ .

We examine the distribution of the part given by the compound Poissonprocess Yt. As described in the previous section J1, J2,… are independent,identically distributed normal random variables and (Nt)t≥0 is astandard Poisson process with jump intensity λN0. Let N and J bejointly independent. We denote the mean and the variance of theprocess J by μJ and σJ

2, respectively. The probability distribution of thePoisson process N is given by the usual Poisson distribution. To derive

the density of the jump component we utilise the approximation of thejump integral,∫t

se−α t−uð ÞdYu≈e−α t−sð Þ Yt−Ysð Þ. By the stationarity of the

compound Poisson process, we find that the increment Yt−Ys has thesame distribution as Yt− s. Thus, the density of the jump term is

ΦYt−sxð Þ = ∑

h=0

λ t−sð Þð Þhh!

e−λ t−sð Þ × ϕ x; μ Je−α t−sð Þh;σ 2

J e−2α t−sð Þh

� �ð15Þ

where ϕ denotes the pdf of the normal distribution. Following thearguments by Hanson andWestman (2002) the pdf of our observationprocess can be calculated as the convolution of densities of the OUprocess without jumps and the jump part distribution. We thereforehave the density of Xt conditioned on Xs as

ΦX xð Þ = ∑∞

h=0

λ t−sð Þð Þhh!

e−λ t−sð Þ

× ϕ x;β + Xs−βð Þe−α t−sð Þ + μJe−α t−sð Þh;

σ2

2α1−e−2α t−sð Þ� �

+ σ 2J e

−2α t−sð Þh� �

:

ð16Þ

The density in Eq. (16) can be further expressed as an expectationof the normal density under the Poisson counter NΔk. Hence, Eq. (16)has a more compact form

ΦX xð Þ = ENΔk ½ϕð x;β + Xs−βð Þe−α t−sð Þ + μJe−α t−sð ÞNΔt ;

σ2

2α1−e−2α t−sð Þ� �

+ σ2J e

−2α t−sð ÞNΔtÞ�:ð17Þ

Wewish tofind theoptimal parameters of the observationprocessXtspecified in Eq. (6) using the EM algorithm. For this purpose we makethe simplifying assumption, that the intensity of the Poisson processλ isindependent from the other parameters. To find optimal estimates, weevaluate the parameters of the normally distributed part of theobservation process independent of the Nt-process. We first derive themaximum likelihood estimates (MLE) for the set of parameters ξ={α i,βi, σi

2, µJ, σJ2, πji}. Our aim is to find a new set of parameters ξ, which

maximises the conditional expectation of the log-likelihoods. In thefollowing we denote the jump counter NΔk with p and the mean andvariance of the OUprocesswith μ x and σx, respectively.We deriveMLEsfor the normal distribution ϕ(x; μ x+μ Jpe−α(t− s), σx

2+σJ2pe−α(t− s)).

We note that both mean and variance are dependent on the Markovchain z, and so they are regime-switching. The discretised version of theobservation process in Eq. (7) is used in deriving the recursiveparameter updates.

We derive an explicit recursive formula for the parameter βwith theprocesses of the Markov chain z. However, since the mean-reversionlevel α is included in the mean and variance part, the calculation of theMLE for α is less straightforward and a recursive formula cannot befound.We therefore derive an explicit recursive formula for themean μxand themean of the jumpprocess μJ and calculate a value forα based onthe optimal value of β by solving the equation µxj=βi+(Xl−βi)e−αiΔ.

Consequentlyαi = − lnμxi−βi

Xl−βi

� �1Δ. With this value of α togetherwith

the MLE estimate of σx the estimated value of σi is given by

σ2i =

2αiσ2xi

1−e−2αiΔ. Therefore, calculating MLEs for μx and σx gives us the

desired parameter estimates for α and σ2. Applying the EM algorithmwe obtain the following optimal recursive parameter estimates:

μxi=

T ik Xk + 1

− Oikμ Ji

pe−αiΔ

Oik

ð18Þ

1038 C. Erlwein et al. / Energy Economics 32 (2010) 1034–1043

μ Ji=

T ik Xk + 1

− Oikμxi

Oikpe

−αiΔð19Þ

βi =Tik Xlð Þ e−2αiΔ + e−αiΔ

� �−O

ik −e−2αiΔμ Ji

p + μ Jipe−αiΔ

� �Oik 1 + 2e−αiΔ + e−2αiΔ

+Tik Xl + 1

1−e−αiΔ� �

Oik 1 + 2e−αiΔ + e−2αiΔ

ð20Þ

σ2xi=

T ik X2

k + 1

� �+Oi

k μ2xi+ μ2

Jip2e−2αiΔ + 2μxi

μ Jipe−αiΔ−σ2

Jie−2αiΔp

� �Oik

−2T i

k Xk + 1

μxi+ μ Ji

pe−αiΔ� �Oik

ð21Þ

σ2Ji=

T ik X2

k + 1

� �+ Oi

k μ2xi+ μ2

Jip2e−2αiΔ + 2μxi

μ Jipe−αiΔ−σ 2

xi

� �Oikpe

−2αiΔ

−2T i

k Xk + 1

μxi+ μ Ji

pe−αiΔ� �

Oikpe

−2αiΔ

ð22Þ

and

πji =Gjik

Oik

: ð23Þ

Note that for any process H we write Ĥl=E[Hl|F kX]. The proof of

Eq. (18) can be found in the Appendix. The proofs of formulae (19)–(23) are derived using similar arguments.

5. Implementation

The model is implemented on daily spot prices compiled byNordpool. In the implementation hybrid states of the Markov chainare allowed. For instance, in a two-state setting zk could take the value

Fig. 1. Actual data and

(0.3, 0.7)⊺, which indicates that zk has a 0.3 probability of being instate 1 and a 0.7 probability of being in state 2.

5.1. Fitting the deterministic function

Due to the nature of power production in Norway, where mostelectricity is produced from hydro power, electricity prices are highlydependent on water levels in reservoirs and snowmelting conditions.Compared to other power regions like the US electricity market, dailyspot prices compiled by Nordpool therefore exhibit high seasonality.To remove seasonal components, the deterministic function is fittedto the actual data. The parameters for the deterministic function arecalibrated with a least-square algorithm in Matlab. In particular,12∑t D x; kð Þ−SP kð Þð Þ2 is minimised with respect to x, where x denotesa set of parameters. In our case, x={a, bh, ch, dh, eh, g}, is a parameterset described in Eq. (2). The resulting best fitting deterministicfunction for the seasonality component has the estimated parametervalues of â=0.0566, b1=14.2141, b2=−0.6806, b3=4.6331,ĉ1=20.4066, ĉ2=−1.6644, ĉ3=2.6234, d1=8.5408, d2=3.1962,d3=0.7352, ê1=0.5275, ê2=4.3471, ê3=2.8170 and ĝ=97.3887.

In Fig. 1 daily spot prices in NOK/MWh are depicted together withthe seasonal function. Frequent jumps in the electricity prices arevisible and the descriptive statistics show a high variance of the pricedata. The remaining stochastic part is the log of the deseasonalisedspot price S. We consider this as our observation process for theempirical work presented in the next subsection.

5.2. Filtering and parameter estimation

The filters for updating the model parameters are applied to thedata set. We calculate a series of one-step ahead forecasts for thedeseasonalised daily log spot prices. The expected value of theobservation process at time k+1 is calculated using the equation

E Xk + 1 jF k

� �= Xke

−⟨α;Πzk⟩Δk + ⟨β;Πzk⟩ 1−e−⟨α;Πzk⟩Δk� �

+ λke−⟨α;Πzk⟩Δk⟨μJ ;Πzk⟩ð24Þ

The data set in our implementation consists of 1360 data points forthe time period between December 1998 and August 2002. We use

seasonal function.

Fig. 2. Evolution of parameters in a 2-state HMM.

Fig. 3. Evolution of parameters in a 3-state HMM.

1039C. Erlwein et al. / Energy Economics 32 (2010) 1034–1043

Fig. 4. One-step ahead electricity price forecasts in a 3-state HMM.

1040 C. Erlwein et al. / Energy Economics 32 (2010) 1034–1043

the mean value and variance from the data set as guides to selectinitial values. Practitioners implementing the algorithm on differentdata sets may need to run the algorithm with different choices for theinitial values as the EM algorithm could only yield a local maximumfor the log-likelihood. The data set is processed in data batches of 40data points. This means that roughly every six weeks (sufficient to

Fig. 5. Comparison of 1-, 2-, and 3-state HM

warrant the presence of new information), the parameter estimatesare updated based on updated filtering equations. The algorithm isrun 34 times within our data set. The algorithm is a self-tuningalgorithm since new information leads to updated optimal parameterestimates. The implementation is performed under the set-up of a 2-state and 3-state Markov chain. To show the added benefit of

M one-step ahead spot price forecasts.

Table 1Error analysis for HMM forecast.

Error measure 1-state 2-state 3-state 4-state

Log spot pricesMSE 0.4615 0.0577 0.0455 0.0464MdAPE 2.066 0.7681 0.6771 0.6115MdRAE 6.2049 3.3750 2.9837 2.7961

Actual spot pricesMSE 4967.5 1160.8 1142.8 1026.9MdAPE 0.2016 0.1202 0.1040 0.0993MdRAE 3.9546 2.6242 2.4089 2.3093

1041C. Erlwein et al. / Energy Economics 32 (2010) 1034–1043

introducing the switching of regimes, the algorithm is also run on a 1-state model setting, and we compare the results.

Fig. 2 depicts the dynamic movement of the optimal parameterestimates of a 2-state HMM. The parameters α and σ are calculatedthrough the updated optimal parameters β, μx and σx. In updating α thecondition µxiNXl for XlNβi or µxibXl for Xlbβimust be satisfied, otherwiseαi(p+1)=αi(p) forp=1, ...,npwithnp=no_of_parameter_updates. Allother parameters are calculated via the recursive filter Eqs. (18) to (23).

In Fig. 3 the evolution of parameters in a 3-state Markov chainsetting is displayed. Here, the evolution of parameters exhibits similarpattern to that of the 2-state Markov chain setting. The rate ofconvergence of parameter estimates is slightly higher than that in the2-state set-up.

The one-step ahead forecasts for electricity spot prices in a 3-stateHMM is depicted in Fig. 4. The graph shows the forecast for thedeseasonalised log prices as well as for the daily spot prices. Here wecan see that the one-step ahead forecast follows the actual values veryclosely. Our self-tuning algorithm is able to capture the dynamics ofthe electricity spot prices and the occurrence of jumps is picked up bythe filter.

A comparison of the 1-, 2- and 3-state HMM forecasts shows, thatregime-switching significantly improves the one-step ahead fore-casts. Fig. 5 depicts a zoom-in view of forecasts from the three models

Fig. 6. Expected spot on deli

during a 6-month period. The 2- and 3-state settings give closerforecasts than the 1-state model.

An error analysis on the deviations between forecasts anddeseasonalised log spot prices as well as forecasts and daily spotprices is given in Table 1. Three error measures, namely mean squareerror (MSE), median absolute percentage error (MdAPE) and medianrelative absolute error (MdRAE) are calculated for the 1-, 2-, 3- and 4-state settings. The MdAPE is the sample median of {APEt}, which is

calculated through APEt =Ft−At

At: Here, Ft denotes the forecast of the

timeseries at time t and At denotes the actual value of the time series.The MdRAE is obtained similarly, here we take the sample median of

{RAEt}, which is calculated through RAEt =Ft−At

Frw;t−At; where F rw,t

denotes the forecast of the time series from the randomwalk method.TheMSE is obtained fromMSE = 1

N∑Nt = 1 Ft−Atð Þ2;where N denotes

the number of observations in the time series. The largest improve-ment in the error measurements can be seen between the 1-state and2-state HMM. This is a clear indication that models with regime-switching parameters are more likely to generate better priceforecasts than a model with no-regime-switching. The number ofstates was extended to n=4, but the error analysis shows that nosignificant improvement is achieved. A comparison of error measure-ments between the 2- and 3-state setting shows that the 3-state HMMis able to forecast deseasonalised log spot prices as well as daily spotprices better than the 2-state model. A large number of states adds tothe complexity of parameter estimation. Therefore, a slight improve-ment in terms of MdAPE for example using a 4-state setting does notreally merit choosing a model with nN3.

5.3. Pricing of electricity contracts

We use the optimal parameter estimates generated by ourproposed filtering procedures in pricing the expected spot at delivery(ESD). The price we are considering is given by the expected values ofthe spot price at a future time T given the current price at time t underthe real-world measure P. The forward price is the ESD under a risk-

very in a 3-state HMM.

1042 C. Erlwein et al. / Energy Economics 32 (2010) 1034–1043

neutral measure. The risk-premium can then be calculated as thedifference between these two prices. We compute the ESD formaturities of T=1, …, 30 days with starting dates from 1st July2002 to 15th July 2002. Fig. 6 shows the ESD prices in a 3-state setting.In this example for short delivery periods it is reasonable to assume aconstant Markov chain. Since the starting dates lie in the last batch ofdata in our filtering estimation, we use the corresponding latestparameter estimates in a 3-state setting, which are α(zt)=−0.5853,β(zt)=0.1211, σ(zt)=0.04, μJ(zt)=0.0091 and σJ(zt)=0.0089.

The ESD in our model is calculated using

ESD ST ; t; Tð Þ = EP ST jF t½ �

= D Tð Þ exp Xte−α ztð Þ T−tð Þ

� �exp β ztð Þ 1−e−α ztð Þ T−tð Þ

� �+

σ ztð Þ22

1−e−2α ztð Þ T−tð Þ� �" #

× EP exp ∫Tt e

−α ztð Þ T−uð ÞJdNu

� �jF t

h i

= D Tð Þ exp Xte−α ztð Þ T−tð Þ

� �exp β ztð Þ 1−e−α ztð Þ T−tð Þ

� �+

σ ztð Þ22

1−e−2α ztð Þ T−tð Þ� �" #

× exp ∫Tt exp μJ ztð Þe−α ztð Þ T−uð Þ +

σ 2J ztð Þ2

e−2α ztð Þ T−uð Þ !

λdu−λ T−tð Þ" #

:

A proof for the expected value of an integral similar to the last termEP[exp(∫t

Te−α(zt)(T−u)dYu)|F t] can be found in Benth et al. (2003). Theexpectations above have to be calculated numerically if we do notassume that the Markov chain is constant. This approach is necessaryfor pricing ESD's with longer delivery periods which is an importantissue for future research.

The prices in a 2-state setting are slightly lower than the pricesderived in a 3-state HMM; the difference increases with increasingmaturity. This pricing example shows a practical application of ourmodel for spot prices and the filtered parameters. For any determin-istic market price of risk, the conclusion of this exercise may bedirectly transferred to forward prices.

6. Concluding remarks

We developed an HMM-driven model to forecast electricity spotprices. The spot price is assumed to evolve in accordance with theexponential of an OU process plus a jump term and this exponential isscaled by a deterministic sinusoidal function to take into account theseasonal component of electricity prices. The added compoundPoisson process has normally distributed jumps, where the meanand variance are governed by a discrete-time HMM. This offers themodel greater flexibility to switch between economic regimesreflected by the dynamic changes of various factors such as electricitysupply and demand or behavioural aspects, which are easily seen inthe sudden jumps of spot prices. Employing the EM algorithm, theoptimal estimates for the model parameters are derived in terms ofthe recursive filters for the state of the Markov chain, the number ofjumps between two states, occupation time of the Markov chain andan auxiliary process. Since the parameters are updated whenever anew dataset arrives, we have created a self-tuning model. Theempirical work on the implementation of filters and parameterestimation of the model using deseasonalised electricity spot pricesillustrates that the proposed model is well-equipped to capture thespikes present in the data for both the 2-state and 3-state setting. Acomparison to the 1-state model indicates clearly the improvementsgained by allowing parameters to switch between regimes. Theimportant empirically observed characteristics of the electricitymarkets are captured by the model as evidenced by low forecasterrors and similar trends portrayed by the forecasts closely resem-bling to the dynamics and patterns of the actual data series. Thepricing of expected spots on delivery shows an application of ourmodel to pricing, which can be easily adopted by practitioners.

Acknowledgements

The authors would like to thank Steen Koekebakker for helpfuldiscussions and for providing electricity spot price data in ourempirical analysis. Christina Erlwein wishes to thank the financialsupport provided by a Marie Curie Fellowship for Early StageResearchers Training and to acknowledge the hospitality of theCentre of Mathematics for Applications, University of Oslo where thiswork was completed.

Appendix A. Optimal parameter estimate for μx.

We define a new measure P by

dPdPjF k

= Λ�k = ∏

k

l=1λ�l

where

λ�l =

exp − 12σ2

xXl + 1−μ x−μ Jpe

−αΔh i2� �

exp − 12σ2

xXl + 1−μx−μ Jpe

−αΔh i2� �

= exp1

2σ2x

− Xl + 1−μx−μ Jpe−αΔ

� �2+ Xl + 1−μx−μ Jpe

−αΔ� �2� �� �

:

ð25Þ

The log-likelihood for Λ k⁎ is

logΛ⁎k = ∑

k

l=1− 1

2σ2x

−μ2x + 2Xl + 1μx−2μxμJpe

−αΔ+ μ2x−2Xl + 1μx + 2μxμJpe

−αΔ� �� �

:

ð26Þ

We substitute the processes of the Markov chain z into this log-likelihood and get

log Λ⁎k = ∑

n

i=1− 1

2σ2xi

μ2xiOik−2Ti

k Xk + 1

μ xi+ 2Oi

k μ xiμJi pe

−αiΔ + R μxð Þh i" #

ð27Þ

where R(μx) is a remainder without µ. Now, the conditionalexpectation of the log-likelihood L(µXi

)=E[logΛ k|F kX] is considered.

For any process H write Ĥl=E[Hl|F kX].

L μxi

� �= ∑

n

i=1− 1

2σ2xi

Oik μ

2xi−2T i

k Xk + 1

μxi+ 2Oi

k μxiμJi pe

−αiΔ + R μxð Þh i" #

:

ð28Þ

We differentiate L(µXj) in µXj

and equate the result to 0. This gives

2Oik μxi

−2T ik Xk + 1

+ 2OikμJi pe

−αiΔ = 0

or μxi=

T ik Xk + 1

−OikμJi pe

−αiΔ

Oik

:

ð29Þ

References

Benth, F.E., Šaltytė-Benth, J., 2005. Stochastic temperature modelling and weatherderivatives. Applied Mathematical Finance 12, 53–85.

Benth, F.E., Ekeland, L., Hauge, R., Nielsen, B.F., 2003. A note on arbitrage-free pricing offorward contracts in energy markets. Applied Mathematical Finance 10, 325–336.

Cartea, Á., Figueroa, M.G., 2005. Pricing in electricity markets: a mean reverting jumpdiffusion model with seasonality. Applied Mathematical Finance 12, 313–335.

Chen, H., Jiang, J.N., 2006. Empirical electricity price modelling. Energy Risk 74–79.

1043C. Erlwein et al. / Energy Economics 32 (2010) 1034–1043

Conejo, A.J., Plazas, M.A., Espinola, R., Molina, A.B., 2005. Day-ahead electricity priceforecasting using the wavelet transform and ARIMA models. IEEE Transactions onPower Systems 20, 1035–1042.

Culot M., Goffin V., Lawford S., de Menten S. and Smeers Y. An affine jump diffusionmodel for electricity. Working paper, Catholic University of Leuwen; 2006.

de Jong, C., 2006. The nature of power spikes: a regime-switch approach. Studies inNonlinear Dynamics & Econometrics 10.

de Jong, C., Huisman, R., 2002. Option Formulas for Mean-Reverting Power Prices withSpikes. Erasmus Research Institute of Management (ERIM), Erasmus UniversityRotterdam.

Deng, S., 2000. Stochastic Models of Energy Commodity Prices and Their Applications:Mean-reversion with Jumps and Spikes. University of California Energy Institute.

Elliott, R.J., 1994. Exact adaptive filters for Markov chains observed in Gaussian noise.Automatica 30, 1399–1408.

Elliott, R.J., Aggoun, L., Moore, J.B., 1995. Hidden Markov Models: Estimation andControl. Springer, New York.

Elliott R.J., Sick G.A. and Stein M. Modelling Electricity Price Risk. Preprint, University ofCalgary; 2003.

Fabra, N., Toro, J., 2005. Price wars and collusion in the Spanish electricity market.International Journal of Industrial Organization 23, 155–181.

Geman, H., Roncoroni, A., 2006. Understanding the fine structure of electricity prices.Journal of Business 79, 1225–1262.

González, A.M., San Roque, A.M., García-González, J., 2005. Modeling and forecastingelectricity prices with input/output hidden Markov models. IEEE Transactions onPower Systems 20, 13–24.

Hanson, F.B., Westman, J.J., 2002. Stochastic analysis of jump-diffusions for financiallog-return processes. In: Parsik-Duncan, B. (Ed.), Stochastic Theory and Control,LNCIS 280. Berlin, Springer, pp. 169–183.

Huisman, R., Mahieu, R., 2003. Regime jumps in electricity prices. Energy Economics 25,425–434.

Kluge T. Pricing swing options and other electricity derivatives. PhD thesis, Universityof Oxford; 2006.

Lucia, J.J., Schwartz, E.S., 2002. Electricity prices and power derivatives: evidence fromthe Nordic power exchange. Review of Derivatives Research 5, 5–50.

Pilipović, D., 1998. Energy Risk — Valuing and Managing Energy Derivatives. McGraw-Hill, New York.

Rambharat, R., Brockwell, A., Seppi, D., 2005. A threshold autoregressive model forwholesale electricity prices. Journal of the Royal Statistical Society, Series C 54,2087–2299.

Weron, R., Simonsen, I., Wilman, P., 2004. Modeling highly volatile and seasonalmarkets: evidence from the Nord Pool electricity market. In: Takayasu, H. (Ed.), TheApplication of Econophysics. Tokyo, Springer, pp. 182–192.

Yu, W., Sheblé, G.B., 2006. Modeling electricity markets with hidden Markov model.Electric Power Systems Research 76, 445–451.