Вы находитесь на странице: 1из 18

Time Series Forecasting Using Exponential

Smoothing (continued)
Victor | 29 February, 2012 | Views: 6862 | English
Introduction
The article "Tie !eries Forecasting "sing E#$onential !oothing" %1& ga'e a brie( suary
o( e#$onential soothing o)els, illustrate) one o( the $ossible a$$roaches to o$tii*ing
the o)el $araeters an) ultiately $ro$ose) the (orecast in)icator )e'elo$e) on the basis
o( the linear growth o)el with )a$ing+ This article re$resents an atte$t to soewhat
increase the accuracy o( this (orecast in)icator+
,t is co$licate) to $re)ict currency -uotes or to get a (airly reliable (orecast e'en (or three
or (our ste$s ahea)+ .e'ertheless, as in the $re'ious article o( this series, we will $ro)uce
12/ste$/ahea) (orecasts, clearly reali*ing that it will be i$ossible to get satis(actory results
o'er such a long hori*on+ The 0rst (ew ste$s o( the (orecast with the narrowest con0)ence
inter'als shoul) there(ore be gi'en (oreost attention to+
1 10/ to 12/ste$/ahea) (orecast is inten)e) ainly (or )eonstration o( beha'ioral (eatures
o( )i2erent o)els an) (orecasting etho)s+ ,n any case, the accuracy o( the obtaine)
(orecast (or any hori*on can be assesse) using the con0)ence inter'al liits+ This article is
essentially aie) at )eonstration o( soe etho)s that can hel$ to u$gra)e the in)icator
as set (orth in the article %1&+
The algorith (or 0n)ing the iniu o( a (unction o( se'eral 'ariables that is a$$lie) in
)e'elo$ing the in)icators was )ealt with in the $re'ious article an) will there(ore not be
re$eate)ly )escribe) here+ .ot to o'erloa) the article, theoretical in$uts will be 3e$t to the
iniu+

