You are on page 1of 6

Keep

up with the trend


No,wearenttalkingaboutthelatesttrendintechnologyorfashion;weretalkingabouttrendanalysis fortimeseriesdata!Disappointed?Dontbe,thisisanexcitingandfuntopic.

Putsimply,trendingisthepracticeoffittingacurve(e.g.line,polynomial,exponential,etc.)toyourdata overtime,inanefforttoprojectaforecastandestablishaconfidenceinterval. Howdoesthisrelatetotimeseriesanalysis?Whilethefittingcurveisafunctionoftime,theparameters valuesofthecurvearecalibrated(orfitted)usingthepriorinformationandisthusrelated. Whyshouldwecare?Thetrendisveryoftenused(orabused)intheindustrytomakeaquick(anddirty) forecast.Executivesmightusethetrendingtoolasasanitycheckwhenhe/sheexaminesresultsfrom moreadvancedmodels. Inthispaper,wewillgoovertheNxTrendbuiltinfunctionthatwasfirstintroducedinNumXL1.55 (LYNX)anddemonstrate,throughnumerousexamples,itsuseandtheintuitionbehindit.Wewillfocus onthebacktestingaspectandtheforecastconfidenceinterval.

Background
MicrosoftExcelcomeswithanativeTrendfunction,butitislimitedtolineartrendsanddoesnot generateoutputsotherthanthefittedvalue.TheNxTrendfunctionpushesthetrendapplicationfroma nicelineonagraphtoacomprehensivetrendanalysis. NxTrendsupportsfive(5)differentcurvefunctions:

a+ b t Linear: Polynomial: a+ b t+ b t 2 + ... + b t q 1 2 q bt a e Exponential: Logarithm: a+ b ln(t) a t b Power:


Eachofthetrendfunctionssupportsafixed(i.e.known)interceptorfloat(i.e.computedbythefitting algorithm).Also,thepowerandtheexponentialcurvefunctionsrequirethevaluesofthesampletime seriestobepositive.

Tips&HintsTrendAnalysis

SpiderFinancialCorp,2012

Problem
Inpractice,wehaveadatasampletakenoveraperiodoftime.Wetrytofitaparametriccurve betweenthepointsinsuchwaythatitdescribesthedatawelland,oncesatisfied,wewillextendthe curvebeyondtheendofthesample,forecastingforfuturedatapoints. Interesting?LetslookatasalesdatasampleandusetheExceltrendfeatureingraphs:

Comparingthefivedifferentcurves,thequadratichasthehighestRsquaredbutisprojectingsalesto dropaftermonth25thatbeingsaid,wecansaydefinitivelythatwewillpreferoneofthefourother possibilities;butwhichoneshouldyouchoose? Furthermore,aforecastusuallycomesinasanintervalupperandlowerlimitswithsomeprobability measureforthisrange.Howcanwedothatwithtrendycurve?

Tips&HintsTrendAnalysis

SpiderFinancialCorp,2012

Solution

Asadataorforecastanalystpractitioner,youknowthatforecastingisnotaonetimething:youneedto periodicallyupdateyourforecastasnewdataisrealized.Thatbeingsaid,howwouldourtrendfunction fairovertime? Thedescriptionaboveisoftenreferredtoasbacktesting.Forourpurposeshere,wewanttobacktest thetrendfunction. 1. Letssetthetimebackwardtothebeginningofthesampledataplus2(accrueafew observations) 2. Runthetrendfunctionusingthepriordata 3. Forecastthepresentvalueanditsconfidenceintervalrememberthatwemovedbacktime. 4. Movetimeonestepforward 5. Repeatsteps24 Thismimicsexactlywhatyouwoulddotoupdatetheforecasttoincludenewobservations,sodoinga backtestingwillhelpyouseehowyouwouldfairwithdifferenttrendcurves.

Linear Trend
UsingNxTrend,wecomputedtheforecastandits95%confidenceintervalthroughoutthesampledata andthenext5monthsforecast.

Noticethetraditionaltrendlinewedrawusingthewholesampledoesnotgiveyouanyinsightofhowa lineartrendworks(ordoesnotwork)foryourforecast. Tips&HintsTrendAnalysis 3 SpiderFinancialCorp,2012

Quadratic Trend
NxTrendsupportspolynomialsofanyorder(assumingyouhaveagoodsizeddatasample).Soto generateaquadratictrendcurve,wewillsettheorderto2.

Thequadraticcurvedoesnotlooksobad:itforecastsadeclineinsalesaftermonth24.Therearemore pointsintheC.I.thaninthelineartrendwelookedatearlier.

Logarithmic Trend
Letsassumethedatafollowsthelogarithmoftimeinsteadoftimeitself.

Tips&HintsTrendAnalysis

SpiderFinancialCorp,2012

Obviously,thelogarithmtrendisinferioranddoesnotdescribethedatawell.Letstossitputthatone totheside.

Exponential Trend
Usinganexponentialtrend,wewouldliketobelievethatourdatagrowsexponentiallyovertime.This maybeappropriateforsometypesofdata,suchaspopulationgrowth.

Theexponentialtrendcurveseemstodowellthroughoutthesample.

Power Trend

Thepowertrend,ontheotherhand,providesaverypoorfit. Tips&HintsTrendAnalysis 5 SpiderFinancialCorp,2012

Conclusion
Theburningquestionnowis:whichtrendfunctionshouldIuseformyforecast?Myanswerwouldbe none,butifyoumustuseone,wedneedtocomeupwithameasure.Sincewearefocusedon forecasting,welluseameasuretosummarizetheforecasterrorsgeneratedduringthebacktesting: 1. Ratioofthenumberofobservationsintheconfidenceintervalband. 2. MedianRobustmeasureoftheforecasterrordistributioncenter. 3. MADRobustmeasureofforecasterrordispersion. Function Linear Quadratic Logarithm Exponential Power % 40.9% 61.9% 50% 40.9% 50% Median 0.2 0.9 0.0 0.2 0.0 MAD 1.53 1.49 1.22 1.54 1.23

Again,thequadratictrendfunctiondidthebestinouranalysis,butitsforecasterrorhasamedianof negative0.9.Toimproveourforecastvalues,wecansubtract0.9towhatevervaluetheQuadratictrend functiongivesus.Heresthenewquadratictrendgraph:

Thedottedlineinthefigureabovecorrespondstothenewforecast(with0.9subtracted).Thesolidline istheoriginaltrendfunction. Withthismodification,66.7%ofthepointsarewithintheCIband.

Tips&HintsTrendAnalysis

SpiderFinancialCorp,2012

You might also like