diff --git a/data/employment.csv b/data/employment.csv new file mode 100644 index 000000000..cb9ef1da6 --- /dev/null +++ b/data/employment.csv @@ -0,0 +1,278 @@ +1947,43606,NaN,NaN +1947.25,43808,NaN,NaN +1947.5,44201,NaN,NaN +1947.75,44579,NaN,NaN +1948,44681,NaN,NaN +1948.25,45033,NaN,NaN +1948.5,45295,NaN,NaN +1948.75,45029,NaN,NaN +1949,44238,NaN,1.438939266971146935247816145420074462890625 +1949.25,43739,NaN,-0.157629648730789995170198380947113037109375 +1949.5,43784,NaN,-0.947895942049626683001406490802764892578125 +1949.75,43517,-7.828544971260043894289992749691009521484375,-2.41112297743484305101446807384490966796875 +1950,43952,-6.0095952707933975034393370151519775390625,-1.645022597631395910866558551788330078125 +1950.25,45084,-5.23091113064720047987066209316253662109375,0.113186203368286442128010094165802001953125 +1950.5,46442,-2.70285745641331232036463916301727294921875,2.500757110324911991483531892299652099609375 +1950.75,46855,0.52433988334678360843099653720855712890625,3.9750999926172880805097520351409912109375 +1951,47871,5.354856293356760943424887955188751220703125,7.89257448608304912340827286243438720703125 +1951.25,48068,4.88532426947995190857909619808197021484375,9.437652243032289334223605692386627197265625 +1951.5,47955,2.501188758772741493885405361652374267578125,9.09946173382968481746502220630645751953125 +1951.75,48309,5.631875000154877852764911949634552001953125,10.446621235585553222335875034332275390625 +1952,48504,3.404621569023220217786729335784912109375,9.85481394165117308148182928562164306640625 +1952.25,48286,-1.319838307391137277591042220592498779296875,6.86142471901302997139282524585723876953125 +1952.5,49319,-1.096267842665156422299332916736602783203125,6.01051801158837406546808779239654541015625 +1952.75,50164,3.527568958810434196493588387966156005859375,6.8239911386017411132343113422393798828125 +1953,50475,-0.175339018134536672732792794704437255859375,5.296827110250205805641598999500274658203125 +1953.25,50522,1.06987629345849200035445392131805419921875,4.97922099315110244788229465484619140625 +1953.5,50365,1.87158388414854925940744578838348388671875,4.903341821473077288828790187835693359375 +1953.75,49702,-2.70666523492445776355452835559844970703125,2.84272950376407607109285891056060791015625 +1954,49158,-3.754534137614200517418794333934783935546875,1.339333161830154494964517652988433837890625 +1954.25,48896,-2.3036574699517586850561201572418212890625,1.255392997409217059612274169921875 +1954.5,48882,-8.2808400602079927921295166015625,-0.8900171783825499005615711212158203125 +1954.75,49331,-7.94898182712813650141470134258270263671875,-1.67449512816483547794632613658905029296875 +1955,49963,-4.539810866057223392999731004238128662109375,-1.0195432705904750037007033824920654296875 +1955.25,50790,-2.97993288345924156601540744304656982421875,0.5290599832587759010493755340576171875 +1955.5,51262,-2.0638238490946605452336370944976806640625,1.76532475573594638262875378131866455078125 +1955.75,51805,1.13723506827636811067350208759307861328125,4.144149596210581876221112906932830810546875 +1956,52295,2.2180288718545853043906390666961669921875,6.18611638184984258259646594524383544921875 +1956.25,52584,2.050715986669956691912375390529632568359375,7.271629741722108519752509891986846923828125 +1956.5,52601,1.8085436089922950486652553081512451171875,7.332590041323555851704441010951995849609375 +1956.75,52930,0.8424309225529214018024504184722900390625,7.0417599189740940346382558345794677734375 +1957,53157,0.23278585433445186936296522617340087890625,6.19670673510472624911926686763763427734375 +1957.25,53066,-1.327637004817233901121653616428375244140625,4.383693703603739777463488280773162841796875 +1957.5,52932,-1.19140806576388058601878583431243896484375,3.20583339587983573437668383121490478515625 +1957.75,52385,-3.497475848502062945044599473476409912109375,1.11336211012121566454879939556121826171875 +1958,51300,-6.728438592193924705497920513153076171875,-1.9210012029507197439670562744140625 +1958.25,50912,-7.485979108499805079190991818904876708984375,-3.2313238805900255101732909679412841796875 +1958.5,51506,-5.902346874764816675451584160327911376953125,-2.103682523189718267531134188175201416015625 +1958.75,52088,-6.5930031994130331440828740596771240234375,-1.603568993533599496004171669483184814453125 +1959,53016,-5.055357328305717601324431598186492919921875,-0.26560440581170041696168482303619384765625 +1959.25,53679,-2.597321544153828654089011251926422119140625,1.148544172864376378129236400127410888671875 +1959.5,53429,-3.064874340562482757377438247203826904296875,0.93455988066170903039164841175079345703125 +1959.75,54175,-0.02178051029613925493322312831878662109375,3.35992566174945750390179455280303955078125 +1960,54458,3.55393649424559043836779892444610595703125,5.973901019329105110955424606800079345703125 +1960.25,54347,1.470961422119898998062126338481903076171875,6.529076209629920413135550916194915771484375 +1960.5,54228,-2.4641329963315001805312931537628173828125,5.14990744792476107249967753887176513671875 +1960.75,53744,-2.864335208275178956682793796062469482421875,3.129743693537648141500540077686309814453125 +1961,53662,-4.4731810834464340587146580219268798828125,1.21113612277486026869155466556549072265625 +1961.25,53977,-4.18205692970923337270505726337432861328125,0.553616632830426169675774872303009033203125 +1961.5,54388,-0.5729178983137899194844067096710205078125,1.77898715760193226742558181285858154296875 +1961.75,54871,-4.4474498315057644504122436046600341796875,1.2765428377597345388494431972503662109375 +1962,55276,-3.346466735569492811919189989566802978515625,1.490905557122232494293712079524993896484375 +1962.25,55644,-0.8039927771196744288317859172821044921875,2.3584840945650284993462264537811279296875 +1962.5,55977,-0.76820244881355392863042652606964111328125,3.174351186607736963196657598018646240234375 +1962.75,56028,0.65217523059754967107437551021575927734375,4.161953290686369655304588377475738525390625 +1963,56322,0.074466483560172491706907749176025390625,4.83801065692341580870561301708221435546875 +1963.25,56658,-0.96158145736126243718899786472320556640625,4.847516560284930164925754070281982421875 +1963.5,57077,-0.4619652083420078270137310028076171875,4.82576921203917663660831749439239501953125 +1963.75,57360,-0.494130498693493791506625711917877197265625,4.43622204913435780326835811138153076171875 +1964,57898,0.06742135645845337421633303165435791015625,4.634402372677641324116848409175872802734375 +1964.25,58221,0.083972193918043558369390666484832763671875,4.52718592007431652746163308620452880859375 +1964.5,58903,0.638399932118090873700566589832305908203125,5.09511310633160974248312413692474365234375 +1964.75,59421,2.016039913199392685783095657825469970703125,5.87961334664350943057797849178314208984375 +1965,60003,1.675172616378631573752500116825103759765625,6.330933838923328949022106826305389404296875 +1965.25,60690,2.01847257427789372741244733333587646484375,6.874574433877796764136292040348052978515625 +1965.5,61490,2.704677911540557033731602132320404052734375,7.44733265515469611273147165775299072265625 +1965.75,62321,3.97902038659458412439562380313873291015625,8.29512513554846009355969727039337158203125 +1966,63192,3.869681421079121719230897724628448486328125,8.749486919410401242203079164028167724609375 +1966.25,64110,5.29577565936415339820086956024169921875,9.635424360109709596144966781139373779296875 +1966.5,64644,4.300922016269396408461034297943115234375,9.3003270339859227533452212810516357421875 +1966.75,65200,4.70372166817696779617108404636383056640625,9.281176968937188576092012226581573486328125 +1967,65530,4.367558788537962755071930587291717529296875,8.811349207926241433597169816493988037109375 +1967.25,65750,3.249897530859698235872201621532440185546875,8.0080731210109661333262920379638671875 +1967.5,66164,2.500313223096100045950151979923248291015625,7.32619484145971000543795526027679443359375 +1967.75,66900,2.418292909613228403031826019287109375,7.090051948733389508561231195926666259765625 +1968,67295,1.7067182812797909718938171863555908203125,6.290822882355996625847183167934417724609375 +1968.25,67904,1.167341338690675911493599414825439453125,5.749458499235288400086574256420135498046875 +1968.5,68487,2.06076975685709840035997331142425537109375,5.7748652749187385779805481433868408203125 +1968.75,69246,2.0790878131183490040712058544158935546875,6.020591273371564966510049998760223388671875 +1969,69905,2.646034137755123083479702472686767578125,6.462912438838202433544211089611053466796875 +1969.25,70636,3.455861412496460616239346563816070556640625,7.168025849300420304643921554088592529296875 +1969.5,70917,2.586313641062361057265661656856536865234375,6.93736707468769964179955422878265380859375 +1969.75,71240,1.35556396782203592010773718357086181640625,6.285549128728007417521439492702484130859375 +1970,71452,2.11549926016914469073526561260223388671875,5.993995590096119485679082572460174560546875 +1970.25,71029,0.307739317693858538405038416385650634765625,4.499330136073922403738833963871002197265625 +1970.5,70948,-0.7570104814176374929957091808319091796875,3.530326810775704871048219501972198486328125 +1970.75,70790,-2.213890354110162661527283489704132080078125,2.20523661197739784256555140018463134765625 +1971,70859,-2.766113259672920321463607251644134521484375,1.35548095637795995571650564670562744140625 +1971.25,71253,-3.265571830497947303229011595249176025390625,0.869699397463818968390114605426788330078125 +1971.5,71617,-2.357279510995113014359958469867706298828125,0.98222968252639475394971668720245361328125 +1971.75,72108,-2.3951211377270738012157380580902099609375,1.211053671833042244543321430683135986328125 +1972,72945,-1.677676743917118074023164808750152587890625,2.067983693722226234967820346355438232421875 +1972.25,73760,1.145236630844237879500724375247955322265625,3.772833489608046875218860805034637451171875 +1972.5,74263,0.862510935256068478338420391082763671875,4.56656321891068728291429579257965087890625 +1972.75,75270,2.241369254016035483800806105136871337890625,6.13639012603425726410932838916778564453125 +1973,76285,3.30396092901128213270567357540130615234375,7.378433956160051820916123688220977783203125 +1973.25,76887,3.017635390742043455247767269611358642578125,7.609988798018321176641620695590972900390625 +1973.5,77276,3.453430561267623488674871623516082763671875,7.60509527781914584920741617679595947265625 +1973.75,78035,3.786271421004812509636394679546356201171875,7.8992448854723988915793597698211669921875 +1974,78296,2.423645491991237577167339622974395751953125,7.079078359965706113143824040889739990234375 +1974.25,78602,2.0755942976729784277267754077911376953125,6.358056515571661293506622314453125 +1974.5,78611,2.244197004623174507287330925464630126953125,5.689879222016543280915357172489166259765625 +1974.75,77657,-1.3584911438738345168530941009521484375,3.12200445856115038623102009296417236328125 +1975,76649,-3.946451154236228830995969474315643310546875,0.4760232353137325844727456569671630859375 +1975.25,76520,-3.77372939554743425105698406696319580078125,-0.478466693364907769137062132358551025390625 +1975.5,77230,-3.20096575031902830232866108417510986328125,-0.059544614913420446100644767284393310546875 +1975.75,78018,-4.1908886498640640638768672943115234375,-0.021787469727996722212992608547210693359375 +1976,79049,-2.33929941562337262439541518688201904296875,0.95713972305702554876916110515594482421875 +1976.25,79376,-2.36198883854603991494514048099517822265625,0.979891115463715323130600154399871826171875 +1976.5,79892,-1.5839262741910715703852474689483642578125,1.616408385031036232248879969120025634765625 +1976.75,80448,1.789482315473151174956001341342926025390625,3.530931933573128844727762043476104736328125 +1977,81391,3.6271917407439104863442480564117431640625,6.002814286685179467895068228244781494140625 +1977.25,82488,2.893213501586387792485766112804412841796875,7.51006836435908553539775311946868896484375 +1977.5,83532,2.23088253791365787037648260593414306640625,7.84418093933572890819050371646881103515625 +1977.75,84408,3.264565973511707852594554424285888671875,7.872261454255522039602510631084442138671875 +1978,85461,3.508687602696454632678069174289703369140625,7.799221817409488721750676631927490234375 +1978.25,86951,6.18093622944752496550790965557098388671875,9.114868603802960933535359799861907958984375 +1978.5,87618,5.819937615755179649568162858486175537109375,9.231073368346415009000338613986968994140625 +1978.75,88673,5.85040767139298623078502714633941650390625,9.7344433166335875284858047962188720703125 +1979,89480,5.159511199595044672605581581592559814453125,9.47504348367738202796317636966705322265625 +1979.25,90109,4.543169930055910299415700137615203857421875,8.83672204222830259823240339756011962890625 +1979.5,90325,4.0060647637392321485094726085662841796875,7.81844850591733120381832122802734375 +1979.75,90673,3.721455774920059411670081317424774169921875,7.15974442896686014137230813503265380859375 +1980,90994,2.476155410777437282376922667026519775390625,6.27334387489872824517078697681427001953125 +1980.25,90099,-0.882009590690358891151845455169677734375,3.55643241768439111183397471904754638671875 +1980.5,90210,0.063600274816735691274516284465789794921875,2.915382938215998365194536745548248291015625 +1980.75,90943,-0.959820241743500446318648755550384521484375,2.527749050244210593518801033496856689453125 +1981,91210,-1.559813152204924335819669067859649658203125,1.914940357013620086945593357086181640625 +1981.25,91490,-1.5326302049606965738348662853240966796875,1.5209628053517008083872497081756591796875 +1981.5,91479,-1.428492651374881461379118263721466064453125,1.26951607100136243388988077640533447265625 +1981.75,90893,-2.939641561540838665678165853023529052734375,0.24233623879581500659696757793426513671875 +1982,90432,-3.962898655756134758121334016323089599609375,-0.619538321510617606691084802150726318359375 +1982.25,89864,-1.806399503766215275391004979610443115234375,-0.26116494342977603082545101642608642578125 +1982.5,89183,-4.691925016176583085325546562671661376953125,-1.144984720546517564798705279827117919921875 +1982.75,88769,-7.17916231496974432957358658313751220703125,-2.419544668681055554770864546298980712890625 +1983,89090,-5.508627846417539331014268100261688232421875,-2.351744545951305553899146616458892822265625 +1983.25,90022,-4.590779134790864191018044948577880859375,-1.617559178840792810660786926746368408203125 +1983.5,91247,-3.107416284786495452863164246082305908203125,-0.253932253389621109818108379840850830078125 +1983.75,92227,-0.709320196554699577973224222660064697265625,1.45699388239745530881918966770172119140625 +1984,93429,0.468658365822420819313265383243560791015625,3.26036024852646733052097260951995849609375 +1984.25,94479,2.0454986729282609303481876850128173828125,5.008017124318939750082790851593017578125 +1984.5,95344,3.89879927665197101305238902568817138671875,6.680096554154033583472482860088348388671875 +1984.75,96107,4.641264925560562915052287280559539794921875,7.942466416457818922935985028743743896484375 +1985,96843,4.0162976172750859404914081096649169921875,8.34440157917924807406961917877197265625 +1985.25,97459,3.251232930855394442914985120296478271484375,7.93776918399453279562294483184814453125 +1985.5,98045,2.880273673620877161738462746143341064453125,7.185644174165872755111195147037506103515625 +1985.75,98609,3.302004399109819132718257606029510498046875,6.69096059920912011875770986080169677734375 +1986,98935,2.141386610900326559203676879405975341796875,5.726127929707445218809880316257476806640625 +1986.25,99155,1.430222248900236081681214272975921630859375,4.830669475533568402170203626155853271484375 +1986.5,99934,1.654001399597973431809805333614349365234375,4.70185640875888566370122134685516357421875 +1986.75,100511,1.415578586353376522311009466648101806640625,4.480502013160730712115764617919921875 +1987,101164,1.197739223369126193574629724025726318359375,4.36518518163620683480985462665557861328125 +1987.25,101900,1.391942629865297931246459484100341796875,4.45601634856984674115665256977081298828125 +1987.5,102646,1.51033013593178111477755010128021240234375,4.585961838938374057761393487453460693359375 +1987.75,103664,1.88256964475704080541618168354034423828125,4.999236437411809674813412129878997802734375 +1988,104487,2.638598871588555994094349443912506103515625,5.459959290802771647577174007892608642578125 +1988.25,105324,3.248123103970783631666563451290130615234375,6.035703106018672770005650818347930908203125 +1988.5,106009,2.216916503548191030859015882015228271484375,5.901402807595104604843072593212127685546875 +1988.75,106906,2.929008804615705230389721691608428955078125,6.168276943169303194736130535602569580078125 +1989,107619,3.11231649319597636349499225616455078125,6.185424972422651990200392901897430419921875 +1989.25,108026,2.590061388086041915812529623508453369140625,5.837999866287873373948968946933746337890625 +1989.5,108365,2.25882657122792807058431208133697509765625,5.42189832995018150541000068187713623046875 +1989.75,108849,1.452957250707186176441609859466552734375,4.8806700976228967192582786083221435546875 +1990,109647,1.77349809292127247317694127559661865234375,4.820345295605875435285270214080810546875 +1990.25,109862,1.25356619689000581274740397930145263671875,4.218371933895468828268349170684814453125 +1990.5,109525,0.397721775270156285841949284076690673828125,3.262883753179949053446762263774871826171875 +1990.75,109160,-1.067112223874801202327944338321685791015625,2.086475216250846642651595175266265869140625 +1991,108577,-2.028441104476996770245023071765899658203125,0.886238663299309337162412703037261962890625 +1991.25,108338,-2.2001412848994732485152781009674072265625,0.288403076536496882908977568149566650390625 +1991.5,108340,-2.638768178404689024318940937519073486328125,-0.02307284106109364074654877185821533203125 +1991.75,108325,-3.4529719240208578412421047687530517578125,-0.48256330578578854328952729701995849609375 +1992,108368,-4.481730106251461620558984577655792236328125,-1.173327223594014867558144032955169677734375 +1992.25,108721,-3.459264953640740714035928249359130859375,-1.044006499668512333300895988941192626953125 +1992.5,108966,-2.3260152821594601846300065517425537109375,-0.511692673554762222920544445514678955078125 +1992.75,109496,-1.993296964567207396612502634525299072265625,0.307332306882699413108639419078826904296875 +1993,109998,-1.05434258663672153488732874393463134765625,1.3002585111016742303036153316497802734375 +1993.25,110754,-0.66172145894370260066352784633636474609375,2.205555599759463802911341190338134765625 +1993.5,111451,-0.317558597507968443096615374088287353515625,2.83106021953381059574894607067108154296875 +1993.75,112312,0.7585352931591842207126319408416748046875,3.61447450436753570102155208587646484375 +1994,113248,1.6031753017668961547315120697021484375,4.404726169050491080270148813724517822265625 +1994.25,114246,1.80317861130379242240451276302337646484375,4.9569050480249643442220985889434814453125 +1994.5,115254,2.738050939039794684504158794879913330078125,5.6102481468415135168470442295074462890625 +1994.75,116164,2.83832890017538375104777514934539794921875,5.91149668363505043089389801025390625 +1995,116913,3.11681140878090445767156779766082763671875,6.0967884645242520491592586040496826171875 +1995.25,117294,2.617817144255923267337493598461151123046875,5.73720778015194809995591640472412109375 +1995.5,117887,2.66011178142844073590822517871856689453125,5.614150610413844333379529416561126708984375 +1995.75,118322,2.201887599558858710224740207195281982421875,5.212900890308674206607975065708160400390625 +1996,119002,1.910008904598726076073944568634033203125,4.956019552993211618741042912006378173828125 +1996.25,119774,1.745999569979403531760908663272857666015625,4.7252615526149384095333516597747802734375 +1996.5,120427,1.485712367177029591402970254421234130859375,4.39053717927527031861245632171630859375 +1996.75,121147,1.46277037913159801973961293697357177734375,4.20016985197389658424071967601776123046875 +1997,122000,1.68886917700410776888020336627960205078125,4.2590976279070673626847565174102783203125 +1997.25,122818,2.342653111589015679783187806606292724609375,4.6019981319795988383702933788299560546875 +1997.5,123605,2.045406057342688654898665845394134521484375,4.736445875058734600315801799297332763671875 +1997.75,124554,2.514951386433267543907277286052703857421875,5.132963523597709354362450540065765380859375 +1998,125177,2.2377971937376059941016137599945068359375,5.05884360266963994945399463176727294921875 +1998.25,126080,2.2325278178932421724312007427215576171875,5.1309992362921548192389309406280517578125 +1998.5,126774,2.534153711700355415814556181430816650390625,5.136221343385614090948365628719329833984375 +1998.75,127601,2.536366456815585479489527642726898193359375,5.190352360552196842036210000514984130859375 +1999,128244,2.177945193225468756281770765781402587890625,4.9913654597503409604541957378387451171875 +1999.25,129091,2.30072168952710853773169219493865966796875,4.981399724620814595255069434642791748046875 +1999.5,129791,2.305166286845860668108798563480377197265625,4.883446714399951815721578896045684814453125 +1999.75,130780,2.122532869417000256362371146678924560546875,4.8777165324418092495761811733245849609375 +2000,131608,2.647083091789454556419514119625091552734375,5.009907159743534066365100443363189697265625 +2000.25,132075,1.980591652864632123964838683605194091796875,4.645331694080823581316508352756500244140625 +2000.5,132377,1.828076139205450090230442583560943603515625,4.32479387410103299771435558795928955078125 +2000.75,132731,1.389021786729927043779753148555755615234375,3.941631583091975699062459170818328857421875 +2001,132752,1.048578456500536049134097993373870849609375,3.45480265911692185909487307071685791015625 +2001.25,132302,-0.13604919197359777172096073627471923828125,2.45696061425815059919841587543487548828125 +2001.5,131793,-0.919488592863899611984379589557647705078125,1.53070454602629979490302503108978271484375 +2001.75,131005,-2.500652553129611987969838082790374755859375,0.171896827857608514023013412952423095703125 +2002,130713,-3.15361858963433405733667314052581787109375,-0.6823727210858123726211488246917724609375 +2002.25,130684,-3.084009629013735320768319070339202880859375,-1.0587747664440030348487198352813720703125 +2002.5,130526,-3.448971578041664542979560792446136474609375,-1.408147176562806635047309100627899169921875 +2002.75,130505,-3.987698587318618592689745128154754638671875,-1.69129834964724068413488566875457763671875 +2003,130238,-3.93807367519139006617479026317596435546875,-1.911918005096367778605781495571136474609375 +2003.25,130195,-3.25428189678177659516222774982452392578125,-1.605386158530336615513078868389129638671875 +2003.5,130281,-3.040940346056231646798551082611083984375,-1.153885373025332228280603885650634765625 +2003.75,130618,-2.1437138765877534751780331134796142578125,-0.295845764529303778544999659061431884765625 +2004,131158,-2.1171358544806935242377221584320068359375,0.339862320254042060696519911289215087890625 +2004.25,131791,-1.8504384211400974891148507595062255859375,0.843513907019541875342838466167449951171875 +2004.5,132120,-1.054408655433917374466545879840850830078125,1.21381598877678698045201599597930908203125 +2004.75,132660,-0.690022480341212940402328968048095703125,1.6377923892387116211466491222381591796875 +2005,133169,0.12320998180666720145381987094879150390625,2.22554524161250810720957815647125244140625 +2005.25,133955,0.50550607832656169193796813488006591796875,2.847059607560595395625568926334381103515625 +2005.5,134593,0.7457416911138352588750422000885009765625,3.256175376090823192498646676540374755859375 +2005.75,135174,0.813397254295296079362742602825164794921875,3.42858046566470875404775142669677734375 +2006,136049,0.989678006744725280441343784332275390625,3.6612411654559764428995549678802490234375 +2006.25,136337,0.815433289503971536760218441486358642578125,3.39124274224241162301041185855865478515625 +2006.5,136883,1.392179276339675197959877550601959228515625,3.541594582877223729155957698822021484375 +2006.75,137266,1.014242569395946702570654451847076416015625,3.413118508980915066786110401153564453125 +2007,137785,0.978735584883224873919971287250518798828125,3.40755009567646993673406541347503662109375 +2007.25,138085,0.43656796956520338426344096660614013671875,3.036551491683212589123286306858062744140625 +2007.5,138116,0.211083562985777462017722427845001220703125,2.58385018633407526067458093166351318359375 +2007.75,138413,0.138154429292399072437547147274017333984375,2.36791319851408843533135950565338134765625 +2008,138268,-0.95959821195583572261966764926910400390625,1.6178715878950242768041789531707763671875 +2008.25,137708,-0.945980988253495524986647069454193115234375,1.0005739481466662255115807056427001953125 +2008.5,136781,-2.305217343946651453734375536441802978515625,-0.074543969775504592689685523509979248046875 +2008.75,134844,-4.02467520984146176488138735294342041015625,-1.7802094473454417311586439609527587890625 +2009,132527,-6.192175553145943922572769224643707275390625,-3.89081009916890252497978508472442626953125 +2009.25,131020,-7.370305607618547583115287125110626220703125,-5.25194542680264930822886526584625244140625 +2009.5,130260,-7.72636462813761681900359690189361572265625,-5.856145865982171017094515264034271240234375 +2009.75,129774,-8.7317913478264017612673342227935791015625,-6.444749336898212277446873486042022705078125 +2010,129896,-8.155431092805883963592350482940673828125,-6.24597005574969443841837346553802490234375 +2010.25,130528,-6.897272331198109895922243595123291015625,-5.354773822487686629756353795528411865234375 +2010.5,130372,-6.313047128043990596779622137546539306640625,-4.798920414391659505781717598438262939453125 +2010.75,130840,-3.86747478946927003562450408935546875,-3.01433520435830359929241240024566650390625 +2011,131295,-1.88679291045673380722291767597198486328125,-0.933969839965584469609893858432769775390625 +2011.25,131949,-1.603880166302360521513037383556365966796875,0.706550098861725928145460784435272216796875 +2011.5,132372,-1.392474945805361130624078214168548583984375,1.608368765698969582444988191127777099609375 +2011.75,132927,-0.312405178983453879482112824916839599609375,2.4005629316607155487872660160064697265625 +2012,133761,0.0218983204167670919559895992279052734375,2.93204951001871449989266693592071533203125 +2012.25,134038,-0.446917701330448835506103932857513427734375,2.653557870351733072311617434024810791015625 +2012.5,134552,1.270743847349194766138680279254913330078125,3.155883891544135622098110616207122802734375 +2012.75,135076,0.67272112767068392713554203510284423828125,3.186238032700885014492087066173553466796875 +2013,135712,0.65696747450829207082279026508331298828125,3.308829343967090608202852308750152587890625 +2013.25,136268,0.659959300192213049740530550479888916015625,3.220805061698001736658625304698944091796875 +2013.5,136862,1.066737078163669139030389487743377685546875,3.33569781159530975855886936187744140625 +2013.75,137387,0.9298065120810861117206513881683349609375,3.300165569128921561059542000293731689453125 +2014,138014,0.44127249792063594213686883449554443359375,3.130050390193673592875711619853973388671875 +2014.25,138843,1.52448961296477136784233152866363525390625,3.5220456527358692255802452564239501953125 +2014.5,139579,1.40375424064995968365110456943511962890625,3.6680007788017974235117435455322265625 +2014.75,140402,1.431144862696555719594471156597137451171875,3.867215350730475620366632938385009765625 +2015,140972,1.377280233447663704282604157924652099609375,3.802629580577331580570898950099945068359375 +2015.25,141724,1.625820747632360507850535213947296142578125,3.9257969357995534664951264858245849609375 +2015.5,142300,1.596020301481303249602206051349639892578125,3.896438620460912716225720942020416259765625 +2015.75,143146,1.858248492586426436901092529296875,4.1063327389174446580000221729278564453125 +2016,143733,1.7232058384824995300732553005218505859375,4.060228252759088718448765575885772705078125 +2016.25,144175,1.25752563741980338818393647670745849609375,3.768404113545329892076551914215087890625 diff --git a/quantecon/__init__.py b/quantecon/__init__.py index d18e84870..7600dc6e4 100644 --- a/quantecon/__init__.py +++ b/quantecon/__init__.py @@ -25,6 +25,7 @@ from .lae import LAE from .arma import ARMA from .lqcontrol import LQ +from .filter import hamilton_filter from .lqnash import nnash from .lss import LinearStateSpace from .matrix_eqn import solve_discrete_lyapunov, solve_discrete_riccati diff --git a/quantecon/filter.py b/quantecon/filter.py new file mode 100644 index 000000000..cfa68f716 --- /dev/null +++ b/quantecon/filter.py @@ -0,0 +1,62 @@ +""" + +function for filtering + +""" +import numpy as np + +def hamilton_filter(data, h, *args): + r""" + This function applies "Hamilton filter" to the data + + http://econweb.ucsd.edu/~jhamilto/hp.pdf + + Parameters + ---------- + data : arrray or dataframe + h : integer + Time horizon that we are likely to predict incorrectly. + Original paper recommends 2 for annual data, 8 for quarterly data, + 24 for monthly data. + *args : integer + If supplied, it is p in the paper. Number of lags in regression. + Must be greater than h. + If not supplied, random walk process is assumed. + + Note: For seasonal data, it's desirable for p and h to be integer multiples + of the number of obsevations in a year. + e.g. For quarterly data, h = 8 and p = 4 are recommended. + + Returns + ------- + cycle : array of cyclical component + trend : trend component + + """ + # transform data to array + y = np.asarray(data, float) + # sample size + T = len(y) + + if len(args) == 1: # if p is supplied + p = args[0] + # construct X matrix of lags + X = np.ones((T-p-h+1, p+1)) + for j in range(1, p+1): + X[:, j] = y[p-j:T-h-j+1:1] + + # do OLS regression + b = np.linalg.solve(X.transpose()@X, X.transpose()@y[p+h-1:T]) + # trend component (`nan` for the first p+h-1 period) + trend = np.append(np.zeros(p+h-1)+np.nan, X@b) + # cyclical component + cycle = y - trend + + elif len(args) == 0: # if p is not supplied (random walk) + cycle = np.append(np.zeros(h)+np.nan, y[h:T] - y[0:T-h]) + trend = y - cycle + + return cycle, trend + + + diff --git a/quantecon/tests/test_filter.py b/quantecon/tests/test_filter.py new file mode 100644 index 000000000..0f105737a --- /dev/null +++ b/quantecon/tests/test_filter.py @@ -0,0 +1,31 @@ +""" +Tests for filter.py. +Using the data of original paper. + +""" + +import sys +import os +import unittest +import pandas as pd +import numpy as np +from numpy.testing import assert_allclose +from quantecon.filter import hamilton_filter +from quantecon.tests.util import get_data_dir + +def test_hamilton_filter(): + # read data + data_dir = get_data_dir() + data_dir = 'data' + data = pd.read_csv(os.path.join(data_dir, "employment.csv"), + names = ['year', 'employment', 'matlab_cyc', 'matlab_cyc_rw']) + + data['hamilton_cyc'], data['hamilton_trend'] = hamilton_filter(100*np.log(data['employment']), 8, 4) + data['hamilton_cyc_rw'], data['hamilton_trend_rw'] = hamilton_filter(100*np.log(data['employment']), 8) + assert_allclose(data['matlab_cyc'], data['hamilton_cyc'], + rtol = 1e-07, atol = 1e-07) + assert_allclose(data['matlab_cyc_rw'], data['hamilton_cyc_rw']) + + +if __name__ == '__main__': + test_hamilton_filter()