1. Initial Indicator
The ,n)icatorE!+-4 in)icator 5see article %1&6 will be use) as a starting $oint+
For co$ilation o( the in)icator we will nee) ,n)icatorE!+-4, 7,n)icatorE!+-h an)
8owells9etho)+-h, all locate) in the sae )irectory+ The 0les can be (oun) in the 0les2+*i$
archi'e at the en) o( the article+
:et us re(resh the e-uations that )e0ne the e#$onential soothing o)el use) in
)e'elo$ing this in)icator / the linear growth o)el with )a$ing+
;here:
/ soothing $araeter (or the le'el o( the se-uence %0,1&<
/ soothing $araeter (or the tren) %0,1&<
/ )a$ing $araeter %0,1&<
/ soothe) le'el o( the se-uence calculate) at the tie t a(ter has been
obser'e)<
/ soothe) a))iti'e tren) calculate) at the tie t<
/ 'alue o( the se-uence at the tie t<
/ nuber o( ste$s ahea) (or which the (orecast is a)e<
/ /ste$/ahea) (orecast a)e at the tie t<
/ one/ste$/ahea) (orecast error at the tie t, +
The only in$ut $araeter o( the in)icator is the 'alue )eterining the length o( the inter'al
accor)ing to which the o)el $araeters will be o$tii*e) an) the initial 'alues 5stu)y
inter'al6 selecte)+ Following the )eterination o( the o$tial 'alues o( the o)el
$araeters at a gi'en inter'al an) the re-uire) calculations, the (orecast, con0)ence
inter'al an) the line corres$on)ing to the one/ste$/ahea) (orecast are $ro)uce)+ 1t e'ery
new bar, the $araeters are o$tii*e) an) the (orecast is a)e+
!ince the in)icator in -uestion is going to be u$gra)e), the e2ect o( the changes we will
a3e will be assesse) using the test se-uences (ro the Files2+*i$ archi'e locate) at the
en) o( the article+ The archi'e )irectory =>ataset2 contains 0les with the sa'e) E"?"!>,
"!>7@F, "!>A8B -uotes an) "+!+ >ollar ,n)e# >CB+ Each o( those is $ro'i)e) (or three tie
(raes, being 91, @1 an) >1+ The "o$en" 'alues sa'e) in the 0les are locate) so that the
ost recent 'alue is at the en) o( the 0le+ Each 0le contains 1200 eleents+
Forecast errors will be estiate) by calculating the "9ean 1bsolute 8ercentage Error"
5918E6 coeDcient
:et us )i'i)e each o( the twel'e test se-uences into 40 o'erla$$ing sections containing 80
eleents each an) calculate the 918E 'alue (or each one o( the+ The ean o( the
estiates so obtaine) will be use) as a (orecast error in)e# with regar) to the in)icators $ut
into co$arison+ 918E 'alues (or two/ an) three/ste$/ahea) (orecast errors will be
calculate) in the sae anner+ !uch a'erage) estiates will be (urther )enote) as (ollows:
918E1 E a'erage) estiate o( the one/ste$/ahea) (orecast error<
918E2 E a'erage) estiate o( the two/ste$/ahea) (orecast error<
918EF E a'erage) estiate o( the three/ste$/ahea) (orecast error<
918E1/F E ean 5918E1G918E2G918EF6HF+
;hen calculating the 918E 'alue, the absolute (orecast error 'alue is at e'ery ste$ )i'i)e)
by the current 'alue o( the se-uence+ ,n or)er to a'oi) )i'ision by *ero or obtaining negati'e
'alues in so )oing, the in$ut se-uences are re-uire) to ta3e only non*ero $ositi'e 'alues, as
in our case+
The estiate 'alues (or our initial in)icator are shown in Table 1+
MAPE1 MAPE MAPE! MAPE1"!
,n)icatorE! 0+2099 0+2924 0+F46I 0+286F
Table 1+ ,nitial in)icator (orecast error estiates
The )ata )is$laye) in Table 1 is obtaine) using the ErrorsJ,n)icatorE!+-4 scri$t 5(ro the
0les2+*i$ archi'e locate) at the en) o( the article6+ To co$ile an) run the scri$t, it is
necessary that 7,n)icatorE!+-h an) 8owells9etho)+-h are locate) in the sae )irectory
as ErrorsJ,n)icatorE!+-4, an) the in$ut se-uences are in Files=>ataset2= )irectory+
1(ter obtaining the initial estiates o( the (orecast errors, we can now $rocee) to u$gra)ing
the in)icator un)er consi)eration+
. #ptimi$ation %riterion
The o)el $araeters in the initial in)icator as set (orth in the article "Tie !eries
Forecasting "sing E#$onential !oothing" were )eterine) by inii*ing the su o(
s-uares o( the one/ste$/ahea) (orecast error+ ,t a$$ears logical that the o)el $araeters
o$tial (or a one/ste$/ahea) (orecast ay not yiel) iniu errors (or a ore/ste$/ahea)
(orecast+ ,t woul), o( course, be )esirable to inii*e 10/ to 12/ste$/ahea) (orecast errors,
but getting a satis(actory (orecast result o'er the gi'en range (or the se-uences un)er
consi)eration woul) be a ission i$ossible+
Keing realistic, when o$tii*ing the o)el $araeters, we will use the su o( s-uares o( the
one/, two/ an) three/ste$/ahea) (orecast errors as the 0rst u$gra)e o( our in)icator+ The
a'erage nuber o( errors ay be e#$ecte) to soewhat )ecrease o'er the range o( the 0rst
three ste$s o( the (orecast+
7learly, such u$gra)e o( the initial in)icator )oes not concern its ain structural $rinci$les
but only changes the $araeter o$tii*ation criterion+ There(ore we cannot e#$ect the
(orecast accuracy to increase se'eral/(ol) although the nuber o( two/ an) three/ste$/
ahea) (orecast errors shoul) )ro$ a little+
,n or)er to co$are the (orecast results, we create) the 79o)1 class siilar to the
7,n)icatorE! class intro)uce) in the $re'ious article with the o)i0e) obLecti'e (unction
(unc+
The (unc (unction o( the initial 7,n)icatorE! class:
double CIndicatorES::func(const double &p[])
{
int i;
double s,t,alp,gam,pi,!",!#,!$,e,sse,ae,pt;

s%p[&]; t%p["]; alp%p[#]; gam%p[$]; pi%p[']; !"%"; !#%"; !$%";
if (alp(&)*+){!",%(alp-&)*+).#&&; alp%&)*+;/ 00 1lpa ( &)*+
else if(alp2&)&+){!",%(&)&+-alp).#&&; alp%&)&+;/ 00 1lpa 2 &)&+
if (gam(&)*+){!#,%(gam-&)*+).#&&; gam%&)*+;/ 00 3amma ( &)*+
else if(gam2&)&+){!#,%(&)&+-gam).#&&; gam%&)&+;/ 00 3amma 2 &)&+
if (pi(")& ){!$,%(pi-")& ).#&&; pi%")&; / 00 4i ( ")&
else if(pi2&)&+){!$,%(&)&+-pi).#&&; pi%&)&+;/ 00 4i 2 &)&+
sse%&;
for(i%&;i25len;i,,)
{
e%5at[i]-(s,pi.t); sse,%e.e;
ae%alp.e; pt%pi.t; s%s,pt,ae; t%pt,gam.ae;
/
return(5len.6at7og(!".!#.!$.sse));
/
Following soe o)i0cations, the (unc (unction now a$$ears as (ollows
double C6od"::func(const double &p[])
{
int i;
double s,t,alp,gam,pi,!",!#,!$,e,err,ae,pt,pi#,pi$,a;

s%p[&]; t%p["]; alp%p[#]; gam%p[$]; pi%p[']; !"%"; !#%"; !$%";
if (alp(&)*+){!",%(alp-&)*+).#&&; alp%&)*+; 00 1lpa ( &)*+
else if(alp2&)&+){!",%(&)&+-alp).#&&; alp%&)&+;/ 00 1lpa 2 &)&+
if (gam(&)*+){!#,%(gam-&)*+).#&&; gam%&)*+;/ 00 3amma ( &)*+
else if(gam2&)&+){!#,%(&)&+-gam).#&&; gam%&)&+;/ 00 3amma 2 &)&+
if (pi(")& ){!$,%(pi-")& ).#&&; pi%")&; / 00 4i ( ")&
else if(pi2&)&+){!$,%(&)&+-pi).#&&; pi%&)&+;/ 00 4i 2 &)&+
pi#%pi,pi.pi; pi$%pi#,pi.pi.pi;
err%&;
for(i%&;i25len-#;i,,)
{
e%5at[i]-(s,pi.t); err,%e.e;
a%5at[i,"]-(s,pi#.t); err,%a.a;
a%5at[i,#]-(s,pi$.t); err,%a.a;
ae%alp.e; pt%pi.t; s%s,pt,ae; t%pt,gam.ae;
/
e%5at[5len-#]-(s,pi.t); err,%e.e;
a%5at[5len-"]-(s,pi#.t); err,%a.a;
ae%alp.e; pt%pi.t; s%s,pt,ae; t%pt,gam.ae;
a%5at[5len-"]-(s,pi.t); err,%a.a;
return(!".!#.!$.err);
/
.ow, when calculating the obLecti'e (unction, the su o( s-uares o( the one/, two/ an)
three/ste$/ahea) (orecast errors is use)+
Further, base) on this class the ErrorsJ9o)1+-4 scri$t was )e'elo$e) allowing to estiate
the (orecast errors, li3e the alrea)y entione) ErrorsJ,n)icatorE!+-4 scri$t )oes+
79o)1+-h an) ErrorsJ9o)1+-4 are locate) in the 0les2+*i$ archi'e at the en) o( the
article+
Table 2 )is$lays the (orecast error estiates (or the initial an) u$gra)e) 'ersions+
MAPE1 MAPE MAPE! MAPE1"!
,n)icatorE! 0+2099 0+2924 0+F46I 0+286F
9o)1 0+21II 0+2898 0+FI86 0+28I2
Table 2+ 7o$arison o( the (orecast error estiates
1s can be seen, the error coeDcients 918E2 an) 918EF an) the ean 'alue 918E1/F
actually )i) turn out to be slightly lower (or the se-uences un)er consi)eration+ !o let us
sa'e this 'ersion an) $rocee) to (urther o)i0cation o( our in)icator+
!. Ad&ustment o' Parameters in the Smoothing Process
The i)ea o( changing the soothing $araeters )e$en)ing on the current 'alues o( the
in$ut se-uence is not new or original an) coes (ro the wish to a)Lust the soothing
coeDcients so that they reain o$tial gi'en any change in the nature o( the in$ut
se-uence+ !oe ways o( a)Lusting the soothing coeDcients are )escribe) in the literature
%2&, %F&+
To (urther u$gra)e the in)icator, we will use the o)el with )ynaically changing
soothing coeDcient e#$ecting that the use o( the a)a$ti'e e#$onential soothing o)el
will allow us to increase the (orecast accuracy o( our in)icator+
"n(ortunately, when use) in (orecasting algoriths, the aLority o( a)a$ti'e etho)s )o not
always yiel) the )esire) results+ !election o( the a)e-uate a)a$ti'e etho) ay a$$ear to
be too cubersoe an) tie/consuing< there(ore in our case we will a3e use o( the
0n)ings $ro'i)e) in the literature %I& an) try to e$loy "!ooth Transition E#$onential
!oothing" 5!TE!6 a$$roach set (orth in the article %4&+
The essence o( the a$$roach is clearly outline) in the s$eci0e) article, so we will lea'e it out
here an) $rocee) )irectly to the e-uations (or our o)el 5see the beginning o( the s$eci0e)
article6 ta3ing into consi)eration the use o( the a)a$ti'e soothing coeDcient+

1s we can now see, the 'alue o( the soothing coeDcient al$ha is calculate) at e'ery ste$
o( the algorith an) )e$en)s on the s-uare) (orecast error+ Values o( b an) g coeDcients
)eterine the e2ect o( the (orecast error on the al$ha 'alue+ ,n all other res$ects, the
e-uations (or the e$loye) o)el reaine) unchange)+ 1))itional in(oration regar)ing
the use o( !TE! a$$roach can be (oun) in the article %6&+
;hereas in the $re'ious 'ersions, we ha) to )eterine the o$tial 'alue o( the al$ha
coeDcient o'er the gi'en in$ut se-uence, there are now two a)a$ti'e coeDcients b an) g
that are subLect to o$tii*ation an) the al$ha 'alue will be )ynaically )eterine) in the
$rocess o( soothing the in$ut se-uence+
This u$gra)e is i$leente) in the (or o( the 79o)2 class+ The aLor changes 5as the
$re'ious tie6 $riarily concerne) the (unc (unction which now a$$ears as (ollows+
double C6od#::func(const double &p[])
{
int i;
double s,t,alp,gam,pi,sb,sg,!",!#,e,err,ae,pt,pi#,pi$,a;

s%p[&]; t%p["]; gam%p[#]; pi%p[$]; sb%p[']; sg%p[+]; !"%"; !#%";
if (gam(&)*+){!",%(gam-&)*+).#&&; gam%&)*+;/ 00 3amma ( &)*+
else if(gam2&)&+){!",%(&)&+-gam).#&&; gam%&)&+;/ 00 3amma 2 &)&+
if (pi(")& ){!#,%(pi-")& ).#&&; pi%")&; / 00 4i ( ")&
else if(pi2&)&+){!#,%(&)&+-pi).#&&; pi%&)&+;/ 00 4i 2 &)&+
pi#%pi,pi.pi; pi$%pi#,pi.pi.pi;
err%&;
for(i%&;i25len-#;i,,)
{
e%5at[i]-(s,pi.t); err,%e.e;
a%5at[i,"]-(s,pi#.t); err,%a.a;
a%5at[i,#]-(s,pi$.t); err,%a.a;
alp%&)&+,&)*0(",6atE8p(sb,sg.e.e)); 00 &)&+ 2 1lpa 2 &)*+
ae%alp.e; pt%pi.t; s%s,pt,ae; t%pt,gam.ae;
/
e%5at[5len-#]-(s,pi.t); err,%e.e;
a%5at[5len-"]-(s,pi#.t); err,%a.a;
alp%&)&+,&)*0(",6atE8p(sb,sg.e.e)); 00 &)&+ 2 1lpa 2 &)*+
ae%alp.e; pt%pi.t; s%s,pt,ae; t%pt,gam.ae;
a%5at[5len-"]-(s,pi.t); err,%a.a;
return(!".!#.err);
/
;hen )e'elo$ing this (unction, the e-uation )e0ning the al$ha coeDcient 'alue was slightly
o)i0e)+ This was )one to set the liit o( the a#iu an) iniu $erissible 'alue o(
this coeDcient at 0+04 an) 0+94, res$ecti'ely+
To estiate the (orecast errors, as it was $re'iously )one, the ErrorsJ9o)2+-4 scri$t was
written base) on the 79o)2 class+ 79o)2+-h an) ErrorsJ9o)2+-4 are locate) in the
0les2+*i$ archi'e at the en) o( the article+
The scri$t results are shown in Table F+
MAPE1 MAPE MAPE! MAPE1"!
,n)icatorE! 0+2099 0+2924 0+F46I 0+286F
9o)1 0+21II 0+2898 0+FI86 0+28I2
9o)2 0+21I4 0+28F2 0+FI1F 0+2M9M
Table F+ 7o$arison o( the (orecast error estiates
1s Table F suggests, the use o( the a)a$ti'e soothing coeDcient has on the a'erage
allowe) to (urther slightly )ecrease the (orecast errors (or our test se-uences+ Thus,
(ollowing two u$gra)es, we anage) to )ecrease the error coeDcient 918E1/F by
a$$ro#iately two $ercent+
>es$ite a rather o)est u$gra)e result, we will stic3 with the resulting 'ersion an) lea'e
(urther u$gra)es out o( the sco$e o( the article+ 1s a ne#t ste$, it woul) be interesting to try
using the Ko#/7o# trans(oration+ This trans(oration is ostly use) to a$$ro#iate the
initial se-uence )istribution to the noral )istribution+
,n our case, it coul) be utili*e) to trans(or the initial se-uence, co$ute the (orecast an)
to in'erse/trans(or the (orecast+ The trans(oration coeDcient a$$lie) in so )oing shoul)
be selecte) so that the resulting (orecast error is inii*e)+ 1n e#a$le o( using the Ko#/
7o# trans(oration in (orecasting se-uences can be (oun) in the article %M&+
(. Forecast %on)dence Inter*al
The (orecast con0)ence inter'al in the initial ,n)icatorE!+-4 in)icator 5set (orth in the
$re'ious article6 was calculate) accor)ing to the analytical e#$ressions )eri'e) (or the
selecte) e#$onential soothing o)el %8&+ The changes a)e in our case ha'e lea) to
changes in the o)el un)er consi)eration+ The 'ariable soothing coeDcient a3es it
ina$$ro$riate to use the abo'e entione) analytical e#$ressions (or estiation o( the
con0)ence inter'al+
The (act that the $re'iously use) analytical e#$ressions were )eri'e) base) on the
assu$tion that the (orecast error )istribution is syetric an) noral ay constitute an
a))itional reason (or changing the con0)ence inter'al estiation etho)+ These
re-uireents are not et (or our class o( se-uences an) the (orecast error )istribution ay
not be noral nor syetric+
;hen estiating the con0)ence inter'al in the initial in)icator, the one/ste$/ahea) (orecast
error 'ariance was calculate) in the 0rst $lace (ro the in$ut se-uence, (ollowe) by the
calculation o( the 'ariance (or a two/, three/ an) ore/ste$/ahea) (orecast on the basis o(
the obtaine) one/ste$/ahea) (orecast error 'ariance 'alue using the analytical e#$ressions+
,n or)er to a'oi) the use o( analytical e#$ressions, there is a si$le way out whereby the
'ariance (or a two/, three/ an) ore/ste$/ahea) (orecast is calculate) )irectly (ro the in$ut
se-uence as well as the 'ariance (or a one/ste$/ahea) (orecast+ @owe'er, this a$$roach has
a signi0cant )rawbac3: in short in$ut se-uences, the con0)ence inter'al estiates will be
wi)ely scattere) an) the calculation o( 'ariance an) ean s-uare) error will not allow to
relie'e constraints on the e#$ecte) norality o( errors+
1 solution in this case can be (oun) in the use o( non$araetric bootstra$ 5resa$ling6 %9&+
The bac3bone o( the i)ea e#$resse) si$ly: when sa$ling in a ran)o way 5uni(or
)istribution6 with re$laceent (ro the initial se-uence, the )istribution o( the so generate)
arti0cial se-uence will be the sae as that o( the initial one+
1ssue, we ha'e an in$ut se-uence o( . ebers< by generating a uni(orly )istribute)
$seu)o/ran)o se-uence o'er the range o( %0,./1& an) using these 'alues as in)ices when
sa$ling (ro the initial array, we can generate an arti0cial se-uence o( a substantially
greater length than the initial one+ That sai), the )istribution o( the generate) se-uence will
be the sae 5alost the sae6 as that o( the initial one+
The bootstra$ $roce)ure (or estiation o( the con0)ence inter'als can be as (ollows:
1+ >eterine the o$tial initial 'alues o( the o)el $araeters, its coeDcients an)
a)a$ti'e coeDcients (ro the in$ut se-uence (or the e#$onential soothing o)el
obtaine) as a result o( o)i0cation+ The o$tial $araeters are, as be(ore,
)eterine) using the algorith that e$loys 8owellNs search etho)<
2+ "sing the )eterine) o$tial o)el $araeters, "go" through the initial se-uence
an) (or an array o( one/ste$/ahea) (orecast errors+ The nuber o( the array
eleents will be e-ual to the in$ut se-uence length .<
F+ 1lign the errors by subtracting (ro each eleent o( the error array the ean 'alue
thereo(<
I+ "sing the $seu)o/ran)o se-uence generator, generate in)ices within the range o(
%0,./1& an) use the to (or an arti0cial se-uence o( errors being 9999 eleents
long 5resa$ling6<
4+ For an array containing 9999 'alues o( the $seu)o/in$ut se-uence by inserting the
'alues (ro the arti0cially generate) error array into the e-uations that )e0ne the
o)el currently use)+ ,n other wor)s, whereas we $re'iously ha) to insert the in$ut
se-uence 'alues into the o)el e-uations thus calculating the (orecast error, now
the in'erse calculations are a)e+ For each eleent o( the array, the error 'alue is
inserte) to calculate the in$ut 'alue+ 1s a result, we get the array o( 9999 eleents
containing the se-uence with the sae )istribution as the in$ut se-uence while
being o( suDcient length to )irectly estiate the (orecast con0)ence inter'als+
Then estiate the con0)ence inter'als using the generate) se-uence o( a)e-uate length+
For this $ur$ose, we will e#$loit the (act that i( the generate) (orecast error array is sorte) in
ascen)ing or)er, the array cells with in)ices 2I9 an) 9MI9 (or the array containing 9999
'alues will ha'e the 'alues corres$on)ing to the liits o( the 94O con0)ence inter'al %10&+
,n or)er to get a ore accurate estiation o( the $re)iction inter'als, the array length shall
be o))+ ,n our case, the liits o( the (orecast con0)ence inter'als are estiate) as (ollows:
1+ "sing the o$tial o)el $araeters as )eterine) earlier, "go" through the
generate) se-uence an) (or an array o( 9999 one/ste$/ahea) (orecast errors<
2+ !ort the resulting array<
F+ Fro the sorte) error array, select 'alues with in)ices 2I9 an) 9MI9 which re$resent
the liits o( the 94O con0)ence inter'al<
I+ ?e$eat ste$s 1, 2 an) F (or two/, three/ an) ore/ste$/ahea) (orecast errors+
This a$$roach to estiating the con0)ence inter'als has its a)'antages an) )isa)'antages+
1ong its a)'antages is the absence o( assu$tions regar)ing the nature o( the )istribution
o( the (orecast errors+ They )o not ha'e to be norally or syetrically )istribute)+ Kesi)es,
this a$$roach ay be use(ul where it is i$ossible to )eri'e analytical e#$ressions (or the
o)el in use+
1 )raatic increase in the re-uire) sco$e o( calculations an) )e$en)ence o( the estiates
on the -uality o( the $seu)o/ran)o se-uence generator use) can be consi)ere) its
)isa)'antages+
The $ro$ose) a$$roach to estiating the con0)ence inter'als using resa$ling an)
-uantiles is rather $riiti'e an) there ust be ways to i$ro'e it+ Kut since the con0)ence
inter'als in our case are only inten)e) (or 'isual assessent, the accuracy $ro'i)e) by the
abo'e a$$roach ay a$$ear to be -uite suDcient+

+. Modi)ed ,ersion o' the Indicator
Ta3ing into account the u$gra)es intro)uce) in the article, the ForecastE!+-4 in)icator was
)e'elo$e)+ For resa$ling, we use) the $seu)o/ran)o se-uence generator $ro$ose)
earlier in the article %11&+ The stan)ar) 9ath?an)56 generator yiel)e) slightly $oorer results,
$robably )ue to the (act that the range o( 'alues it generate) %0,F2M6M& was not wi)e
enough+
;hen co$iling the ForecastE!+-4 in)icator, 8owells9etho)+-h, 7ForeE!+-h an)
?.>Cor128+-h shall be locate) in the sae )irectory with it+ 1ll these 0les can be (oun) in
the (ore+*i$ archi'e+
Kelow is the source co)e o( the ForecastE!+-4 in)icator+
00,------------------------------------------------------------------,
009 :orecastES)m;+ 9
009 Cop<rigt #&"#, =ictorg 9
009 ttp:00>>>)m;l+)com 9
00,------------------------------------------------------------------,
?propert< cop<rigt @#&"#, =ictorg)@
?propert< lin! @ttp:00>>>)m;l+)com@
?propert< =ersion @")&#@
?propert< description @:orecasting based on te e8ponential smooting)@
?propert< indicatorAcartA>indo>
?propert< indicatorAbuffers '
?propert< indicatorAplots '
?propert< indicatorAlabel" @Bistor<@
?propert< indicatorAt<pe" 5C1DA7IEE
?propert< indicatorAcolor" clr5odgerFlue
?propert< indicatorAst<le" SGH7EASI7I5
?propert< indicatorA>idt" "
?propert< indicatorAlabel# @:orecast@ 00 :orecast
?propert< indicatorAt<pe# 5C1DA7IEE
?propert< indicatorAcolor# clr5ar!Irange
?propert< indicatorAst<le# SGH7EASI7I5
?propert< indicatorA>idt# "
?propert< indicatorAlabel$ @ConfJp@ 00 Confidence inter=al
?propert< indicatorAt<pe$ 5C1DA7IEE
?propert< indicatorAcolor$ clrCrimson
?propert< indicatorAst<le$ SGH7EA5IG
?propert< indicatorA>idt$ "
?propert< indicatorAlabel' @Conf5n@ 00 Confidence inter=al
?propert< indicatorAt<pe' 5C1DA7IEE
?propert< indicatorAcolor' clrCrimson
?propert< indicatorAst<le' SGH7EA5IG
?propert< indicatorA>idt' "
input int nBist%K&; 00 Bistor< bars, nBist(%#'
?include @C:oreES)m;@
?include @CE5Lor"#K)m;@
?define E:ICE "#
?define EFIIG ****
double Bist[],:ore[],Conf"[],Conf#[];
double 5ata[],Err[],FS5at[],5amp[E:ICE],FSErr[EFIIG];
int E5at;
C:oreES Es;
CE5Lor"#K Cnd;
00,------------------------------------------------------------------,
009 Custom indicator initialiMation function 9
00,------------------------------------------------------------------,
int InInit()
{
E5at%nBist; if(E5at2#')E5at%#';
6;lCates rates[];
Cop<Cates(EJ77,&,&,E5at,rates); 00 7oad missing data
1rra<CesiMe(5ata,E5at);
1rra<CesiMe(Err,E5at);
1rra<CesiMe(FS5at,EFIIG,E:ICE);
SetInde8Fuffer(&,Bist,IE5IC1GICA51G1);
4lotInde8SetString(&,47IGA71FE7,@Bistor<@);
SetInde8Fuffer(",:ore,IE5IC1GICA51G1);
4lotInde8SetString(",47IGA71FE7,@:orecast@);
4lotInde8SetInteger(",47IGASBI:G,E:ICE);
SetInde8Fuffer(#,Conf",IE5IC1GICA51G1); 00 Confidence inter=al
4lotInde8SetString(#,47IGA71FE7,@ConfJp@);
4lotInde8SetInteger(#,47IGASBI:G,E:ICE);
SetInde8Fuffer($,Conf#,IE5IC1GICA51G1); 00 Confidence inter=al
4lotInde8SetString($,47IGA71FE7,@Conf5E@);
4lotInde8SetInteger($,47IGASBI:G,E:ICE);
IndicatorSetInteger(IE5IC1GICA5I3IGS,A5igits);
return(&);
/
00,------------------------------------------------------------------,
009 Custom indicator iteration function 9
00,------------------------------------------------------------------,
int InCalculate(const int ratesAtotal,
const int pre=Acalculated,
const datetime &time[],
const double &open[],
const double &ig[],
const double &lo>[],
const double &close[],
const long &tic!A=olume[],
const long &=olume[],
const int &spread[])
{
int i,N,!,start;
double s,t,alp,gam,pi,sb,sg,e,f,a,a",a#;
if(ratesAtotal2E5at){4rint(@Error: Eot enoug bars for calculationO@); return(&);/
if(pre=Acalculated%%ratesAtotal)return(ratesAtotal); 00 Ee> tic! but not ne> bar
start%ratesAtotal-E5at;
00-----------------------
4lotInde8SetInteger(&,47IGA5C1DAFE3IE,ratesAtotal-E5at);
4lotInde8SetInteger(",47IGA5C1DAFE3IE,ratesAtotal-E:ICE);
4lotInde8SetInteger(#,47IGA5C1DAFE3IE,ratesAtotal-E:ICE);
4lotInde8SetInteger($,47IGA5C1DAFE3IE,ratesAtotal-E:ICE);
for(i%&;i2E5at;i,,)5ata[i]%open[ratesAtotal-E5at,i]; 00 Input data
Es)Calc4ar(5ata); 00 IptimiMation of parameters
s%Es)3et4ar(&); t%Es)3et4ar("); gam%Es)3et4ar(#);
pi%Es)3et4ar($); sb%Es)3et4ar('); sg%Es)3et4ar(+);
00----
a%pi; 5amp[&]%pi;
for(N%";N2E:ICE;N,,){a%a.pi; 5amp[N]%5amp[N-"],a;/ 00 4i table
00----
f%s,pi.t;
for(i%&;i2E5at;i,,) 00 Bistor<
{
e%5ata[i]-f; Err[i]%e;
alp%&)&+,&)*0(",6atE8p(sb,sg.e.e)); 00 &)&+ 2 1lpa 2 &)*+
a"%alp.e; a#%pi.t; s%s,a#,a"; t%a#,gam.a";
f%(s,pi.t); Bist[start,i]%f; 00 Bistor<
/
for(N%&;N2E:ICE;N,,):ore[ratesAtotal-E:ICE,N]%s,5amp[N].t; 00 :orecast
00----
a%&;
for(i%&;i2E5at;i,,)a,%Err[i];
a0%E5at;
for(i%&;i2E5at;i,,)Err[i]-%a; 00 alignment of te arra< of
errors
00----
f%Es)3et4ar(&),pi.Es)3et4ar(");
for(i%&;i2EFIIG,E:ICE;i,,) 00 Cesampling
{
N%(int)(E5at.Cnd)CandA&"());
if(N(E5at-")N%E5at-";
e%Err[N];
FS5at[i]%f,e;
alp%&)&+,&)*0(",6atE8p(sb,sg.e.e)); 00 &)&+ 2 1lpa 2 &)*+
a"%alp.e; a#%pi.t; s%s,a#,a"; t%a#,gam.a";
f%s,pi.t;
/
00----
for(N%&;N2E:ICE;N,,) 00 4rediction inter=als
{
s%Es)3et4ar(&); t%Es)3et4ar(");
f%s,pi.t;
for(i%&,!%&;i2EFIIG;i,,,!,,)
{
FSErr[i]%FS5at[i,N]-(s,5amp[N].t);
e%FS5at[i]-f;
a"%alp.e; a#%pi.t; s%s,a#,a"; t%a#,gam.a";
f%(s,pi.t);
/
1rra<Sort(FSErr);
Conf"[ratesAtotal-E:ICE,N]%:ore[ratesAtotal-E:ICE,N],FSErr[#'*];
Conf#[ratesAtotal-E:ICE,N]%:ore[ratesAtotal-E:ICE,N],FSErr[*P'*];
/
return(ratesAtotal);
/
00-----------------------------------------------------------------------------------
For better )eonstration $ur$oses, the in)icator was e#ecute), to the e#tent $ossible, as a
straight/line co)e+ .o o$tii*ation was inten)e) while co)ing it+
Figures 1 an) 2 )eonstrate the o$eration results o( the in)icator (or two )i2erent cases+
Figure 1+ First o$eration e#a$le o( the ForecastE!+-4 in)icator

Figure 2+ !econ) o$eration e#a$le o( the ForecastE!+-4 in)icator
Figure 2 clearly shows that the 94O (orecast con0)ence inter'al is asyetric+ This is )ue
to the (act that the in$ut se-uence contains consi)erable outliers that resulte) in
asyetric )istribution o( the (orecast errors+
;ebsites www+-lI+co an) www+-l4+co earlier $ro'i)e) e#tra$olator in)icators + :et us
ta3e one o( those / arJe#tra$olatorJo(J$rice+-4 an) set its $araeter 'alues as shown in
Figure F to co$are its results with the results obtaine) using the in)icator we )e'elo$e)+
Figure F+ !ettings o( the arJe#tra$olatorJo(J$rice+-4 in)icator
The o$eration o( these two in)icators was co$are) 'isually on )i2erent tie (raes (or
E"?"!> an) "!>7@F+ Pn the sur(ace, it sees that the )irection o( the (orecast by both
in)icators coinci)es in the aLority o( cases+ @owe'er, in longer obser'ations, one ay
coe across serious )i'ergences+ That being sai), arJe#tra$olatorJo(J$rice+-4 will always
$ro)uce a ore bro3en (orecast line+
1n e#a$le o( siultaneous o$eration o( ForecastE!+-4 an) arJe#tra$olatorJo(J$rice+-4
in)icators is shown in Figure I+
Figure I+ 7o$arison o( the (orecast results
The (orecast $ro)uce) by the arJe#tra$olatorJo(J$rice+-4 in)icator is )is$laye) in Figure I
as a soli) orange/re) line+

%onclusion
!uary o( the results $ertaining to this an) the $re'ious article:
E#$onential soothing o)els use) in tie series (orecasting were intro)uce)<
8rograing solutions (or i$leentation o( the o)els were $ro$ose)<
1 -uic3 insight into the issues relate) to selection o( the o$tial initial 'alues an)
o)el $araeters was gi'en<
1 $rograing i$leentation o( the algorith (or 0n)ing the iniu o( a
(unction o( se'eral 'ariables using 8owellNs etho) was $ro'i)e)<
8rograing solutions (or $araeter o$tii*ation o( the (orecasting o)el using the
in$ut se-uence were $ro$ose)<
!oe si$le e#a$les o( u$gra)ing the (orecasting algorith were )eonstrate)<
1 etho) (or estiating (orecast con0)ence inter'als using bootstra$$ing an)
-uantiles was brieQy outline)<
The (orecast in)icator ForecastE!+-4 was )e'elo$e) containing all the etho)s an)
algoriths )escribe) in the articles<
1 (ew lin3s to the articles, aga*ines an) boo3s were gi'en $ertaining to this subLect+
7oncerning the resulting in)icator ForecastE!+-4, it shoul) be note) that the o$tii*ation
algorith e$loying 8owellNs etho) ay in certain cases (ail to )eterine the iniu o(
the obLecti'e (unction with a gi'en accuracy+ This being the case, the a#iu $erissible
nuber o( iterations will be reache) an) a rele'ant essage will a$$ear in the log+ This
situation is howe'er not $rocesse) in any way in the co)e o( the in)icator which is -uite
acce$table (or )eonstration o( the algoriths set (orth in the article+ @owe'er, when it
coes to serious a$$lications, such instances shall be onitore) an) $rocesse) in one way
or another+
To (urther )e'elo$ an) enhance the (orecast in)icator, we coul) suggest using se'eral
)i2erent (orecasting o)els siultaneously at each ste$ with a 'iew to (urther selecting o(
one o( the using e+g+ the 13ai3eNs ,n(oration 7riterion+ Pr in case o( using se'eral o)els
siilar in nature, to calculate the weighte) a'erage 'alue o( their (orecast results+ The
weighting coeDcients in this case can be selecte) )e$en)ing on the (orecast error
coeDcient o( each o)el+
The subLect o( (orecasting tie series is so broa) that un(ortunately these articles ha'e
barely scratche) the sur(ace o( soe o( the $ertaining issues+ ,t is ho$e) that these
$ublications will hel$ to )raw the rea)erNs attention to the issues o( (orecasting an) (uture
wor3s in this area+
-e'erences
1+ "Tie !eries Forecasting "sing E#$onential !oothing"+
2+ Bu+ 8+ :u3ashin+ 1)a$ti'e 9etho)s (or !hort/Ter Forecasting o( Tie !eries:
Te#tboo3+ / R+: Finansy i !tatisti3a, 200F+/I16 $$+
F+ !+V+ Kulashe'+ !tatistics (or Tra)ers+ / R+: So$ania !$utni3 G, 200F+ / 2I4 $$+
I+ E'erette !+ Tar)ner Ar+, E#$onential !oothing: The !tate o( the 1rt E 8art ,,+ Aune F,
2004+
4+ Aaes ;+ Taylor, !ooth Transition E#$onential !oothing+ Aournal o( Forecasting,
200I, Vol+ 2F, $$+ F84/F9I+
6+ Aaes ;+ Taylor, Volatility Forecasting with !ooth Transition E#$onential !oothing+
,nternational Aournal o( Forecasting, 200I, Vol+ 20, $$+ 2MF/286+
M+ 1lysha 9 >e :i'era+ 1utoatic Forecasting with a 9o)i0e) E#$onential !oothing
!tate !$ace Fraewor3+ 28 1$ril 2010, >e$artent o( Econoetrics an) Kusiness
!tatistics, 9onash "ni'ersity, V,7 F800 1ustralia+
8+ ?ob A @yn)an et al+ 8re)iction ,nter'als (or E#$onential !oothing "sing Two .ew
7lasses o( !tate !$ace 9o)els+ F0 Aanuary 200F+
9+ The Uuantile Aournal+ issue .o+ F, !e$teber 200M+
10+ htt$:HHru+wi3i$e)ia+orgHwi3iHVWXYZ[\]
11+ "1nalysis o( the 9ain 7haracteristics o( Tie !eries"+

Вам также может понравиться