From 1f3cfec647ec048ff7891a0b67898033205568f0 Mon Sep 17 00:00:00 2001 From: Shunsuke Hori Date: Sat, 24 Mar 2018 16:59:11 -0700 Subject: [PATCH 1/8] add hp and hamilton filter --- REQUIRE | 1 + src/QuantEcon.jl | 7 +- src/filter.jl | 140 ++++++++++++++++++++ test/REQUIRE | 1 + test/data/employment.csv | 278 +++++++++++++++++++++++++++++++++++++++ test/runtests.jl | 2 + test/test_filter.jl | 17 +++ test/util.jl | 2 +- 8 files changed, 446 insertions(+), 2 deletions(-) create mode 100644 src/filter.jl create mode 100644 test/data/employment.csv create mode 100644 test/test_filter.jl diff --git a/REQUIRE b/REQUIRE index 16e78368..453488ff 100644 --- a/REQUIRE +++ b/REQUIRE @@ -7,3 +7,4 @@ Compat 0.18.0 StatsBase Optim 0.9.0 NLopt 0.3.4 +DataFrames 0.9.0 diff --git a/src/QuantEcon.jl b/src/QuantEcon.jl index bd5c8f5b..0c2c36d9 100644 --- a/src/QuantEcon.jl +++ b/src/QuantEcon.jl @@ -137,7 +137,11 @@ export MVNSampler, # modeltools - @def_sim + @def_sim, + +# filter + hp_filter, + hamilton_filter include("sampler.jl") @@ -152,6 +156,7 @@ include("markov/random_mc.jl") include("discrete_rv.jl") include("ecdf.jl") include("estspec.jl") +include("filter.jl") include("kalman.jl") include("lae.jl") include("lqcontrol.jl") diff --git a/src/filter.jl b/src/filter.jl new file mode 100644 index 00000000..add63489 --- /dev/null +++ b/src/filter.jl @@ -0,0 +1,140 @@ +import DataFrames +doc""" +apply Hodrick-Prescott filter to `AbstractDataVector`. + +##### Arguments +- `y::DaraFrames.AbstractDataVector` : data to be detrended +- `λ::Real` : penalty on variation in trend + +##### Returns +- `y_cyclical::Vector`: cyclical component +- `y_trend::Vector`: trend component +""" +hp_filter(y::DataFrames.AbstractDataVector{T}, λ::Real) where T <: Real = + hp_filter(Vector(y), λ) + +doc""" +apply Hodrick-Prescott filter to `Vector`. + +##### Arguments +- `y::Vector` : data to be detrended +- `λ::Real` : penalty on variation in trend + +##### Returns +- `y_cyclical::Vector`: cyclical component +- `y_trend::Vector`: trend component +""" +function hp_filter(y::Vector{T}, λ::Real) where T <: Real + N = length(y) + H = spdiagm(-2 => fill(λ, N-2), + -1 => vcat(-2λ, fill(-4λ, N - 3), -2λ), + 0 => vcat(1 + λ, 1 + 5λ, fill(1 + 6λ, N-4), + 1 + 5λ, 1 + λ), + 1 => vcat(-2λ, fill(-4λ, N - 3), -2λ), + 2 => fill(λ, N-2)) + y_trend = H \ y + y_cyclical = y - y_trend + return y_cyclical, y_trend +end + +doc""" +This function applies "Hamilton filter" to the data of type `<: AbstractDataVector`. + +http://econweb.ucsd.edu/~jhamilto/hp.pdf + +##### Arguments +- `y::DataFrames.AbstractDataVector` : data to be filtered +- `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. +- `p::Integer` : Number of lags in regression. Must be greater than `h`. +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 +- `y_cycle::Vector` : cyclical component +- `y_trend::Vector` : trend component +""" +hamilton_filter(y::DataFrames.AbstractDataVector, h::Integer, p::Integer) = + hamilton_filter(Vector(y), h, p) + +doc""" +This function applies "Hamilton filter" to the data of type `<: AbstractVector`. + +http://econweb.ucsd.edu/~jhamilto/hp.pdf + +##### Arguments +- `y::AbstractVector` : data to be filtered +- `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. +- `p::Integer` : Number of lags in regression. Must be greater than `h`. +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 +- `y_cycle::Vector` : cyclical component +- `y_trend::Vector` : trend component +""" +function hamilton_filter(y::AbstractVector, h::Integer, p::Integer) + T = length(y) + y_cycle = fill(NaN, T) + + # construct X matrix of lags + X = ones(T-p-h+1) + for j = 1:p + X = hcat(X, y[p-j+1:T-h-j+1]) + end + + # do OLS regression + b = (X'*X)\(X'*y[p+h:T]) + y_cycle[p+h:T] = y[p+h:T] - X*b + y_trend = vcat(fill(NaN, p+h-1), X*b) + return y_cycle, y_trend +end + +doc""" +This function applies "Hamilton filter" to the data of type `<:AbstractDataVector` +under random walk assumption. + +http://econweb.ucsd.edu/~jhamilto/hp.pdf + +##### Arguments +- `y::DataFrames.AbstractDataVector` : data to be filtered +- `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. +Note: For seasonal data, it's desirable for `h` to be an integer multiple + of the number of obsevations in a year. + e.g. For quarterly data, `h = 8` is recommended. +##### Returns +- `y_cycle::Vector` : cyclical component +- `y_trend::Vector` : trend component +""" +hamilton_filter(y::DataFrames.AbstractDataVector, h::Integer) = + hamilton_filter(Vector(y), h) +doc""" +This function applies "Hamilton filter" to the data of type `<:AbstractVector` +under random walk assumption. + +http://econweb.ucsd.edu/~jhamilto/hp.pdf + +##### Arguments +- `y::AbstractVector` : data to be filtered +- `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. +Note: For seasonal data, it's desirable for `h` to be an integer multiple + of the number of obsevations in a year. + e.g. For quarterly data, `h = 8` is recommended. +##### Returns +- `y_cycle::Vector` : cyclical component +- `y_trend::Vector` : trend component +""" +function hamilton_filter(y::AbstractVector, h::Integer) + T = length(y) + y_cycle = fill(NaN, T) + y_cycle[h+1:T] = y[h+1:T] - y[1:T-h] + y_trend = y - y_cycle + return y_cycle, y_trend +end diff --git a/test/REQUIRE b/test/REQUIRE index f586f5bd..c90d2d6f 100644 --- a/test/REQUIRE +++ b/test/REQUIRE @@ -3,3 +3,4 @@ HDF5 MAT JLD DataStructures +CSV diff --git a/test/data/employment.csv b/test/data/employment.csv new file mode 100644 index 00000000..79c975c5 --- /dev/null +++ b/test/data/employment.csv @@ -0,0 +1,278 @@ +1947,43606,NaN,NaN,0.407431001005306825391016900539398193359375 +1947.25,43808,NaN,NaN,0.4579401602813959470950067043304443359375 +1947.5,44201,NaN,NaN,0.93912173677063037757761776447296142578125 +1947.75,44579,NaN,NaN,1.377959682335131219588220119476318359375 +1948,44681,NaN,NaN,1.19187195312815674697048962116241455078125 +1948.25,45033,NaN,NaN,1.558045862658900659880600869655609130859375 +1948.5,45295,NaN,NaN,1.712963252897679922170937061309814453125 +1948.75,45029,NaN,NaN,0.6884244918546755798161029815673828125 +1949,44238,NaN,1.438939266971146935247816145420074462890625,-1.5345120235679132747463881969451904296875 +1949.25,43739,NaN,-0.157629648730789995170198380947113037109375,-3.139931218246829303097911179065704345703125 +1949.5,43784,NaN,-0.947895942049626683001406490802764892578125,-3.53271121675425092689692974090576171875 +1949.75,43517,-7.828544971260043894289992749691009521484375,-2.41112297743484305101446807384490966796875,-4.666877646513967192731797695159912109375 +1950,43952,-6.0095952707933975034393370151519775390625,-1.645022597631395910866558551788330078125,-4.221675713357626591459847986698150634765625 +1950.25,45084,-5.23091113064720047987066209316253662109375,0.113186203368286442128010094165802001953125,-2.252310393678499167435802519321441650390625 +1950.5,46442,-2.70285745641331232036463916301727294921875,2.500757110324911991483531892299652099609375,0.123164010635946397087536752223968505859375 +1950.75,46855,0.52433988334678360843099653720855712890625,3.9750999926172880805097520351409912109375,0.404549381016522602294571697711944580078125 +1951,47871,5.354856293356760943424887955188751220703125,7.89257448608304912340827286243438720703125,1.940849018771814371575601398944854736328125 +1951.25,48068,4.88532426947995190857909619808197021484375,9.437652243032289334223605692386627197265625,1.744212341848424330237321555614471435546875 +1951.5,47955,2.501188758772741493885405361652374267578125,9.09946173382968481746502220630645751953125,0.908480285900850503821857273578643798828125 +1951.75,48309,5.631875000154877852764911949634552001953125,10.446621235585553222335875034332275390625,1.054783500752591862692497670650482177734375 +1952,48504,3.404621569023220217786729335784912109375,9.85481394165117308148182928562164306640625,0.883322229370833156281150877475738525390625 +1952.25,48286,-1.319838307391137277591042220592498779296875,6.86142471901302997139282524585723876953125,-0.1235374204197796643711626529693603515625 +1952.5,49319,-1.096267842665156422299332916736602783203125,6.01051801158837406546808779239654541015625,1.457210286927647757693193852901458740234375 +1952.75,50164,3.527568958810434196493588387966156005859375,6.8239911386017411132343113422393798828125,2.64292966247785443556495010852813720703125 +1953,50475,-0.175339018134536672732792794704437255859375,5.296827110250205805641598999500274658203125,2.7724383492231936543248593807220458984375 +1953.25,50522,1.06987629345849200035445392131805419921875,4.97922099315110244788229465484619140625,2.401513175538639188744127750396728515625 +1953.5,50365,1.87158388414854925940744578838348388671875,4.903341821473077288828790187835693359375,1.64907671172704795026220381259918212890625 +1953.75,49702,-2.70666523492445776355452835559844970703125,2.84272950376407607109285891056060791015625,-0.09769869638103045872412621974945068359375 +1954,49158,-3.754534137614200517418794333934783935546875,1.339333161830154494964517652988433837890625,-1.60462476931934361346065998077392578125 +1954.25,48896,-2.3036574699517586850561201572418212890625,1.255392997409217059612274169921875,-2.53433598145920768729411065578460693359375 +1954.5,48882,-8.2808400602079927921295166015625,-0.8900171783825499005615711212158203125,-2.950438603197426346014253795146942138671875 +1954.75,49331,-7.94898182712813650141470134258270263671875,-1.67449512816483547794632613658905029296875,-2.41734515404868943733163177967071533203125 +1955,49963,-4.539810866057223392999731004238128662109375,-1.0195432705904750037007033824920654296875,-1.51916469707748547079972922801971435546875 +1955.25,50790,-2.97993288345924156601540744304656982421875,0.5290599832587759010493755340576171875,-0.244160430633883152040652930736541748046875 +1955.5,51262,-2.0638238490946605452336370944976806640625,1.76532475573594638262875378131866455078125,0.325020974198878320748917758464813232421875 +1955.75,51805,1.13723506827636811067350208759307861328125,4.144149596210581876221112906932830810546875,1.036524594884895122959278523921966552734375 +1956,52295,2.2180288718545853043906390666961669921875,6.18611638184984258259646594524383544921875,1.65202230515706105506978929042816162109375 +1956.25,52584,2.050715986669956691912375390529632568359375,7.271629741722108519752509891986846923828125,1.89547708725513075478374958038330078125 +1956.5,52601,1.8085436089922950486652553081512451171875,7.332590041323555851704441010951995849609375,1.639340459399818428209982812404632568359375 +1956.75,52930,0.8424309225529214018024504184722900390625,7.0417599189740940346382558345794677734375,1.993351330349241834483109414577484130859375 +1957,53157,0.23278585433445186936296522617340087890625,6.19670673510472624911926686763763427734375,2.1694881755092865205369889736175537109375 +1957.25,53066,-1.327637004817233901121653616428375244140625,4.383693703603739777463488280773162841796875,1.761514503153875921270810067653656005859375 +1957.5,52932,-1.19140806576388058601878583431243896484375,3.20583339587983573437668383121490478515625,1.2833542982980361557565629482269287109375 +1957.75,52385,-3.497475848502062945044599473476409912109375,1.11336211012121566454879939556121826171875,0.025593474450261055608280003070831298828125 +1958,51300,-6.728438592193924705497920513153076171875,-1.9210012029507197439670562744140625,-2.285771564406104516820050776004791259765625 +1958.25,50912,-7.485979108499805079190991818904876708984375,-3.2313238805900255101732909679412841796875,-3.2686077618063791305758059024810791015625 +1958.5,51506,-5.902346874764816675451584160327911376953125,-2.103682523189718267531134188175201416015625,-2.341841667275502913980744779109954833984375 +1958.75,52088,-6.5930031994130331440828740596771240234375,-1.603568993533599496004171669483184814453125,-1.463300149160886576282791793346405029296875 +1959,53016,-5.055357328305717601324431598186492919921875,-0.26560440581170041696168482303619384765625,0.044788478260670672170817852020263671875 +1959.25,53679,-2.597321544153828654089011251926422119140625,1.148544172864376378129236400127410888671875,1.01709538783370589953847229480743408203125 +1959.5,53429,-3.064874340562482757377438247203826904296875,0.93455988066170903039164841175079345703125,0.267130371733173888060264289379119873046875 +1959.75,54175,-0.02178051029613925493322312831878662109375,3.35992566174945750390179455280303955078125,1.357330218576635161298327147960662841796875 +1960,54458,3.55393649424559043836779892444610595703125,5.973901019329105110955424606800079345703125,1.56795390644356302800588309764862060546875 +1960.25,54347,1.470961422119898998062126338481903076171875,6.529076209629920413135550916194915771484375,1.037895483457077716593630611896514892578125 +1960.5,54228,-2.4641329963315001805312931537628173828125,5.14990744792476107249967753887176513671875,0.47444677237581345252692699432373046875 +1960.75,53744,-2.864335208275178956682793796062469482421875,3.129743693537648141500540077686309814453125,-0.787799543341179742128588259220123291015625 +1961,53662,-4.4731810834464340587146580219268798828125,1.21113612277486026869155466556549072265625,-1.33121018945666946819983422756195068359375 +1961.25,53977,-4.18205692970923337270505726337432861328125,0.553616632830426169675774872303009033203125,-1.1646938716030490468256175518035888671875 +1961.5,54388,-0.5729178983137899194844067096710205078125,1.77898715760193226742558181285858154296875,-0.855190640211048958008177578449249267578125 +1961.75,54871,-4.4474498315057644504122436046600341796875,1.2765428377597345388494431972503662109375,-0.451856724208710147649981081485748291015625 +1962,55276,-3.346466735569492811919189989566802978515625,1.490905557122232494293712079524993896484375,-0.229997969282294434378854930400848388671875 +1962.25,55644,-0.8039927771196744288317859172821044921875,2.3584840945650284993462264537811279296875,-0.113367514177525663399137556552886962890625 +1962.5,55977,-0.76820244881355392863042652606964111328125,3.174351186607736963196657598018646240234375,-0.097533045438694898621179163455963134765625 +1962.75,56028,0.65217523059754967107437551021575927734375,4.161953290686369655304588377475738525390625,-0.621668128620285642682574689388275146484375 +1963,56322,0.074466483560172491706907749176025390625,4.83801065692341580870561301708221435546875,-0.74827445842674933373928070068359375 +1963.25,56658,-0.96158145736126243718899786472320556640625,4.847516560284930164925754070281982421875,-0.838226516722670567105524241924285888671875 +1963.5,57077,-0.4619652083420078270137310028076171875,4.82576921203917663660831749439239501953125,-0.820489528701045855996198952198028564453125 +1963.75,57360,-0.494130498693493791506625711917877197265625,4.43622204913435780326835811138153076171875,-1.07829371446905497577972710132598876953125 +1964,57898,0.06742135645845337421633303165435791015625,4.634402372677641324116848409175872802734375,-0.928966734927826109924353659152984619140625 +1964.25,58221,0.083972193918043558369390666484832763671875,4.52718592007431652746163308620452880859375,-1.18654358462072195834480226039886474609375 +1964.5,58903,0.638399932118090873700566589832305908203125,5.09511310633160974248312413692474365234375,-0.86277227281016166671179234981536865234375 +1964.75,59421,2.016039913199392685783095657825469970703125,5.87961334664350943057797849178314208984375,-0.851446952538253754028119146823883056640625 +1965,60003,1.675172616378631573752500116825103759765625,6.330933838923328949022106826305389404296875,-0.7603938487600316875614225864410400390625 +1965.25,60690,2.01847257427789372741244733333587646484375,6.874574433877796764136292040348052978515625,-0.52041570903247702517546713352203369140625 +1965.5,61490,2.704677911540557033731602132320404052734375,7.44733265515469611273147165775299072265625,-0.119100776680852504796348512172698974609375 +1965.75,62321,3.97902038659458412439562380313873291015625,8.29512513554846009355969727039337158203125,0.310618187447516902466304600238800048828125 +1966,63192,3.869681421079121719230897724628448486328125,8.749486919410401242203079164028167724609375,0.78689102529779120231978595256805419921875 +1966.25,64110,5.29577565936415339820086956024169921875,9.635424360109709596144966781139373779296875,1.32376348425123069318942725658416748046875 +1966.5,64644,4.300922016269396408461034297943115234375,9.3003270339859227533452212810516357421875,1.258879108841256311279721558094024658203125 +1966.75,65200,4.70372166817696779617108404636383056640625,9.281176968937188576092012226581573486328125,1.235858809463024954311549663543701171875 +1967,65530,4.367558788537962755071930587291717529296875,8.811349207926241433597169816493988037109375,0.879358407549943876801989972591400146484375 +1967.25,65750,3.249897530859698235872201621532440185546875,8.0080731210109661333262920379638671875,0.373606962927851782296784222126007080078125 +1967.5,66164,2.500313223096100045950151979923248291015625,7.32619484145971000543795526027679443359375,0.1826399577048505307175219058990478515625 +1967.75,66900,2.418292909613228403031826019287109375,7.090051948733389508561231195926666259765625,0.49408103848918472067452967166900634765625 +1968,67295,1.7067182812797909718938171863555908203125,6.290822882355996625847183167934417724609375,0.313288726785913240746594965457916259765625 +1968.25,67904,1.167341338690675911493599414825439453125,5.749458499235288400086574256420135498046875,0.471175202638505652430467307567596435546875 +1968.5,68487,2.06076975685709840035997331142425537109375,5.7748652749187385779805481433868408203125,0.610502063317881038528867065906524658203125 +1968.75,69246,2.0790878131183490040712058544158935546875,6.020591273371564966510049998760223388671875,1.02518272805036758654750883579254150390625 +1969,69905,2.646034137755123083479702472686767578125,6.462912438838202433544211089611053466796875,1.313298643033476764685474336147308349609375 +1969.25,70636,3.455861412496460616239346563816070556640625,7.168025849300420304643921554088592529296875,1.72255729914513722178526222705841064453125 +1969.5,70917,2.586313641062361057265661656856536865234375,6.93736707468769964179955422878265380859375,1.51543988884577629505656659603118896484375 +1969.75,71240,1.35556396782203592010773718357086181640625,6.285549128728007417521439492702484130859375,1.390350118934520651237107813358306884765625 +1970,71452,2.11549926016914469073526561260223388671875,5.993995590096119485679082572460174560546875,1.1294041360970368259586393833160400390625 +1970.25,71029,0.307739317693858538405038416385650634765625,4.499330136073922403738833963871002197265625,-0.0050883240101029514335095882415771484375 +1970.5,70948,-0.7570104814176374929957091808319091796875,3.530326810775704871048219501972198486328125,-0.64732781380143933347426354885101318359375 +1970.75,70790,-2.213890354110162661527283489704132080078125,2.20523661197739784256555140018463134765625,-1.390588445370440240367315709590911865234375 +1971,70859,-2.766113259672920321463607251644134521484375,1.35548095637795995571650564670562744140625,-1.810019741244104807265102863311767578125 +1971.25,71253,-3.265571830497947303229011595249176025390625,0.869699397463818968390114605426788330078125,-1.772417185498170510982163250446319580078125 +1971.5,71617,-2.357279510995113014359958469867706298828125,0.98222968252639475394971668720245361328125,-1.782152292831369777559302747249603271484375 +1971.75,72108,-2.3951211377270738012157380580902099609375,1.211053671833042244543321430683135986328125,-1.621845591574356149067170917987823486328125 +1972,72945,-1.677676743917118074023164808750152587890625,2.067983693722226234967820346355438232421875,-0.99451370698670871206559240818023681640625 +1972.25,73760,1.145236630844237879500724375247955322265625,3.772833489608046875218860805034637451171875,-0.413095639963330540922470390796661376953125 +1972.5,74263,0.862510935256068478338420391082763671875,4.56656321891068728291429579257965087890625,-0.264566812811608542688190937042236328125 +1972.75,75270,2.241369254016035483800806105136871337890625,6.13639012603425726410932838916778564453125,0.551535882038706404273398220539093017578125 +1973,76285,3.30396092901128213270567357540130615234375,7.378433956160051820916123688220977783203125,1.362463416876153132761828601360321044921875 +1973.25,76887,3.017635390742043455247767269611358642578125,7.609988798018321176641620695590972900390625,1.623781318284500230220146477222442626953125 +1973.5,77276,3.453430561267623488674871623516082763671875,7.60509527781914584920741617679595947265625,1.608242817731706963968463242053985595703125 +1973.75,78035,3.786271421004812509636394679546356201171875,7.8992448854723988915793597698211669921875,2.069680372688026182004250586032867431640625 +1974,78296,2.423645491991237577167339622974395751953125,7.079078359965706113143824040889739990234375,1.890560595829128942568786442279815673828125 +1974.25,78602,2.0755942976729784277267754077911376953125,6.358056515571661293506622314453125,1.76794059575286155450157821178436279296875 +1974.5,78611,2.244197004623174507287330925464630126953125,5.689879222016543280915357172489166259765625,1.263276943658638629131019115447998046875 +1974.75,77657,-1.3584911438738345168530941009521484375,3.12200445856115038623102009296417236328125,-0.482140297490104785538278520107269287109375 +1975,76649,-3.946451154236228830995969474315643310546875,0.4760232353137325844727456569671630859375,-2.32705507151104029617272317409515380859375 +1975.25,76520,-3.77372939554743425105698406696319580078125,-0.478466693364907769137062132358551025390625,-3.053243976062049114261753857135772705078125 +1975.5,77230,-3.20096575031902830232866108417510986328125,-0.059544614913420446100644767284393310546875,-2.7106669966606204980053007602691650390625 +1975.75,78018,-4.1908886498640640638768672943115234375,-0.021787469727996722212992608547210693359375,-2.30177940497060262714512646198272705078125 +1976,79049,-2.33929941562337262439541518688201904296875,0.95713972305702554876916110515594482421875,-1.6207910775547134107910096645355224609375 +1976.25,79376,-2.36198883854603991494514048099517822265625,0.979891115463715323130600154399871826171875,-1.864270061536217326647602021694183349609375 +1976.5,79892,-1.5839262741910715703852474689483642578125,1.616408385031036232248879969120025634765625,-1.89490282112410568515770137310028076171875 +1976.75,80448,1.789482315473151174956001341342926025390625,3.530931933573128844727762043476104736328125,-1.8989734728265830199234187602996826171875 +1977,81391,3.6271917407439104863442480564117431640625,6.002814286685179467895068228244781494140625,-1.44571415380005419137887656688690185546875 +1977.25,82488,2.893213501586387792485766112804412841796875,7.51006836435908553539775311946868896484375,-0.82784373990944004617631435394287109375 +1977.5,83532,2.23088253791365787037648260593414306640625,7.84418093933572890819050371646881103515625,-0.293341480204389881691895425319671630859375 +1977.75,84408,3.264565973511707852594554424285888671875,7.872261454255522039602510631084442138671875,0.031549884870628375210799276828765869140625 +1978,85461,3.508687602696454632678069174289703369140625,7.799221817409488721750676631927490234375,0.565124647175025529577396810054779052734375 +1978.25,86951,6.18093622944752496550790965557098388671875,9.114868603802960933535359799861907958984375,1.606755263916284093284048140048980712890625 +1978.5,87618,5.819937615755179649568162858486175537109375,9.231073368346415009000338613986968994140625,1.710394557793961212155409157276153564453125 +1978.75,88673,5.85040767139298623078502714633941650390625,9.7344433166335875284858047962188720703125,2.2789639590637307264842092990875244140625 +1979,89480,5.159511199595044672605581581592559814453125,9.47504348367738202796317636966705322265625,2.59364139589115438866429030895233154296875 +1979.25,90109,4.543169930055910299415700137615203857421875,8.83672204222830259823240339756011962890625,2.7432899845762221957556903362274169921875 +1979.5,90325,4.0060647637392321485094726085662841796875,7.81844850591733120381832122802734375,2.474109211896802662522532045841217041015625 +1979.75,90673,3.721455774920059411670081317424774169921875,7.15974442896686014137230813503265380859375,2.392355155250470488681457936763763427734375 +1980,90994,2.476155410777437282376922667026519775390625,6.27334387489872824517078697681427001953125,2.32030377695582501473836600780487060546875 +1980.25,90099,-0.882009590690358891151845455169677734375,3.55643241768439111183397471904754638671875,0.944285211834767324035055935382843017578125 +1980.5,90210,0.063600274816735691274516284465789794921875,2.915382938215998365194536745548248291015625,0.71330028016609503538347780704498291015625 +1980.75,90943,-0.959820241743500446318648755550384521484375,2.527749050244210593518801033496856689453125,1.1969131864252631203271448612213134765625 +1981,91210,-1.559813152204924335819669067859649658203125,1.914940357013620086945593357086181640625,1.187423806414017235510982573032379150390625 +1981.25,91490,-1.5326302049606965738348662853240966796875,1.5209628053517008083872497081756591796875,1.20808982938387998729012906551361083984375 +1981.5,91479,-1.428492651374881461379118263721466064453125,1.26951607100136243388988077640533447265625,0.92007792997173964977264404296875 +1981.75,90893,-2.939641561540838665678165853023529052734375,0.24233623879581500659696757793426513671875,0.003607282620805563055910170078277587890625 +1982,90432,-3.962898655756134758121334016323089599609375,-0.619538321510617606691084802150726318359375,-0.78480949883260109345428645610809326171875 +1982.25,89864,-1.806399503766215275391004979610443115234375,-0.26116494342977603082545101642608642578125,-1.70920836389495889306999742984771728515625 +1982.5,89183,-4.691925016176583085325546562671661376953125,-1.144984720546517564798705279827117919921875,-2.78639764089211894315667450428009033203125 +1982.75,88769,-7.17916231496974432957358658313751220703125,-2.419544668681055554770864546298980712890625,-3.597069762703313244855962693691253662109375 +1983,89090,-5.508627846417539331014268100261688232421875,-2.351744545951305553899146616458892822265625,-3.615346921977788952062837779521942138671875 +1983.25,90022,-4.590779134790864191018044948577880859375,-1.617559178840792810660786926746368408203125,-2.99047232693692421889863908290863037109375 +1983.5,91247,-3.107416284786495452863164246082305908203125,-0.253932253389621109818108379840850830078125,-2.091747328267729244544170796871185302734375 +1983.75,92227,-0.709320196554699577973224222660064697265625,1.45699388239745530881918966770172119140625,-1.511995337467624267446808516979217529296875 +1984,93429,0.468658365822420819313265383243560791015625,3.26036024852646733052097260951995849609375,-0.73858056784365544444881379604339599609375 +1984.25,94479,2.0454986729282609303481876850128173828125,5.008017124318939750082790851593017578125,-0.1717592850918663316406309604644775390625 +1984.5,95344,3.89879927665197101305238902568817138671875,6.680096554154033583472482860088348388671875,0.16369273824830088415183126926422119140625 +1984.75,96107,4.641264925560562915052287280559539794921875,7.942466416457818922935985028743743896484375,0.36389055345580345601774752140045166015625 +1985,96843,4.0162976172750859404914081096649169921875,8.34440157917924807406961917877197265625,0.5130826350750794517807662487030029296875 +1985.25,97459,3.251232930855394442914985120296478271484375,7.93776918399453279562294483184814453125,0.52051311560717294923961162567138671875 +1985.5,98045,2.880273673620877161738462746143341064453125,7.185644174165872755111195147037506103515625,0.4839955182005724054761230945587158203125 +1985.75,98609,3.302004399109819132718257606029510498046875,6.69096059920912011875770986080169677734375,0.415486045545321758254431188106536865234375 +1986,98935,2.141386610900326559203676879405975341796875,5.726127929707445218809880316257476806640625,0.100265680309576055151410400867462158203125 +1986.25,99155,1.430222248900236081681214272975921630859375,4.830669475533568402170203626155853271484375,-0.323367483803167488076724112033843994140625 +1986.5,99934,1.654001399597973431809805333614349365234375,4.70185640875888566370122134685516357421875,-0.18441127663891165866516530513763427734375 +1986.75,100511,1.415578586353376522311009466648101806640625,4.480502013160730712115764617919921875,-0.247335837395212365663610398769378662109375 +1987,101164,1.197739223369126193574629724025726318359375,4.36518518163620683480985462665557861328125,-0.23049470787418613326735794544219970703125 +1987.25,101900,1.391942629865297931246459484100341796875,4.45601634856984674115665256977081298828125,-0.12533221393869098392315208911895751953125 +1987.5,102646,1.51033013593178111477755010128021240234375,4.585961838938374057761393487453460693359375,-0.001402664372335493681021034717559814453125 +1987.75,103664,1.88256964475704080541618168354034423828125,4.999236437411809674813412129878997802734375,0.39753442460687438142485916614532470703125 +1988,104487,2.638598871588555994094349443912506103515625,5.459959290802771647577174007892608642578125,0.62125205276652195607312023639678955078125 +1988.25,105324,3.248123103970783631666563451290130615234375,6.035703106018672770005650818347930908203125,0.876005110767664518789388239383697509765625 +1988.5,106009,2.216916503548191030859015882015228271484375,5.901402807595104604843072593212127685546875,1.00778916686658703838475048542022705078125 +1988.75,106906,2.929008804615705230389721691608428955078125,6.168276943169303194736130535602569580078125,1.362661495199063210748136043548583984375 +1989,107619,3.11231649319597636349499225616455078125,6.185424972422651990200392901897430419921875,1.56993175406341833877377212047576904296875 +1989.25,108026,2.590061388086041915812529623508453369140625,5.837999866287873373948968946933746337890625,1.52086608061517836176790297031402587890625 +1989.5,108365,2.25882657122792807058431208133697509765625,5.42189832995018150541000068187713623046875,1.438239096802817584830336272716522216796875 +1989.75,108849,1.452957250707186176441609859466552734375,4.8806700976228967192582786083221435546875,1.51724437223447239375673234462738037109375 +1990,109647,1.77349809292127247317694127559661865234375,4.820345295605875435285270214080810546875,1.908188608489354010089300572872161865234375 +1990.25,109862,1.25356619689000581274740397930145263671875,4.218371933895468828268349170684814453125,1.788578463020030540064908564090728759765625 +1990.5,109525,0.397721775270156285841949284076690673828125,3.262883753179949053446762263774871826171875,1.185542666219362217816524207592010498046875 +1990.75,109160,-1.067112223874801202327944338321685791015625,2.086475216250846642651595175266265869140625,0.570162018117343905032612383365631103515625 +1991,108577,-2.028441104476996770245023071765899658203125,0.886238663299309337162412703037261962890625,-0.23884351563219752279110252857208251953125 +1991.25,108338,-2.2001412848994732485152781009674072265625,0.288403076536496882908977568149566650390625,-0.731165536324851927929557859897613525390625 +1991.5,108340,-2.638768178404689024318940937519073486328125,-0.02307284106109364074654877185821533203125,-1.0061269551542864064686000347137451171875 +1991.75,108325,-3.4529719240208578412421047687530517578125,-0.48256330578578854328952729701995849609375,-1.307557135162142003537155687808990478515625 +1992,108368,-4.481730106251461620558984577655792236328125,-1.173327223594014867558144032955169677734375,-1.571529268300537296454422175884246826171875 +1992.25,108721,-3.459264953640740714035928249359130859375,-1.044006499668512333300895988941192626953125,-1.570534088932845406816340982913970947265625 +1992.5,108966,-2.3260152821594601846300065517425537109375,-0.511692673554762222920544445514678955078125,-1.693715069171275899861939251422882080078125 +1992.75,109496,-1.993296964567207396612502634525299072265625,0.307332306882699413108639419078826904296875,-1.583354574465147379669360816478729248046875 +1993,109998,-1.05434258663672153488732874393463134765625,1.3002585111016742303036153316497802734375,-1.52882425123198117944411933422088623046875 +1993.25,110754,-0.66172145894370260066352784633636474609375,2.205555599759463802911341190338134765625,-1.275281773769165738485753536224365234375 +1993.5,111451,-0.317558597507968443096615374088287353515625,2.83106021953381059574894607067108154296875,-1.107342902292657527141273021697998046875 +1993.75,112312,0.7585352931591842207126319408416748046875,3.61447450436753570102155208587646484375,-0.82392428895263947197236120700836181640625 +1994,113248,1.6031753017668961547315120697021484375,4.404726169050491080270148813724517822265625,-0.5048975739964589593000710010528564453125 +1994.25,114246,1.80317861130379242240451276302337646484375,4.9569050480249643442220985889434814453125,-0.1606920909589462098665535449981689453125 +1994.5,115254,2.738050939039794684504158794879913330078125,5.6102481468415135168470442295074462890625,0.1650906151744493399746716022491455078125 +1994.75,116164,2.83832890017538375104777514934539794921875,5.91149668363505043089389801025390625,0.38233316741707312758080661296844482421875 +1995,116913,3.11681140878090445767156779766082763671875,6.0967884645242520491592586040496826171875,0.442063742244499735534191131591796875 +1995.25,117294,2.617817144255923267337493598461151123046875,5.73720778015194809995591640472412109375,0.173242417938809012412093579769134521484375 +1995.5,117887,2.66011178142844073590822517871856689453125,5.614150610413844333379529416561126708984375,0.07445107112152982153929769992828369140625 +1995.75,118322,2.201887599558858710224740207195281982421875,5.212900890308674206607975065708160400390625,-0.16704668603733807685784995555877685546875 +1996,119002,1.910008904598726076073944568634033203125,4.956019552993211618741042912006378173828125,-0.2084038525399591890163719654083251953125 +1996.25,119774,1.745999569979403531760908663272857666015625,4.7252615526149384095333516597747802734375,-0.178547648187304730527102947235107421875 +1996.5,120427,1.485712367177029591402970254421234130859375,4.39053717927527031861245632171630859375,-0.251607476852086620056070387363433837890625 +1996.75,121147,1.46277037913159801973961293697357177734375,4.20016985197389658424071967601776123046875,-0.269804285786449327133595943450927734375 +1997,122000,1.68886917700410776888020336627960205078125,4.2590976279070673626847565174102783203125,-0.1773383942754662712104618549346923828125 +1997.25,122818,2.342653111589015679783187806606292724609375,4.6019981319795988383702933788299560546875,-0.11033106618151578004471957683563232421875 +1997.5,123605,2.045406057342688654898665845394134521484375,4.736445875058734600315801799297332763671875,-0.061997754730327869765460491180419921875 +1997.75,124554,2.514951386433267543907277286052703857421875,5.132963523597709354362450540065765380859375,0.12625321141376844025216996669769287109375 +1998,125177,2.2377971937376059941016137599945068359375,5.05884360266963994945399463176727294921875,0.065452031550876199617050588130950927734375 +1998.25,126080,2.2325278178932421724312007427215576171875,5.1309992362921548192389309406280517578125,0.2442919706909378874115645885467529296875 +1998.5,126774,2.534153711700355415814556181430816650390625,5.136221343385614090948365628719329833984375,0.2759707447467008023522794246673583984375 +1998.75,127601,2.536366456815585479489527642726898193359375,5.190352360552196842036210000514984130859375,0.434381769171750420355238020420074462890625 +1999,128244,2.177945193225468756281770765781402587890625,4.9913654597503409604541957378387451171875,0.473240086353371225413866341114044189453125 +1999.25,129091,2.30072168952710853773169219493865966796875,4.981399724620814595255069434642791748046875,0.698065589500174610293470323085784912109375 +1999.5,129791,2.305166286845860668108798563480377197265625,4.883446714399951815721578896045684814453125,0.83772984650249782134778797626495361328125 +1999.75,130780,2.122532869417000256362371146678924560546875,4.8777165324418092495761811733245849609375,1.22962484602021504542790353298187255859375 +2000,131608,2.647083091789454556419514119625091552734375,5.009907159743534066365100443363189697265625,1.528506652570058577111922204494476318359375 +2000.25,132075,1.980591652864632123964838683605194091796875,4.645331694080823581316508352756500244140625,1.585719905885298430803231894969940185546875 +2000.5,132377,1.828076139205450090230442583560943603515625,4.32479387410103299771435558795928955078125,1.551689928335463264374993741512298583984375 +2000.75,132731,1.389021786729927043779753148555755615234375,3.941631583091975699062459170818328857421875,1.589233494011523362132720649242401123046875 +2001,132752,1.048578456500536049134097993373870849609375,3.45480265911692185909487307071685791015625,1.405811634224619410815648734569549560546875 +2001.25,132302,-0.13604919197359777172096073627471923828125,2.45696061425815059919841587543487548828125,0.893664122797645177342928946018218994140625 +2001.5,131793,-0.919488592863899611984379589557647705078125,1.53070454602629979490302503108978271484375,0.357745136446510514360852539539337158203125 +2001.75,131005,-2.500652553129611987969838082790374755859375,0.171896827857608514023013412952423095703125,-0.37532970050096992054022848606109619140625 +2002,130713,-3.15361858963433405733667314052581787109375,-0.6823727210858123726211488246917724609375,-0.720053251691069817752577364444732666015625 +2002.25,130684,-3.084009629013735320768319070339202880859375,-1.0587747664440030348487198352813720703125,-0.8570871937636184156872332096099853515625 +2002.5,130526,-3.448971578041664542979560792446136474609375,-1.408147176562806635047309100627899169921875,-1.090774373487647608271799981594085693359375 +2002.75,130505,-3.987698587318618592689745128154754638671875,-1.69129834964724068413488566875457763671875,-1.22150996133359512896277010440826416015625 +2003,130238,-3.93807367519139006617479026317596435546875,-1.911918005096367778605781495571136474609375,-1.546274651557951074209995567798614501953125 +2003.25,130195,-3.25428189678177659516222774982452392578125,-1.605386158530336615513078868389129638671875,-1.7072039774657241650857031345367431640625 +2003.5,130281,-3.040940346056231646798551082611083984375,-1.153885373025332228280603885650634765625,-1.778676562997361543239094316959381103515625 +2003.75,130618,-2.1437138765877534751780331134796142578125,-0.295845764529303778544999659061431884765625,-1.66803159479013629606924951076507568359375 +2004,131158,-2.1171358544806935242377221584320068359375,0.339862320254042060696519911289215087890625,-1.4128217146489987499080598354339599609375 +2004.25,131791,-1.8504384211400974891148507595062255859375,0.843513907019541875342838466167449951171875,-1.096815066289536844124086201190948486328125 +2004.5,132120,-1.054408655433917374466545879840850830078125,1.21381598877678698045201599597930908203125,-1.018596015952425659634172916412353515625 +2004.75,132660,-0.690022480341212940402328968048095703125,1.6377923892387116211466491222381591796875,-0.784334592955246989731676876544952392578125 +2005,133169,0.12320998180666720145381987094879150390625,2.22554524161250810720957815647125244140625,-0.573753152380731989978812634944915771484375 +2005.25,133955,0.50550607832656169193796813488006591796875,2.847059607560595395625568926334381103515625,-0.152119194511897148913703858852386474609375 +2005.5,134593,0.7457416911138352588750422000885009765625,3.256175376090823192498646676540374755859375,0.16630369114182030898518860340118408203125 +2005.75,135174,0.813397254295296079362742602825164794921875,3.42858046566470875404775142669677734375,0.455167453839067093213088810443878173828125 +2006,136049,0.989678006744725280441343784332275390625,3.6612411654559764428995549678802490234375,0.97797334572487670811824500560760498046875 +2006.25,136337,0.815433289503971536760218441486358642578125,3.39124274224241162301041185855865478515625,1.090799095231659521232359111309051513671875 +2006.5,136883,1.392179276339675197959877550601959228515625,3.541594582877223729155957698822021484375,1.419336081429491969174705445766448974609375 +2006.75,137266,1.014242569395946702570654451847076416015625,3.413118508980915066786110401153564453125,1.658135196227931373869068920612335205078125 +2007,137785,0.978735584883224873919971287250518798828125,3.40755009567646993673406541347503662109375,2.0275850517136859707534313201904296875 +2007.25,138085,0.43656796956520338426344096660614013671875,3.036551491683212589123286306858062744140625,2.270929144751562489545904099941253662109375 +2007.5,138116,0.211083562985777462017722427845001220703125,2.58385018633407526067458093166351318359375,2.352854387215984388603828847408294677734375 +2007.75,138413,0.138154429292399072437547147274017333984375,2.36791319851408843533135950565338134765625,2.659188354088428241084329783916473388671875 +2008,138268,-0.95959821195583572261966764926910400390625,1.6178715878950242768041789531707763671875,2.6749053698376883403398096561431884765625 +2008.25,137708,-0.945980988253495524986647069454193115234375,1.0005739481466662255115807056427001953125,2.4138962561546577489934861660003662109375 +2008.5,136781,-2.305217343946651453734375536441802978515625,-0.074543969775504592689685523509979248046875,1.901192060138555461890064179897308349609375 +2008.75,134844,-4.02467520984146176488138735294342041015625,-1.7802094473454417311586439609527587890625,0.64769337357347467332147061824798583984375 +2009,132527,-6.192175553145943922572769224643707275390625,-3.89081009916890252497978508472442626953125,-0.911822984698801519698463380336761474609375 +2009.25,131020,-7.370305607618547583115287125110626220703125,-5.25194542680264930822886526584625244140625,-1.89030567186955522629432380199432373046875 +2009.5,130260,-7.72636462813761681900359690189361572265625,-5.856145865982171017094515264034271240234375,-2.32435373427642844035290181636810302734375 +2009.75,129774,-8.7317913478264017612673342227935791015625,-6.444749336898212277446873486042022705078125,-2.575632267844639500253833830356597900390625 +2010,129896,-8.155431092805883963592350482940673828125,-6.24597005574969443841837346553802490234375,-2.390612659943826656672172248363494873046875 +2010.25,130528,-6.897272331198109895922243595123291015625,-5.354773822487686629756353795528411865234375,-1.850329621584023698233067989349365234375 +2010.5,130372,-6.313047128043990596779622137546539306640625,-4.798920414391659505781717598438262939453125,-1.954305666926984486053697764873504638671875 +2010.75,130840,-3.86747478946927003562450408935546875,-3.01433520435830359929241240024566650390625,-1.62169421989392503746785223484039306640625 +2011,131295,-1.88679291045673380722291767597198486328125,-0.933969839965584469609893858432769775390625,-1.34238906594919171766377985477447509765625 +2011.25,131949,-1.603880166302360521513037383556365966796875,0.706550098861725928145460784435272216796875,-0.955265031691169497207738459110260009765625 +2011.5,132372,-1.392474945805361130624078214168548583984375,1.608368765698969582444988191127777099609375,-0.785808495563514952664263546466827392578125 +2011.75,132927,-0.312405178983453879482112824916839599609375,2.4005629316607155487872660160064697265625,-0.55722366845793658285401761531829833984375 +2012,133761,0.0218983204167670919559895992279052734375,2.93204951001871449989266693592071533203125,-0.158642501327676654909737408161163330078125 +2012.25,134038,-0.446917701330448835506103932857513427734375,2.653557870351733072311617434024810791015625,-0.2132093178342984174378216266632080078125 +2012.5,134552,1.270743847349194766138680279254913330078125,3.155883891544135622098110616207122802734375,-0.123884716834027130971662700176239013671875 +2012.75,135076,0.67272112767068392713554203510284423828125,3.186238032700885014492087066173553466796875,-0.05786882691199934924952685832977294921875 +2013,135712,0.65696747450829207082279026508331298828125,3.308829343967090608202852308750152587890625,0.0627524397486922680400311946868896484375 +2013.25,136268,0.659959300192213049740530550479888916015625,3.220805061698001736658625304698944091796875,0.09887292516987145063467323780059814453125 +2013.5,136862,1.066737078163669139030389487743377685546875,3.33569781159530975855886936187744140625,0.140282095432894493569619953632354736328125 +2013.75,137387,0.9298065120810861117206513881683349609375,3.300165569128921561059542000293731689453125,0.111518097715816111303865909576416015625 +2014,138014,0.44127249792063594213686883449554443359375,3.130050390193673592875711619853973388671875,0.139796612940926934243179857730865478515625 +2014.25,138843,1.52448961296477136784233152866363525390625,3.5220456527358692255802452564239501953125,0.298754307769513616221956908702850341796875 +2014.5,139579,1.40375424064995968365110456943511962890625,3.6680007788017974235117435455322265625,0.37718109332172389258630573749542236328125 +2014.75,140402,1.431144862696555719594471156597137451171875,3.867215350730475620366632938385009765625,0.506757534015605415333993732929229736328125 +2015,140972,1.377280233447663704282604157924652099609375,3.802629580577331580570898950099945068359375,0.447605874257305913488380610942840576171875 +2015.25,141724,1.625820747632360507850535213947296142578125,3.9257969357995534664951264858245849609375,0.51108847658406375558115541934967041015625 +2015.5,142300,1.596020301481303249602206051349639892578125,3.896438620460912716225720942020416259765625,0.4453905308037064969539642333984375 +2015.75,143146,1.858248492586426436901092529296875,4.1063327389174446580000221729278564453125,0.565245173393122968263924121856689453125 +2016,143733,1.7232058384824995300732553005218505859375,4.060228252759088718448765575885772705078125,0.50084323903502081520855426788330078125 +2016.25,144175,1.25752563741980338818393647670745849609375,3.768404113545329892076551914215087890625,0.334042958698546499363146722316741943359375 diff --git a/test/runtests.jl b/test/runtests.jl index e8d0d6a0..7d6df93a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,6 +2,7 @@ using QuantEcon using DataStructures: counter using Distributions: LogNormal, pdf using Compat +using CSV using Base.Test @@ -11,6 +12,7 @@ tests = [ "discrete_rv", "ecdf", "estspec", + "filter", "kalman", "lae", "lqcontrol", diff --git a/test/test_filter.jl b/test/test_filter.jl new file mode 100644 index 00000000..0d2b90d8 --- /dev/null +++ b/test/test_filter.jl @@ -0,0 +1,17 @@ +@testset "Testing filter.jl" begin + df = CSV.read(filter_data_file_name, + header=["year", "empl", "ham_c_mat", "ham_rw_c_mat", "hp_c_mat"], + nullable = false) + df[:data] = 100*log.(df[:empl]) + @testset "test hp filter" begin + df[:hp_c], df[:hp_t] = hp_filter(df[:data], 1600) + @test isapprox(df[:hp_c], df[:hp_c_mat]) + end + + @testset "test hamilton filter" begin + df[:ham_c], df[:ham_t] = hamilton_filter(df[:data], 8, 4) + df[:ham_rw_c], df[:hp_rw_t] = hamilton_filter(df[:data], 8) + @test isapprox(df[:ham_c], df[:ham_c_mat], nans=true, rtol=1e-7, atol=1e-7) + @test isapprox(df[:ham_rw_c], df[:ham_rw_c_mat], nans=true) + end +end diff --git a/test/util.jl b/test/util.jl index 3fa5da18..b10945b7 100644 --- a/test/util.jl +++ b/test/util.jl @@ -12,6 +12,7 @@ const data_path = joinpath(test_path, "data") const quad_data_file_name = joinpath(data_path, "matlab_quad.mat") const ml_quad_data_url = "https://github.com/spencerlyon2/QuantEcon.jl/releases/download/v0.0.1/matlab_quad.mat" +const filter_data_file_name = joinpath(data_path, "employment.csv") if !(isfile(quad_data_file_name)) try @@ -25,4 +26,3 @@ if !(isfile(quad_data_file_name)) warn(m) end end - From 7fa6fb429b63f3f483864e95c6e333542c5ab9c1 Mon Sep 17 00:00:00 2001 From: Shunsuke Hori Date: Sat, 24 Mar 2018 18:36:55 -0700 Subject: [PATCH 2/8] maybe fixing undefined type error --- src/filter.jl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/filter.jl b/src/filter.jl index add63489..9f42df57 100644 --- a/src/filter.jl +++ b/src/filter.jl @@ -3,14 +3,14 @@ doc""" apply Hodrick-Prescott filter to `AbstractDataVector`. ##### Arguments -- `y::DaraFrames.AbstractDataVector` : data to be detrended +- `y::DaraFrames.DataArrays.AbstractDataVector` : data to be detrended - `λ::Real` : penalty on variation in trend ##### Returns - `y_cyclical::Vector`: cyclical component - `y_trend::Vector`: trend component """ -hp_filter(y::DataFrames.AbstractDataVector{T}, λ::Real) where T <: Real = +hp_filter(y::DataFrames.DataArrays.AbstractDataVector{T}, λ::Real) where T <: Real = hp_filter(Vector(y), λ) doc""" @@ -43,7 +43,7 @@ This function applies "Hamilton filter" to the data of type `<: AbstractDataVect http://econweb.ucsd.edu/~jhamilto/hp.pdf ##### Arguments -- `y::DataFrames.AbstractDataVector` : data to be filtered +- `y::DataFrames.DataArrays.AbstractDataVector` : data to be filtered - `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. @@ -55,7 +55,7 @@ Note: For seasonal data, it's desirable for `p` and `h` to be integer multiples - `y_cycle::Vector` : cyclical component - `y_trend::Vector` : trend component """ -hamilton_filter(y::DataFrames.AbstractDataVector, h::Integer, p::Integer) = +hamilton_filter(y::DataFrames.DataArrays.AbstractDataVector, h::Integer, p::Integer) = hamilton_filter(Vector(y), h, p) doc""" @@ -94,13 +94,13 @@ function hamilton_filter(y::AbstractVector, h::Integer, p::Integer) end doc""" -This function applies "Hamilton filter" to the data of type `<:AbstractDataVector` +This function applies "Hamilton filter" to the data of type `<:DataArrays.AbstractDataVector` under random walk assumption. http://econweb.ucsd.edu/~jhamilto/hp.pdf ##### Arguments -- `y::DataFrames.AbstractDataVector` : data to be filtered +- `y::DataFrames.DataArrays.AbstractDataVector` : data to be filtered - `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. @@ -111,7 +111,7 @@ Note: For seasonal data, it's desirable for `h` to be an integer multiple - `y_cycle::Vector` : cyclical component - `y_trend::Vector` : trend component """ -hamilton_filter(y::DataFrames.AbstractDataVector, h::Integer) = +hamilton_filter(y::DataFrames.DataArrays.AbstractDataVector, h::Integer) = hamilton_filter(Vector(y), h) doc""" This function applies "Hamilton filter" to the data of type `<:AbstractVector` From b443a8ee95ec928221f63d2e7ef644755e83fce3 Mon Sep 17 00:00:00 2001 From: Shunsuke Hori Date: Sat, 24 Mar 2018 18:52:36 -0700 Subject: [PATCH 3/8] does it pass the test? --- src/filter.jl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/filter.jl b/src/filter.jl index 9f42df57..092089d6 100644 --- a/src/filter.jl +++ b/src/filter.jl @@ -1,16 +1,17 @@ -import DataFrames +import DataFrames: AbstractDataVector + doc""" apply Hodrick-Prescott filter to `AbstractDataVector`. ##### Arguments -- `y::DaraFrames.DataArrays.AbstractDataVector` : data to be detrended +- `y::AbstractDataVector` : data to be detrended - `λ::Real` : penalty on variation in trend ##### Returns - `y_cyclical::Vector`: cyclical component - `y_trend::Vector`: trend component """ -hp_filter(y::DataFrames.DataArrays.AbstractDataVector{T}, λ::Real) where T <: Real = +hp_filter(y::AbstractDataVector{T}, λ::Real) where T <: Real = hp_filter(Vector(y), λ) doc""" @@ -43,7 +44,7 @@ This function applies "Hamilton filter" to the data of type `<: AbstractDataVect http://econweb.ucsd.edu/~jhamilto/hp.pdf ##### Arguments -- `y::DataFrames.DataArrays.AbstractDataVector` : data to be filtered +- `y::AbstractDataVector` : data to be filtered - `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. @@ -55,7 +56,7 @@ Note: For seasonal data, it's desirable for `p` and `h` to be integer multiples - `y_cycle::Vector` : cyclical component - `y_trend::Vector` : trend component """ -hamilton_filter(y::DataFrames.DataArrays.AbstractDataVector, h::Integer, p::Integer) = +hamilton_filter(y::AbstractDataVector, h::Integer, p::Integer) = hamilton_filter(Vector(y), h, p) doc""" @@ -100,7 +101,7 @@ under random walk assumption. http://econweb.ucsd.edu/~jhamilto/hp.pdf ##### Arguments -- `y::DataFrames.DataArrays.AbstractDataVector` : data to be filtered +- `y::AbstractDataVector` : data to be filtered - `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. @@ -111,7 +112,7 @@ Note: For seasonal data, it's desirable for `h` to be an integer multiple - `y_cycle::Vector` : cyclical component - `y_trend::Vector` : trend component """ -hamilton_filter(y::DataFrames.DataArrays.AbstractDataVector, h::Integer) = +hamilton_filter(y::AbstractDataVector, h::Integer) = hamilton_filter(Vector(y), h) doc""" This function applies "Hamilton filter" to the data of type `<:AbstractVector` From 3024126b851ee6812a657f60dc3075c9026c5045 Mon Sep 17 00:00:00 2001 From: Shunsuke Hori Date: Sat, 24 Mar 2018 19:23:18 -0700 Subject: [PATCH 4/8] maybe this does the trick --- REQUIRE | 2 +- src/filter.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/REQUIRE b/REQUIRE index 453488ff..08666a3f 100644 --- a/REQUIRE +++ b/REQUIRE @@ -7,4 +7,4 @@ Compat 0.18.0 StatsBase Optim 0.9.0 NLopt 0.3.4 -DataFrames 0.9.0 +DataArrays 0.6.0 diff --git a/src/filter.jl b/src/filter.jl index 092089d6..e32a10dc 100644 --- a/src/filter.jl +++ b/src/filter.jl @@ -1,4 +1,4 @@ -import DataFrames: AbstractDataVector +import DataArrays: AbstractDataVector doc""" apply Hodrick-Prescott filter to `AbstractDataVector`. From d6494db4593f13e54a16b322c883bac648d6b1d8 Mon Sep 17 00:00:00 2001 From: Shunsuke Hori Date: Sat, 24 Mar 2018 19:42:58 -0700 Subject: [PATCH 5/8] minor change of using CSV --- test/runtests.jl | 1 - test/util.jl | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 7d6df93a..b76968d8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,7 +2,6 @@ using QuantEcon using DataStructures: counter using Distributions: LogNormal, pdf using Compat -using CSV using Base.Test diff --git a/test/util.jl b/test/util.jl index b10945b7..70b80dd8 100644 --- a/test/util.jl +++ b/test/util.jl @@ -5,7 +5,7 @@ Utilities for testing QuantEcon @date: 2014-08-26 =# -using HDF5, JLD, MAT +using HDF5, JLD, MAT, CSV const test_path = dirname(@__FILE__()) const data_path = joinpath(test_path, "data") From ce5a23a2d781e9a9fd0c9949c724978a1496e10a Mon Sep 17 00:00:00 2001 From: Shunsuke Hori Date: Mon, 26 Mar 2018 17:07:37 -0700 Subject: [PATCH 6/8] I don't want to mess my PR though... --- test/test_filter.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_filter.jl b/test/test_filter.jl index 0d2b90d8..f7f3e60e 100644 --- a/test/test_filter.jl +++ b/test/test_filter.jl @@ -5,6 +5,8 @@ df[:data] = 100*log.(df[:empl]) @testset "test hp filter" begin df[:hp_c], df[:hp_t] = hp_filter(df[:data], 1600) + @show df[:hp_c] + @show df[:hp_c_mat] @test isapprox(df[:hp_c], df[:hp_c_mat]) end From a8eabcce20a4938670266d9b7b826d6818f17897 Mon Sep 17 00:00:00 2001 From: Shunsuke Hori Date: Mon, 26 Mar 2018 18:13:49 -0700 Subject: [PATCH 7/8] hopefully this works --- test/data/employment.csv | 278 --------------------------------------- test/test_filter.jl | 14 +- test/util.jl | 3 +- 3 files changed, 10 insertions(+), 285 deletions(-) delete mode 100644 test/data/employment.csv diff --git a/test/data/employment.csv b/test/data/employment.csv deleted file mode 100644 index 79c975c5..00000000 --- a/test/data/employment.csv +++ /dev/null @@ -1,278 +0,0 @@ -1947,43606,NaN,NaN,0.407431001005306825391016900539398193359375 -1947.25,43808,NaN,NaN,0.4579401602813959470950067043304443359375 -1947.5,44201,NaN,NaN,0.93912173677063037757761776447296142578125 -1947.75,44579,NaN,NaN,1.377959682335131219588220119476318359375 -1948,44681,NaN,NaN,1.19187195312815674697048962116241455078125 -1948.25,45033,NaN,NaN,1.558045862658900659880600869655609130859375 -1948.5,45295,NaN,NaN,1.712963252897679922170937061309814453125 -1948.75,45029,NaN,NaN,0.6884244918546755798161029815673828125 -1949,44238,NaN,1.438939266971146935247816145420074462890625,-1.5345120235679132747463881969451904296875 -1949.25,43739,NaN,-0.157629648730789995170198380947113037109375,-3.139931218246829303097911179065704345703125 -1949.5,43784,NaN,-0.947895942049626683001406490802764892578125,-3.53271121675425092689692974090576171875 -1949.75,43517,-7.828544971260043894289992749691009521484375,-2.41112297743484305101446807384490966796875,-4.666877646513967192731797695159912109375 -1950,43952,-6.0095952707933975034393370151519775390625,-1.645022597631395910866558551788330078125,-4.221675713357626591459847986698150634765625 -1950.25,45084,-5.23091113064720047987066209316253662109375,0.113186203368286442128010094165802001953125,-2.252310393678499167435802519321441650390625 -1950.5,46442,-2.70285745641331232036463916301727294921875,2.500757110324911991483531892299652099609375,0.123164010635946397087536752223968505859375 -1950.75,46855,0.52433988334678360843099653720855712890625,3.9750999926172880805097520351409912109375,0.404549381016522602294571697711944580078125 -1951,47871,5.354856293356760943424887955188751220703125,7.89257448608304912340827286243438720703125,1.940849018771814371575601398944854736328125 -1951.25,48068,4.88532426947995190857909619808197021484375,9.437652243032289334223605692386627197265625,1.744212341848424330237321555614471435546875 -1951.5,47955,2.501188758772741493885405361652374267578125,9.09946173382968481746502220630645751953125,0.908480285900850503821857273578643798828125 -1951.75,48309,5.631875000154877852764911949634552001953125,10.446621235585553222335875034332275390625,1.054783500752591862692497670650482177734375 -1952,48504,3.404621569023220217786729335784912109375,9.85481394165117308148182928562164306640625,0.883322229370833156281150877475738525390625 -1952.25,48286,-1.319838307391137277591042220592498779296875,6.86142471901302997139282524585723876953125,-0.1235374204197796643711626529693603515625 -1952.5,49319,-1.096267842665156422299332916736602783203125,6.01051801158837406546808779239654541015625,1.457210286927647757693193852901458740234375 -1952.75,50164,3.527568958810434196493588387966156005859375,6.8239911386017411132343113422393798828125,2.64292966247785443556495010852813720703125 -1953,50475,-0.175339018134536672732792794704437255859375,5.296827110250205805641598999500274658203125,2.7724383492231936543248593807220458984375 -1953.25,50522,1.06987629345849200035445392131805419921875,4.97922099315110244788229465484619140625,2.401513175538639188744127750396728515625 -1953.5,50365,1.87158388414854925940744578838348388671875,4.903341821473077288828790187835693359375,1.64907671172704795026220381259918212890625 -1953.75,49702,-2.70666523492445776355452835559844970703125,2.84272950376407607109285891056060791015625,-0.09769869638103045872412621974945068359375 -1954,49158,-3.754534137614200517418794333934783935546875,1.339333161830154494964517652988433837890625,-1.60462476931934361346065998077392578125 -1954.25,48896,-2.3036574699517586850561201572418212890625,1.255392997409217059612274169921875,-2.53433598145920768729411065578460693359375 -1954.5,48882,-8.2808400602079927921295166015625,-0.8900171783825499005615711212158203125,-2.950438603197426346014253795146942138671875 -1954.75,49331,-7.94898182712813650141470134258270263671875,-1.67449512816483547794632613658905029296875,-2.41734515404868943733163177967071533203125 -1955,49963,-4.539810866057223392999731004238128662109375,-1.0195432705904750037007033824920654296875,-1.51916469707748547079972922801971435546875 -1955.25,50790,-2.97993288345924156601540744304656982421875,0.5290599832587759010493755340576171875,-0.244160430633883152040652930736541748046875 -1955.5,51262,-2.0638238490946605452336370944976806640625,1.76532475573594638262875378131866455078125,0.325020974198878320748917758464813232421875 -1955.75,51805,1.13723506827636811067350208759307861328125,4.144149596210581876221112906932830810546875,1.036524594884895122959278523921966552734375 -1956,52295,2.2180288718545853043906390666961669921875,6.18611638184984258259646594524383544921875,1.65202230515706105506978929042816162109375 -1956.25,52584,2.050715986669956691912375390529632568359375,7.271629741722108519752509891986846923828125,1.89547708725513075478374958038330078125 -1956.5,52601,1.8085436089922950486652553081512451171875,7.332590041323555851704441010951995849609375,1.639340459399818428209982812404632568359375 -1956.75,52930,0.8424309225529214018024504184722900390625,7.0417599189740940346382558345794677734375,1.993351330349241834483109414577484130859375 -1957,53157,0.23278585433445186936296522617340087890625,6.19670673510472624911926686763763427734375,2.1694881755092865205369889736175537109375 -1957.25,53066,-1.327637004817233901121653616428375244140625,4.383693703603739777463488280773162841796875,1.761514503153875921270810067653656005859375 -1957.5,52932,-1.19140806576388058601878583431243896484375,3.20583339587983573437668383121490478515625,1.2833542982980361557565629482269287109375 -1957.75,52385,-3.497475848502062945044599473476409912109375,1.11336211012121566454879939556121826171875,0.025593474450261055608280003070831298828125 -1958,51300,-6.728438592193924705497920513153076171875,-1.9210012029507197439670562744140625,-2.285771564406104516820050776004791259765625 -1958.25,50912,-7.485979108499805079190991818904876708984375,-3.2313238805900255101732909679412841796875,-3.2686077618063791305758059024810791015625 -1958.5,51506,-5.902346874764816675451584160327911376953125,-2.103682523189718267531134188175201416015625,-2.341841667275502913980744779109954833984375 -1958.75,52088,-6.5930031994130331440828740596771240234375,-1.603568993533599496004171669483184814453125,-1.463300149160886576282791793346405029296875 -1959,53016,-5.055357328305717601324431598186492919921875,-0.26560440581170041696168482303619384765625,0.044788478260670672170817852020263671875 -1959.25,53679,-2.597321544153828654089011251926422119140625,1.148544172864376378129236400127410888671875,1.01709538783370589953847229480743408203125 -1959.5,53429,-3.064874340562482757377438247203826904296875,0.93455988066170903039164841175079345703125,0.267130371733173888060264289379119873046875 -1959.75,54175,-0.02178051029613925493322312831878662109375,3.35992566174945750390179455280303955078125,1.357330218576635161298327147960662841796875 -1960,54458,3.55393649424559043836779892444610595703125,5.973901019329105110955424606800079345703125,1.56795390644356302800588309764862060546875 -1960.25,54347,1.470961422119898998062126338481903076171875,6.529076209629920413135550916194915771484375,1.037895483457077716593630611896514892578125 -1960.5,54228,-2.4641329963315001805312931537628173828125,5.14990744792476107249967753887176513671875,0.47444677237581345252692699432373046875 -1960.75,53744,-2.864335208275178956682793796062469482421875,3.129743693537648141500540077686309814453125,-0.787799543341179742128588259220123291015625 -1961,53662,-4.4731810834464340587146580219268798828125,1.21113612277486026869155466556549072265625,-1.33121018945666946819983422756195068359375 -1961.25,53977,-4.18205692970923337270505726337432861328125,0.553616632830426169675774872303009033203125,-1.1646938716030490468256175518035888671875 -1961.5,54388,-0.5729178983137899194844067096710205078125,1.77898715760193226742558181285858154296875,-0.855190640211048958008177578449249267578125 -1961.75,54871,-4.4474498315057644504122436046600341796875,1.2765428377597345388494431972503662109375,-0.451856724208710147649981081485748291015625 -1962,55276,-3.346466735569492811919189989566802978515625,1.490905557122232494293712079524993896484375,-0.229997969282294434378854930400848388671875 -1962.25,55644,-0.8039927771196744288317859172821044921875,2.3584840945650284993462264537811279296875,-0.113367514177525663399137556552886962890625 -1962.5,55977,-0.76820244881355392863042652606964111328125,3.174351186607736963196657598018646240234375,-0.097533045438694898621179163455963134765625 -1962.75,56028,0.65217523059754967107437551021575927734375,4.161953290686369655304588377475738525390625,-0.621668128620285642682574689388275146484375 -1963,56322,0.074466483560172491706907749176025390625,4.83801065692341580870561301708221435546875,-0.74827445842674933373928070068359375 -1963.25,56658,-0.96158145736126243718899786472320556640625,4.847516560284930164925754070281982421875,-0.838226516722670567105524241924285888671875 -1963.5,57077,-0.4619652083420078270137310028076171875,4.82576921203917663660831749439239501953125,-0.820489528701045855996198952198028564453125 -1963.75,57360,-0.494130498693493791506625711917877197265625,4.43622204913435780326835811138153076171875,-1.07829371446905497577972710132598876953125 -1964,57898,0.06742135645845337421633303165435791015625,4.634402372677641324116848409175872802734375,-0.928966734927826109924353659152984619140625 -1964.25,58221,0.083972193918043558369390666484832763671875,4.52718592007431652746163308620452880859375,-1.18654358462072195834480226039886474609375 -1964.5,58903,0.638399932118090873700566589832305908203125,5.09511310633160974248312413692474365234375,-0.86277227281016166671179234981536865234375 -1964.75,59421,2.016039913199392685783095657825469970703125,5.87961334664350943057797849178314208984375,-0.851446952538253754028119146823883056640625 -1965,60003,1.675172616378631573752500116825103759765625,6.330933838923328949022106826305389404296875,-0.7603938487600316875614225864410400390625 -1965.25,60690,2.01847257427789372741244733333587646484375,6.874574433877796764136292040348052978515625,-0.52041570903247702517546713352203369140625 -1965.5,61490,2.704677911540557033731602132320404052734375,7.44733265515469611273147165775299072265625,-0.119100776680852504796348512172698974609375 -1965.75,62321,3.97902038659458412439562380313873291015625,8.29512513554846009355969727039337158203125,0.310618187447516902466304600238800048828125 -1966,63192,3.869681421079121719230897724628448486328125,8.749486919410401242203079164028167724609375,0.78689102529779120231978595256805419921875 -1966.25,64110,5.29577565936415339820086956024169921875,9.635424360109709596144966781139373779296875,1.32376348425123069318942725658416748046875 -1966.5,64644,4.300922016269396408461034297943115234375,9.3003270339859227533452212810516357421875,1.258879108841256311279721558094024658203125 -1966.75,65200,4.70372166817696779617108404636383056640625,9.281176968937188576092012226581573486328125,1.235858809463024954311549663543701171875 -1967,65530,4.367558788537962755071930587291717529296875,8.811349207926241433597169816493988037109375,0.879358407549943876801989972591400146484375 -1967.25,65750,3.249897530859698235872201621532440185546875,8.0080731210109661333262920379638671875,0.373606962927851782296784222126007080078125 -1967.5,66164,2.500313223096100045950151979923248291015625,7.32619484145971000543795526027679443359375,0.1826399577048505307175219058990478515625 -1967.75,66900,2.418292909613228403031826019287109375,7.090051948733389508561231195926666259765625,0.49408103848918472067452967166900634765625 -1968,67295,1.7067182812797909718938171863555908203125,6.290822882355996625847183167934417724609375,0.313288726785913240746594965457916259765625 -1968.25,67904,1.167341338690675911493599414825439453125,5.749458499235288400086574256420135498046875,0.471175202638505652430467307567596435546875 -1968.5,68487,2.06076975685709840035997331142425537109375,5.7748652749187385779805481433868408203125,0.610502063317881038528867065906524658203125 -1968.75,69246,2.0790878131183490040712058544158935546875,6.020591273371564966510049998760223388671875,1.02518272805036758654750883579254150390625 -1969,69905,2.646034137755123083479702472686767578125,6.462912438838202433544211089611053466796875,1.313298643033476764685474336147308349609375 -1969.25,70636,3.455861412496460616239346563816070556640625,7.168025849300420304643921554088592529296875,1.72255729914513722178526222705841064453125 -1969.5,70917,2.586313641062361057265661656856536865234375,6.93736707468769964179955422878265380859375,1.51543988884577629505656659603118896484375 -1969.75,71240,1.35556396782203592010773718357086181640625,6.285549128728007417521439492702484130859375,1.390350118934520651237107813358306884765625 -1970,71452,2.11549926016914469073526561260223388671875,5.993995590096119485679082572460174560546875,1.1294041360970368259586393833160400390625 -1970.25,71029,0.307739317693858538405038416385650634765625,4.499330136073922403738833963871002197265625,-0.0050883240101029514335095882415771484375 -1970.5,70948,-0.7570104814176374929957091808319091796875,3.530326810775704871048219501972198486328125,-0.64732781380143933347426354885101318359375 -1970.75,70790,-2.213890354110162661527283489704132080078125,2.20523661197739784256555140018463134765625,-1.390588445370440240367315709590911865234375 -1971,70859,-2.766113259672920321463607251644134521484375,1.35548095637795995571650564670562744140625,-1.810019741244104807265102863311767578125 -1971.25,71253,-3.265571830497947303229011595249176025390625,0.869699397463818968390114605426788330078125,-1.772417185498170510982163250446319580078125 -1971.5,71617,-2.357279510995113014359958469867706298828125,0.98222968252639475394971668720245361328125,-1.782152292831369777559302747249603271484375 -1971.75,72108,-2.3951211377270738012157380580902099609375,1.211053671833042244543321430683135986328125,-1.621845591574356149067170917987823486328125 -1972,72945,-1.677676743917118074023164808750152587890625,2.067983693722226234967820346355438232421875,-0.99451370698670871206559240818023681640625 -1972.25,73760,1.145236630844237879500724375247955322265625,3.772833489608046875218860805034637451171875,-0.413095639963330540922470390796661376953125 -1972.5,74263,0.862510935256068478338420391082763671875,4.56656321891068728291429579257965087890625,-0.264566812811608542688190937042236328125 -1972.75,75270,2.241369254016035483800806105136871337890625,6.13639012603425726410932838916778564453125,0.551535882038706404273398220539093017578125 -1973,76285,3.30396092901128213270567357540130615234375,7.378433956160051820916123688220977783203125,1.362463416876153132761828601360321044921875 -1973.25,76887,3.017635390742043455247767269611358642578125,7.609988798018321176641620695590972900390625,1.623781318284500230220146477222442626953125 -1973.5,77276,3.453430561267623488674871623516082763671875,7.60509527781914584920741617679595947265625,1.608242817731706963968463242053985595703125 -1973.75,78035,3.786271421004812509636394679546356201171875,7.8992448854723988915793597698211669921875,2.069680372688026182004250586032867431640625 -1974,78296,2.423645491991237577167339622974395751953125,7.079078359965706113143824040889739990234375,1.890560595829128942568786442279815673828125 -1974.25,78602,2.0755942976729784277267754077911376953125,6.358056515571661293506622314453125,1.76794059575286155450157821178436279296875 -1974.5,78611,2.244197004623174507287330925464630126953125,5.689879222016543280915357172489166259765625,1.263276943658638629131019115447998046875 -1974.75,77657,-1.3584911438738345168530941009521484375,3.12200445856115038623102009296417236328125,-0.482140297490104785538278520107269287109375 -1975,76649,-3.946451154236228830995969474315643310546875,0.4760232353137325844727456569671630859375,-2.32705507151104029617272317409515380859375 -1975.25,76520,-3.77372939554743425105698406696319580078125,-0.478466693364907769137062132358551025390625,-3.053243976062049114261753857135772705078125 -1975.5,77230,-3.20096575031902830232866108417510986328125,-0.059544614913420446100644767284393310546875,-2.7106669966606204980053007602691650390625 -1975.75,78018,-4.1908886498640640638768672943115234375,-0.021787469727996722212992608547210693359375,-2.30177940497060262714512646198272705078125 -1976,79049,-2.33929941562337262439541518688201904296875,0.95713972305702554876916110515594482421875,-1.6207910775547134107910096645355224609375 -1976.25,79376,-2.36198883854603991494514048099517822265625,0.979891115463715323130600154399871826171875,-1.864270061536217326647602021694183349609375 -1976.5,79892,-1.5839262741910715703852474689483642578125,1.616408385031036232248879969120025634765625,-1.89490282112410568515770137310028076171875 -1976.75,80448,1.789482315473151174956001341342926025390625,3.530931933573128844727762043476104736328125,-1.8989734728265830199234187602996826171875 -1977,81391,3.6271917407439104863442480564117431640625,6.002814286685179467895068228244781494140625,-1.44571415380005419137887656688690185546875 -1977.25,82488,2.893213501586387792485766112804412841796875,7.51006836435908553539775311946868896484375,-0.82784373990944004617631435394287109375 -1977.5,83532,2.23088253791365787037648260593414306640625,7.84418093933572890819050371646881103515625,-0.293341480204389881691895425319671630859375 -1977.75,84408,3.264565973511707852594554424285888671875,7.872261454255522039602510631084442138671875,0.031549884870628375210799276828765869140625 -1978,85461,3.508687602696454632678069174289703369140625,7.799221817409488721750676631927490234375,0.565124647175025529577396810054779052734375 -1978.25,86951,6.18093622944752496550790965557098388671875,9.114868603802960933535359799861907958984375,1.606755263916284093284048140048980712890625 -1978.5,87618,5.819937615755179649568162858486175537109375,9.231073368346415009000338613986968994140625,1.710394557793961212155409157276153564453125 -1978.75,88673,5.85040767139298623078502714633941650390625,9.7344433166335875284858047962188720703125,2.2789639590637307264842092990875244140625 -1979,89480,5.159511199595044672605581581592559814453125,9.47504348367738202796317636966705322265625,2.59364139589115438866429030895233154296875 -1979.25,90109,4.543169930055910299415700137615203857421875,8.83672204222830259823240339756011962890625,2.7432899845762221957556903362274169921875 -1979.5,90325,4.0060647637392321485094726085662841796875,7.81844850591733120381832122802734375,2.474109211896802662522532045841217041015625 -1979.75,90673,3.721455774920059411670081317424774169921875,7.15974442896686014137230813503265380859375,2.392355155250470488681457936763763427734375 -1980,90994,2.476155410777437282376922667026519775390625,6.27334387489872824517078697681427001953125,2.32030377695582501473836600780487060546875 -1980.25,90099,-0.882009590690358891151845455169677734375,3.55643241768439111183397471904754638671875,0.944285211834767324035055935382843017578125 -1980.5,90210,0.063600274816735691274516284465789794921875,2.915382938215998365194536745548248291015625,0.71330028016609503538347780704498291015625 -1980.75,90943,-0.959820241743500446318648755550384521484375,2.527749050244210593518801033496856689453125,1.1969131864252631203271448612213134765625 -1981,91210,-1.559813152204924335819669067859649658203125,1.914940357013620086945593357086181640625,1.187423806414017235510982573032379150390625 -1981.25,91490,-1.5326302049606965738348662853240966796875,1.5209628053517008083872497081756591796875,1.20808982938387998729012906551361083984375 -1981.5,91479,-1.428492651374881461379118263721466064453125,1.26951607100136243388988077640533447265625,0.92007792997173964977264404296875 -1981.75,90893,-2.939641561540838665678165853023529052734375,0.24233623879581500659696757793426513671875,0.003607282620805563055910170078277587890625 -1982,90432,-3.962898655756134758121334016323089599609375,-0.619538321510617606691084802150726318359375,-0.78480949883260109345428645610809326171875 -1982.25,89864,-1.806399503766215275391004979610443115234375,-0.26116494342977603082545101642608642578125,-1.70920836389495889306999742984771728515625 -1982.5,89183,-4.691925016176583085325546562671661376953125,-1.144984720546517564798705279827117919921875,-2.78639764089211894315667450428009033203125 -1982.75,88769,-7.17916231496974432957358658313751220703125,-2.419544668681055554770864546298980712890625,-3.597069762703313244855962693691253662109375 -1983,89090,-5.508627846417539331014268100261688232421875,-2.351744545951305553899146616458892822265625,-3.615346921977788952062837779521942138671875 -1983.25,90022,-4.590779134790864191018044948577880859375,-1.617559178840792810660786926746368408203125,-2.99047232693692421889863908290863037109375 -1983.5,91247,-3.107416284786495452863164246082305908203125,-0.253932253389621109818108379840850830078125,-2.091747328267729244544170796871185302734375 -1983.75,92227,-0.709320196554699577973224222660064697265625,1.45699388239745530881918966770172119140625,-1.511995337467624267446808516979217529296875 -1984,93429,0.468658365822420819313265383243560791015625,3.26036024852646733052097260951995849609375,-0.73858056784365544444881379604339599609375 -1984.25,94479,2.0454986729282609303481876850128173828125,5.008017124318939750082790851593017578125,-0.1717592850918663316406309604644775390625 -1984.5,95344,3.89879927665197101305238902568817138671875,6.680096554154033583472482860088348388671875,0.16369273824830088415183126926422119140625 -1984.75,96107,4.641264925560562915052287280559539794921875,7.942466416457818922935985028743743896484375,0.36389055345580345601774752140045166015625 -1985,96843,4.0162976172750859404914081096649169921875,8.34440157917924807406961917877197265625,0.5130826350750794517807662487030029296875 -1985.25,97459,3.251232930855394442914985120296478271484375,7.93776918399453279562294483184814453125,0.52051311560717294923961162567138671875 -1985.5,98045,2.880273673620877161738462746143341064453125,7.185644174165872755111195147037506103515625,0.4839955182005724054761230945587158203125 -1985.75,98609,3.302004399109819132718257606029510498046875,6.69096059920912011875770986080169677734375,0.415486045545321758254431188106536865234375 -1986,98935,2.141386610900326559203676879405975341796875,5.726127929707445218809880316257476806640625,0.100265680309576055151410400867462158203125 -1986.25,99155,1.430222248900236081681214272975921630859375,4.830669475533568402170203626155853271484375,-0.323367483803167488076724112033843994140625 -1986.5,99934,1.654001399597973431809805333614349365234375,4.70185640875888566370122134685516357421875,-0.18441127663891165866516530513763427734375 -1986.75,100511,1.415578586353376522311009466648101806640625,4.480502013160730712115764617919921875,-0.247335837395212365663610398769378662109375 -1987,101164,1.197739223369126193574629724025726318359375,4.36518518163620683480985462665557861328125,-0.23049470787418613326735794544219970703125 -1987.25,101900,1.391942629865297931246459484100341796875,4.45601634856984674115665256977081298828125,-0.12533221393869098392315208911895751953125 -1987.5,102646,1.51033013593178111477755010128021240234375,4.585961838938374057761393487453460693359375,-0.001402664372335493681021034717559814453125 -1987.75,103664,1.88256964475704080541618168354034423828125,4.999236437411809674813412129878997802734375,0.39753442460687438142485916614532470703125 -1988,104487,2.638598871588555994094349443912506103515625,5.459959290802771647577174007892608642578125,0.62125205276652195607312023639678955078125 -1988.25,105324,3.248123103970783631666563451290130615234375,6.035703106018672770005650818347930908203125,0.876005110767664518789388239383697509765625 -1988.5,106009,2.216916503548191030859015882015228271484375,5.901402807595104604843072593212127685546875,1.00778916686658703838475048542022705078125 -1988.75,106906,2.929008804615705230389721691608428955078125,6.168276943169303194736130535602569580078125,1.362661495199063210748136043548583984375 -1989,107619,3.11231649319597636349499225616455078125,6.185424972422651990200392901897430419921875,1.56993175406341833877377212047576904296875 -1989.25,108026,2.590061388086041915812529623508453369140625,5.837999866287873373948968946933746337890625,1.52086608061517836176790297031402587890625 -1989.5,108365,2.25882657122792807058431208133697509765625,5.42189832995018150541000068187713623046875,1.438239096802817584830336272716522216796875 -1989.75,108849,1.452957250707186176441609859466552734375,4.8806700976228967192582786083221435546875,1.51724437223447239375673234462738037109375 -1990,109647,1.77349809292127247317694127559661865234375,4.820345295605875435285270214080810546875,1.908188608489354010089300572872161865234375 -1990.25,109862,1.25356619689000581274740397930145263671875,4.218371933895468828268349170684814453125,1.788578463020030540064908564090728759765625 -1990.5,109525,0.397721775270156285841949284076690673828125,3.262883753179949053446762263774871826171875,1.185542666219362217816524207592010498046875 -1990.75,109160,-1.067112223874801202327944338321685791015625,2.086475216250846642651595175266265869140625,0.570162018117343905032612383365631103515625 -1991,108577,-2.028441104476996770245023071765899658203125,0.886238663299309337162412703037261962890625,-0.23884351563219752279110252857208251953125 -1991.25,108338,-2.2001412848994732485152781009674072265625,0.288403076536496882908977568149566650390625,-0.731165536324851927929557859897613525390625 -1991.5,108340,-2.638768178404689024318940937519073486328125,-0.02307284106109364074654877185821533203125,-1.0061269551542864064686000347137451171875 -1991.75,108325,-3.4529719240208578412421047687530517578125,-0.48256330578578854328952729701995849609375,-1.307557135162142003537155687808990478515625 -1992,108368,-4.481730106251461620558984577655792236328125,-1.173327223594014867558144032955169677734375,-1.571529268300537296454422175884246826171875 -1992.25,108721,-3.459264953640740714035928249359130859375,-1.044006499668512333300895988941192626953125,-1.570534088932845406816340982913970947265625 -1992.5,108966,-2.3260152821594601846300065517425537109375,-0.511692673554762222920544445514678955078125,-1.693715069171275899861939251422882080078125 -1992.75,109496,-1.993296964567207396612502634525299072265625,0.307332306882699413108639419078826904296875,-1.583354574465147379669360816478729248046875 -1993,109998,-1.05434258663672153488732874393463134765625,1.3002585111016742303036153316497802734375,-1.52882425123198117944411933422088623046875 -1993.25,110754,-0.66172145894370260066352784633636474609375,2.205555599759463802911341190338134765625,-1.275281773769165738485753536224365234375 -1993.5,111451,-0.317558597507968443096615374088287353515625,2.83106021953381059574894607067108154296875,-1.107342902292657527141273021697998046875 -1993.75,112312,0.7585352931591842207126319408416748046875,3.61447450436753570102155208587646484375,-0.82392428895263947197236120700836181640625 -1994,113248,1.6031753017668961547315120697021484375,4.404726169050491080270148813724517822265625,-0.5048975739964589593000710010528564453125 -1994.25,114246,1.80317861130379242240451276302337646484375,4.9569050480249643442220985889434814453125,-0.1606920909589462098665535449981689453125 -1994.5,115254,2.738050939039794684504158794879913330078125,5.6102481468415135168470442295074462890625,0.1650906151744493399746716022491455078125 -1994.75,116164,2.83832890017538375104777514934539794921875,5.91149668363505043089389801025390625,0.38233316741707312758080661296844482421875 -1995,116913,3.11681140878090445767156779766082763671875,6.0967884645242520491592586040496826171875,0.442063742244499735534191131591796875 -1995.25,117294,2.617817144255923267337493598461151123046875,5.73720778015194809995591640472412109375,0.173242417938809012412093579769134521484375 -1995.5,117887,2.66011178142844073590822517871856689453125,5.614150610413844333379529416561126708984375,0.07445107112152982153929769992828369140625 -1995.75,118322,2.201887599558858710224740207195281982421875,5.212900890308674206607975065708160400390625,-0.16704668603733807685784995555877685546875 -1996,119002,1.910008904598726076073944568634033203125,4.956019552993211618741042912006378173828125,-0.2084038525399591890163719654083251953125 -1996.25,119774,1.745999569979403531760908663272857666015625,4.7252615526149384095333516597747802734375,-0.178547648187304730527102947235107421875 -1996.5,120427,1.485712367177029591402970254421234130859375,4.39053717927527031861245632171630859375,-0.251607476852086620056070387363433837890625 -1996.75,121147,1.46277037913159801973961293697357177734375,4.20016985197389658424071967601776123046875,-0.269804285786449327133595943450927734375 -1997,122000,1.68886917700410776888020336627960205078125,4.2590976279070673626847565174102783203125,-0.1773383942754662712104618549346923828125 -1997.25,122818,2.342653111589015679783187806606292724609375,4.6019981319795988383702933788299560546875,-0.11033106618151578004471957683563232421875 -1997.5,123605,2.045406057342688654898665845394134521484375,4.736445875058734600315801799297332763671875,-0.061997754730327869765460491180419921875 -1997.75,124554,2.514951386433267543907277286052703857421875,5.132963523597709354362450540065765380859375,0.12625321141376844025216996669769287109375 -1998,125177,2.2377971937376059941016137599945068359375,5.05884360266963994945399463176727294921875,0.065452031550876199617050588130950927734375 -1998.25,126080,2.2325278178932421724312007427215576171875,5.1309992362921548192389309406280517578125,0.2442919706909378874115645885467529296875 -1998.5,126774,2.534153711700355415814556181430816650390625,5.136221343385614090948365628719329833984375,0.2759707447467008023522794246673583984375 -1998.75,127601,2.536366456815585479489527642726898193359375,5.190352360552196842036210000514984130859375,0.434381769171750420355238020420074462890625 -1999,128244,2.177945193225468756281770765781402587890625,4.9913654597503409604541957378387451171875,0.473240086353371225413866341114044189453125 -1999.25,129091,2.30072168952710853773169219493865966796875,4.981399724620814595255069434642791748046875,0.698065589500174610293470323085784912109375 -1999.5,129791,2.305166286845860668108798563480377197265625,4.883446714399951815721578896045684814453125,0.83772984650249782134778797626495361328125 -1999.75,130780,2.122532869417000256362371146678924560546875,4.8777165324418092495761811733245849609375,1.22962484602021504542790353298187255859375 -2000,131608,2.647083091789454556419514119625091552734375,5.009907159743534066365100443363189697265625,1.528506652570058577111922204494476318359375 -2000.25,132075,1.980591652864632123964838683605194091796875,4.645331694080823581316508352756500244140625,1.585719905885298430803231894969940185546875 -2000.5,132377,1.828076139205450090230442583560943603515625,4.32479387410103299771435558795928955078125,1.551689928335463264374993741512298583984375 -2000.75,132731,1.389021786729927043779753148555755615234375,3.941631583091975699062459170818328857421875,1.589233494011523362132720649242401123046875 -2001,132752,1.048578456500536049134097993373870849609375,3.45480265911692185909487307071685791015625,1.405811634224619410815648734569549560546875 -2001.25,132302,-0.13604919197359777172096073627471923828125,2.45696061425815059919841587543487548828125,0.893664122797645177342928946018218994140625 -2001.5,131793,-0.919488592863899611984379589557647705078125,1.53070454602629979490302503108978271484375,0.357745136446510514360852539539337158203125 -2001.75,131005,-2.500652553129611987969838082790374755859375,0.171896827857608514023013412952423095703125,-0.37532970050096992054022848606109619140625 -2002,130713,-3.15361858963433405733667314052581787109375,-0.6823727210858123726211488246917724609375,-0.720053251691069817752577364444732666015625 -2002.25,130684,-3.084009629013735320768319070339202880859375,-1.0587747664440030348487198352813720703125,-0.8570871937636184156872332096099853515625 -2002.5,130526,-3.448971578041664542979560792446136474609375,-1.408147176562806635047309100627899169921875,-1.090774373487647608271799981594085693359375 -2002.75,130505,-3.987698587318618592689745128154754638671875,-1.69129834964724068413488566875457763671875,-1.22150996133359512896277010440826416015625 -2003,130238,-3.93807367519139006617479026317596435546875,-1.911918005096367778605781495571136474609375,-1.546274651557951074209995567798614501953125 -2003.25,130195,-3.25428189678177659516222774982452392578125,-1.605386158530336615513078868389129638671875,-1.7072039774657241650857031345367431640625 -2003.5,130281,-3.040940346056231646798551082611083984375,-1.153885373025332228280603885650634765625,-1.778676562997361543239094316959381103515625 -2003.75,130618,-2.1437138765877534751780331134796142578125,-0.295845764529303778544999659061431884765625,-1.66803159479013629606924951076507568359375 -2004,131158,-2.1171358544806935242377221584320068359375,0.339862320254042060696519911289215087890625,-1.4128217146489987499080598354339599609375 -2004.25,131791,-1.8504384211400974891148507595062255859375,0.843513907019541875342838466167449951171875,-1.096815066289536844124086201190948486328125 -2004.5,132120,-1.054408655433917374466545879840850830078125,1.21381598877678698045201599597930908203125,-1.018596015952425659634172916412353515625 -2004.75,132660,-0.690022480341212940402328968048095703125,1.6377923892387116211466491222381591796875,-0.784334592955246989731676876544952392578125 -2005,133169,0.12320998180666720145381987094879150390625,2.22554524161250810720957815647125244140625,-0.573753152380731989978812634944915771484375 -2005.25,133955,0.50550607832656169193796813488006591796875,2.847059607560595395625568926334381103515625,-0.152119194511897148913703858852386474609375 -2005.5,134593,0.7457416911138352588750422000885009765625,3.256175376090823192498646676540374755859375,0.16630369114182030898518860340118408203125 -2005.75,135174,0.813397254295296079362742602825164794921875,3.42858046566470875404775142669677734375,0.455167453839067093213088810443878173828125 -2006,136049,0.989678006744725280441343784332275390625,3.6612411654559764428995549678802490234375,0.97797334572487670811824500560760498046875 -2006.25,136337,0.815433289503971536760218441486358642578125,3.39124274224241162301041185855865478515625,1.090799095231659521232359111309051513671875 -2006.5,136883,1.392179276339675197959877550601959228515625,3.541594582877223729155957698822021484375,1.419336081429491969174705445766448974609375 -2006.75,137266,1.014242569395946702570654451847076416015625,3.413118508980915066786110401153564453125,1.658135196227931373869068920612335205078125 -2007,137785,0.978735584883224873919971287250518798828125,3.40755009567646993673406541347503662109375,2.0275850517136859707534313201904296875 -2007.25,138085,0.43656796956520338426344096660614013671875,3.036551491683212589123286306858062744140625,2.270929144751562489545904099941253662109375 -2007.5,138116,0.211083562985777462017722427845001220703125,2.58385018633407526067458093166351318359375,2.352854387215984388603828847408294677734375 -2007.75,138413,0.138154429292399072437547147274017333984375,2.36791319851408843533135950565338134765625,2.659188354088428241084329783916473388671875 -2008,138268,-0.95959821195583572261966764926910400390625,1.6178715878950242768041789531707763671875,2.6749053698376883403398096561431884765625 -2008.25,137708,-0.945980988253495524986647069454193115234375,1.0005739481466662255115807056427001953125,2.4138962561546577489934861660003662109375 -2008.5,136781,-2.305217343946651453734375536441802978515625,-0.074543969775504592689685523509979248046875,1.901192060138555461890064179897308349609375 -2008.75,134844,-4.02467520984146176488138735294342041015625,-1.7802094473454417311586439609527587890625,0.64769337357347467332147061824798583984375 -2009,132527,-6.192175553145943922572769224643707275390625,-3.89081009916890252497978508472442626953125,-0.911822984698801519698463380336761474609375 -2009.25,131020,-7.370305607618547583115287125110626220703125,-5.25194542680264930822886526584625244140625,-1.89030567186955522629432380199432373046875 -2009.5,130260,-7.72636462813761681900359690189361572265625,-5.856145865982171017094515264034271240234375,-2.32435373427642844035290181636810302734375 -2009.75,129774,-8.7317913478264017612673342227935791015625,-6.444749336898212277446873486042022705078125,-2.575632267844639500253833830356597900390625 -2010,129896,-8.155431092805883963592350482940673828125,-6.24597005574969443841837346553802490234375,-2.390612659943826656672172248363494873046875 -2010.25,130528,-6.897272331198109895922243595123291015625,-5.354773822487686629756353795528411865234375,-1.850329621584023698233067989349365234375 -2010.5,130372,-6.313047128043990596779622137546539306640625,-4.798920414391659505781717598438262939453125,-1.954305666926984486053697764873504638671875 -2010.75,130840,-3.86747478946927003562450408935546875,-3.01433520435830359929241240024566650390625,-1.62169421989392503746785223484039306640625 -2011,131295,-1.88679291045673380722291767597198486328125,-0.933969839965584469609893858432769775390625,-1.34238906594919171766377985477447509765625 -2011.25,131949,-1.603880166302360521513037383556365966796875,0.706550098861725928145460784435272216796875,-0.955265031691169497207738459110260009765625 -2011.5,132372,-1.392474945805361130624078214168548583984375,1.608368765698969582444988191127777099609375,-0.785808495563514952664263546466827392578125 -2011.75,132927,-0.312405178983453879482112824916839599609375,2.4005629316607155487872660160064697265625,-0.55722366845793658285401761531829833984375 -2012,133761,0.0218983204167670919559895992279052734375,2.93204951001871449989266693592071533203125,-0.158642501327676654909737408161163330078125 -2012.25,134038,-0.446917701330448835506103932857513427734375,2.653557870351733072311617434024810791015625,-0.2132093178342984174378216266632080078125 -2012.5,134552,1.270743847349194766138680279254913330078125,3.155883891544135622098110616207122802734375,-0.123884716834027130971662700176239013671875 -2012.75,135076,0.67272112767068392713554203510284423828125,3.186238032700885014492087066173553466796875,-0.05786882691199934924952685832977294921875 -2013,135712,0.65696747450829207082279026508331298828125,3.308829343967090608202852308750152587890625,0.0627524397486922680400311946868896484375 -2013.25,136268,0.659959300192213049740530550479888916015625,3.220805061698001736658625304698944091796875,0.09887292516987145063467323780059814453125 -2013.5,136862,1.066737078163669139030389487743377685546875,3.33569781159530975855886936187744140625,0.140282095432894493569619953632354736328125 -2013.75,137387,0.9298065120810861117206513881683349609375,3.300165569128921561059542000293731689453125,0.111518097715816111303865909576416015625 -2014,138014,0.44127249792063594213686883449554443359375,3.130050390193673592875711619853973388671875,0.139796612940926934243179857730865478515625 -2014.25,138843,1.52448961296477136784233152866363525390625,3.5220456527358692255802452564239501953125,0.298754307769513616221956908702850341796875 -2014.5,139579,1.40375424064995968365110456943511962890625,3.6680007788017974235117435455322265625,0.37718109332172389258630573749542236328125 -2014.75,140402,1.431144862696555719594471156597137451171875,3.867215350730475620366632938385009765625,0.506757534015605415333993732929229736328125 -2015,140972,1.377280233447663704282604157924652099609375,3.802629580577331580570898950099945068359375,0.447605874257305913488380610942840576171875 -2015.25,141724,1.625820747632360507850535213947296142578125,3.9257969357995534664951264858245849609375,0.51108847658406375558115541934967041015625 -2015.5,142300,1.596020301481303249602206051349639892578125,3.896438620460912716225720942020416259765625,0.4453905308037064969539642333984375 -2015.75,143146,1.858248492586426436901092529296875,4.1063327389174446580000221729278564453125,0.565245173393122968263924121856689453125 -2016,143733,1.7232058384824995300732553005218505859375,4.060228252759088718448765575885772705078125,0.50084323903502081520855426788330078125 -2016.25,144175,1.25752563741980338818393647670745849609375,3.768404113545329892076551914215087890625,0.334042958698546499363146722316741943359375 diff --git a/test/test_filter.jl b/test/test_filter.jl index f7f3e60e..70b4c8af 100644 --- a/test/test_filter.jl +++ b/test/test_filter.jl @@ -1,12 +1,16 @@ @testset "Testing filter.jl" begin - df = CSV.read(filter_data_file_name, - header=["year", "empl", "ham_c_mat", "ham_rw_c_mat", "hp_c_mat"], - nullable = false) + df = DataFrame(year = [1947,1947.25,1947.5,1947.75,1948,1948.25,1948.5,1948.75,1949,1949.25,1949.5,1949.75,1950,1950.25,1950.5,1950.75,1951,1951.25,1951.5,1951.75,1952,1952.25,1952.5,1952.75,1953,1953.25,1953.5,1953.75,1954,1954.25,1954.5,1954.75,1955,1955.25,1955.5,1955.75,1956,1956.25,1956.5,1956.75,1957,1957.25,1957.5,1957.75,1958,1958.25,1958.5,1958.75,1959,1959.25,1959.5,1959.75,1960,1960.25,1960.5,1960.75,1961,1961.25,1961.5,1961.75,1962,1962.25,1962.5,1962.75,1963,1963.25,1963.5,1963.75,1964,1964.25,1964.5,1964.75,1965,1965.25,1965.5,1965.75,1966,1966.25,1966.5,1966.75,1967,1967.25,1967.5,1967.75,1968,1968.25,1968.5,1968.75,1969,1969.25,1969.5,1969.75,1970,1970.25,1970.5,1970.75,1971,1971.25,1971.5,1971.75,1972,1972.25,1972.5,1972.75,1973,1973.25,1973.5,1973.75,1974,1974.25,1974.5,1974.75,1975,1975.25,1975.5,1975.75,1976,1976.25,1976.5,1976.75,1977,1977.25,1977.5,1977.75,1978,1978.25,1978.5,1978.75,1979,1979.25,1979.5,1979.75,1980,1980.25,1980.5,1980.75,1981,1981.25,1981.5,1981.75,1982,1982.25,1982.5,1982.75,1983,1983.25,1983.5,1983.75,1984,1984.25,1984.5,1984.75,1985,1985.25,1985.5,1985.75,1986,1986.25,1986.5,1986.75,1987,1987.25,1987.5,1987.75,1988,1988.25,1988.5,1988.75,1989,1989.25,1989.5,1989.75,1990,1990.25,1990.5,1990.75,1991,1991.25,1991.5,1991.75,1992,1992.25,1992.5,1992.75,1993,1993.25,1993.5,1993.75,1994,1994.25,1994.5,1994.75,1995,1995.25,1995.5,1995.75,1996,1996.25,1996.5,1996.75,1997,1997.25,1997.5,1997.75,1998,1998.25,1998.5,1998.75,1999,1999.25,1999.5,1999.75,2000,2000.25,2000.5,2000.75,2001,2001.25,2001.5,2001.75,2002,2002.25,2002.5,2002.75,2003,2003.25,2003.5,2003.75,2004,2004.25,2004.5,2004.75,2005,2005.25,2005.5,2005.75,2006,2006.25,2006.5,2006.75,2007,2007.25,2007.5,2007.75,2008,2008.25,2008.5,2008.75,2009,2009.25,2009.5,2009.75,2010,2010.25,2010.5,2010.75,2011,2011.25,2011.5,2011.75,2012,2012.25,2012.5,2012.75,2013,2013.25,2013.5,2013.75,2014,2014.25,2014.5,2014.75,2015,2015.25,2015.5,2015.75,2016,2016.25], + empl = + [43606,43808,44201,44579,44681,45033,45295,45029,44238,43739,43784,43517,43952,45084,46442,46855,47871,48068,47955,48309,48504,48286,49319,50164,50475,50522,50365,49702,49158,48896,48882,49331,49963,50790,51262,51805,52295,52584,52601,52930,53157,53066,52932,52385,51300,50912,51506,52088,53016,53679,53429,54175,54458,54347,54228,53744,53662,53977,54388,54871,55276,55644,55977,56028,56322,56658,57077,57360,57898,58221,58903,59421,60003,60690,61490,62321,63192,64110,64644,65200,65530,65750,66164,66900,67295,67904,68487,69246,69905,70636,70917,71240,71452,71029,70948,70790,70859,71253,71617,72108,72945,73760,74263,75270,76285,76887,77276,78035,78296,78602,78611,77657,76649,76520,77230,78018,79049,79376,79892,80448,81391,82488,83532,84408,85461,86951,87618,88673,89480,90109,90325,90673,90994,90099,90210,90943,91210,91490,91479,90893,90432,89864,89183,88769,89090,90022,91247,92227,93429,94479,95344,96107,96843,97459,98045,98609,98935,99155,99934,100511,101164,101900,102646,103664,104487,105324,106009,106906,107619,108026,108365,108849,109647,109862,109525,109160,108577,108338,108340,108325,108368,108721,108966,109496,109998,110754,111451,112312,113248,114246,115254,116164,116913,117294,117887,118322,119002,119774,120427,121147,122000,122818,123605,124554,125177,126080,126774,127601,128244,129091,129791,130780,131608,132075,132377,132731,132752,132302,131793,131005,130713,130684,130526,130505,130238,130195,130281,130618,131158,131791,132120,132660,133169,133955,134593,135174,136049,136337,136883,137266,137785,138085,138116,138413,138268,137708,136781,134844,132527,131020,130260,129774,129896,130528,130372,130840,131295,131949,132372,132927,133761,134038,134552,135076,135712,136268,136862,137387,138014,138843,139579,140402,140972,141724,142300,143146,143733,144175], + ham_c_mat = + [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,-7.828544971260043894289992749691009521484375,-6.0095952707933975034393370151519775390625,-5.23091113064720047987066209316253662109375,-2.70285745641331232036463916301727294921875,0.52433988334678360843099653720855712890625,5.354856293356760943424887955188751220703125,4.88532426947995190857909619808197021484375,2.501188758772741493885405361652374267578125,5.631875000154877852764911949634552001953125,3.404621569023220217786729335784912109375,-1.319838307391137277591042220592498779296875,-1.096267842665156422299332916736602783203125,3.527568958810434196493588387966156005859375,-0.175339018134536672732792794704437255859375,1.06987629345849200035445392131805419921875,1.87158388414854925940744578838348388671875,-2.70666523492445776355452835559844970703125,-3.754534137614200517418794333934783935546875,-2.3036574699517586850561201572418212890625,-8.2808400602079927921295166015625,-7.94898182712813650141470134258270263671875,-4.539810866057223392999731004238128662109375,-2.97993288345924156601540744304656982421875,-2.0638238490946605452336370944976806640625,1.13723506827636811067350208759307861328125,2.2180288718545853043906390666961669921875,2.050715986669956691912375390529632568359375,1.8085436089922950486652553081512451171875,0.8424309225529214018024504184722900390625,0.23278585433445186936296522617340087890625,-1.327637004817233901121653616428375244140625,-1.19140806576388058601878583431243896484375,-3.497475848502062945044599473476409912109375,-6.728438592193924705497920513153076171875,-7.485979108499805079190991818904876708984375,-5.902346874764816675451584160327911376953125,-6.5930031994130331440828740596771240234375,-5.055357328305717601324431598186492919921875,-2.597321544153828654089011251926422119140625,-3.064874340562482757377438247203826904296875,-0.02178051029613925493322312831878662109375,3.55393649424559043836779892444610595703125,1.470961422119898998062126338481903076171875,-2.4641329963315001805312931537628173828125,-2.864335208275178956682793796062469482421875,-4.4731810834464340587146580219268798828125,-4.18205692970923337270505726337432861328125,-0.5729178983137899194844067096710205078125,-4.4474498315057644504122436046600341796875,-3.346466735569492811919189989566802978515625,-0.8039927771196744288317859172821044921875,-0.76820244881355392863042652606964111328125,0.65217523059754967107437551021575927734375,0.074466483560172491706907749176025390625,-0.96158145736126243718899786472320556640625,-0.4619652083420078270137310028076171875,-0.494130498693493791506625711917877197265625,0.06742135645845337421633303165435791015625,0.083972193918043558369390666484832763671875,0.638399932118090873700566589832305908203125,2.016039913199392685783095657825469970703125,1.675172616378631573752500116825103759765625,2.01847257427789372741244733333587646484375,2.704677911540557033731602132320404052734375,3.97902038659458412439562380313873291015625,3.869681421079121719230897724628448486328125,5.29577565936415339820086956024169921875,4.300922016269396408461034297943115234375,4.70372166817696779617108404636383056640625,4.367558788537962755071930587291717529296875,3.249897530859698235872201621532440185546875,2.500313223096100045950151979923248291015625,2.418292909613228403031826019287109375,1.7067182812797909718938171863555908203125,1.167341338690675911493599414825439453125,2.06076975685709840035997331142425537109375,2.0790878131183490040712058544158935546875,2.646034137755123083479702472686767578125,3.455861412496460616239346563816070556640625,2.586313641062361057265661656856536865234375,1.35556396782203592010773718357086181640625,2.11549926016914469073526561260223388671875,0.307739317693858538405038416385650634765625,-0.7570104814176374929957091808319091796875,-2.213890354110162661527283489704132080078125,-2.766113259672920321463607251644134521484375,-3.265571830497947303229011595249176025390625,-2.357279510995113014359958469867706298828125,-2.3951211377270738012157380580902099609375,-1.677676743917118074023164808750152587890625,1.145236630844237879500724375247955322265625,0.862510935256068478338420391082763671875,2.241369254016035483800806105136871337890625,3.30396092901128213270567357540130615234375,3.017635390742043455247767269611358642578125,3.453430561267623488674871623516082763671875,3.786271421004812509636394679546356201171875,2.423645491991237577167339622974395751953125,2.0755942976729784277267754077911376953125,2.244197004623174507287330925464630126953125,-1.3584911438738345168530941009521484375,-3.946451154236228830995969474315643310546875,-3.77372939554743425105698406696319580078125,-3.20096575031902830232866108417510986328125,-4.1908886498640640638768672943115234375,-2.33929941562337262439541518688201904296875,-2.36198883854603991494514048099517822265625,-1.5839262741910715703852474689483642578125,1.789482315473151174956001341342926025390625,3.6271917407439104863442480564117431640625,2.893213501586387792485766112804412841796875,2.23088253791365787037648260593414306640625,3.264565973511707852594554424285888671875,3.508687602696454632678069174289703369140625,6.18093622944752496550790965557098388671875,5.819937615755179649568162858486175537109375,5.85040767139298623078502714633941650390625,5.159511199595044672605581581592559814453125,4.543169930055910299415700137615203857421875,4.0060647637392321485094726085662841796875,3.721455774920059411670081317424774169921875,2.476155410777437282376922667026519775390625,-0.882009590690358891151845455169677734375,0.063600274816735691274516284465789794921875,-0.959820241743500446318648755550384521484375,-1.559813152204924335819669067859649658203125,-1.5326302049606965738348662853240966796875,-1.428492651374881461379118263721466064453125,-2.939641561540838665678165853023529052734375,-3.962898655756134758121334016323089599609375,-1.806399503766215275391004979610443115234375,-4.691925016176583085325546562671661376953125,-7.17916231496974432957358658313751220703125,-5.508627846417539331014268100261688232421875,-4.590779134790864191018044948577880859375,-3.107416284786495452863164246082305908203125,-0.709320196554699577973224222660064697265625,0.468658365822420819313265383243560791015625,2.0454986729282609303481876850128173828125,3.89879927665197101305238902568817138671875,4.641264925560562915052287280559539794921875,4.0162976172750859404914081096649169921875,3.251232930855394442914985120296478271484375,2.880273673620877161738462746143341064453125,3.302004399109819132718257606029510498046875,2.141386610900326559203676879405975341796875,1.430222248900236081681214272975921630859375,1.654001399597973431809805333614349365234375,1.415578586353376522311009466648101806640625,1.197739223369126193574629724025726318359375,1.391942629865297931246459484100341796875,1.51033013593178111477755010128021240234375,1.88256964475704080541618168354034423828125,2.638598871588555994094349443912506103515625,3.248123103970783631666563451290130615234375,2.216916503548191030859015882015228271484375,2.929008804615705230389721691608428955078125,3.11231649319597636349499225616455078125,2.590061388086041915812529623508453369140625,2.25882657122792807058431208133697509765625,1.452957250707186176441609859466552734375,1.77349809292127247317694127559661865234375,1.25356619689000581274740397930145263671875,0.397721775270156285841949284076690673828125,-1.067112223874801202327944338321685791015625,-2.028441104476996770245023071765899658203125,-2.2001412848994732485152781009674072265625,-2.638768178404689024318940937519073486328125,-3.4529719240208578412421047687530517578125,-4.481730106251461620558984577655792236328125,-3.459264953640740714035928249359130859375,-2.3260152821594601846300065517425537109375,-1.993296964567207396612502634525299072265625,-1.05434258663672153488732874393463134765625,-0.66172145894370260066352784633636474609375,-0.317558597507968443096615374088287353515625,0.7585352931591842207126319408416748046875,1.6031753017668961547315120697021484375,1.80317861130379242240451276302337646484375,2.738050939039794684504158794879913330078125,2.83832890017538375104777514934539794921875,3.11681140878090445767156779766082763671875,2.617817144255923267337493598461151123046875,2.66011178142844073590822517871856689453125,2.201887599558858710224740207195281982421875,1.910008904598726076073944568634033203125,1.745999569979403531760908663272857666015625,1.485712367177029591402970254421234130859375,1.46277037913159801973961293697357177734375,1.68886917700410776888020336627960205078125,2.342653111589015679783187806606292724609375,2.045406057342688654898665845394134521484375,2.514951386433267543907277286052703857421875,2.2377971937376059941016137599945068359375,2.2325278178932421724312007427215576171875,2.534153711700355415814556181430816650390625,2.536366456815585479489527642726898193359375,2.177945193225468756281770765781402587890625,2.30072168952710853773169219493865966796875,2.305166286845860668108798563480377197265625,2.122532869417000256362371146678924560546875,2.647083091789454556419514119625091552734375,1.980591652864632123964838683605194091796875,1.828076139205450090230442583560943603515625,1.389021786729927043779753148555755615234375,1.048578456500536049134097993373870849609375,-0.13604919197359777172096073627471923828125,-0.919488592863899611984379589557647705078125,-2.500652553129611987969838082790374755859375,-3.15361858963433405733667314052581787109375,-3.084009629013735320768319070339202880859375,-3.448971578041664542979560792446136474609375,-3.987698587318618592689745128154754638671875,-3.93807367519139006617479026317596435546875,-3.25428189678177659516222774982452392578125,-3.040940346056231646798551082611083984375,-2.1437138765877534751780331134796142578125,-2.1171358544806935242377221584320068359375,-1.8504384211400974891148507595062255859375,-1.054408655433917374466545879840850830078125,-0.690022480341212940402328968048095703125,0.12320998180666720145381987094879150390625,0.50550607832656169193796813488006591796875,0.7457416911138352588750422000885009765625,0.813397254295296079362742602825164794921875,0.989678006744725280441343784332275390625,0.815433289503971536760218441486358642578125,1.392179276339675197959877550601959228515625,1.014242569395946702570654451847076416015625,0.978735584883224873919971287250518798828125,0.43656796956520338426344096660614013671875,0.211083562985777462017722427845001220703125,0.138154429292399072437547147274017333984375,-0.95959821195583572261966764926910400390625,-0.945980988253495524986647069454193115234375,-2.305217343946651453734375536441802978515625,-4.02467520984146176488138735294342041015625,-6.192175553145943922572769224643707275390625,-7.370305607618547583115287125110626220703125,-7.72636462813761681900359690189361572265625,-8.7317913478264017612673342227935791015625,-8.155431092805883963592350482940673828125,-6.897272331198109895922243595123291015625,-6.313047128043990596779622137546539306640625,-3.86747478946927003562450408935546875,-1.88679291045673380722291767597198486328125,-1.603880166302360521513037383556365966796875,-1.392474945805361130624078214168548583984375,-0.312405178983453879482112824916839599609375,0.0218983204167670919559895992279052734375,-0.446917701330448835506103932857513427734375,1.270743847349194766138680279254913330078125,0.67272112767068392713554203510284423828125,0.65696747450829207082279026508331298828125,0.659959300192213049740530550479888916015625,1.066737078163669139030389487743377685546875,0.9298065120810861117206513881683349609375,0.44127249792063594213686883449554443359375,1.52448961296477136784233152866363525390625,1.40375424064995968365110456943511962890625,1.431144862696555719594471156597137451171875,1.377280233447663704282604157924652099609375,1.625820747632360507850535213947296142578125,1.596020301481303249602206051349639892578125,1.858248492586426436901092529296875,1.7232058384824995300732553005218505859375,1.25752563741980338818393647670745849609375], + ham_rw_c_mat = + [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,1.438939266971146935247816145420074462890625,-0.157629648730789995170198380947113037109375,-0.947895942049626683001406490802764892578125,-2.41112297743484305101446807384490966796875,-1.645022597631395910866558551788330078125,0.113186203368286442128010094165802001953125,2.500757110324911991483531892299652099609375,3.9750999926172880805097520351409912109375,7.89257448608304912340827286243438720703125,9.437652243032289334223605692386627197265625,9.09946173382968481746502220630645751953125,10.446621235585553222335875034332275390625,9.85481394165117308148182928562164306640625,6.86142471901302997139282524585723876953125,6.01051801158837406546808779239654541015625,6.8239911386017411132343113422393798828125,5.296827110250205805641598999500274658203125,4.97922099315110244788229465484619140625,4.903341821473077288828790187835693359375,2.84272950376407607109285891056060791015625,1.339333161830154494964517652988433837890625,1.255392997409217059612274169921875,-0.8900171783825499005615711212158203125,-1.67449512816483547794632613658905029296875,-1.0195432705904750037007033824920654296875,0.5290599832587759010493755340576171875,1.76532475573594638262875378131866455078125,4.144149596210581876221112906932830810546875,6.18611638184984258259646594524383544921875,7.271629741722108519752509891986846923828125,7.332590041323555851704441010951995849609375,7.0417599189740940346382558345794677734375,6.19670673510472624911926686763763427734375,4.383693703603739777463488280773162841796875,3.20583339587983573437668383121490478515625,1.11336211012121566454879939556121826171875,-1.9210012029507197439670562744140625,-3.2313238805900255101732909679412841796875,-2.103682523189718267531134188175201416015625,-1.603568993533599496004171669483184814453125,-0.26560440581170041696168482303619384765625,1.148544172864376378129236400127410888671875,0.93455988066170903039164841175079345703125,3.35992566174945750390179455280303955078125,5.973901019329105110955424606800079345703125,6.529076209629920413135550916194915771484375,5.14990744792476107249967753887176513671875,3.129743693537648141500540077686309814453125,1.21113612277486026869155466556549072265625,0.553616632830426169675774872303009033203125,1.77898715760193226742558181285858154296875,1.2765428377597345388494431972503662109375,1.490905557122232494293712079524993896484375,2.3584840945650284993462264537811279296875,3.174351186607736963196657598018646240234375,4.161953290686369655304588377475738525390625,4.83801065692341580870561301708221435546875,4.847516560284930164925754070281982421875,4.82576921203917663660831749439239501953125,4.43622204913435780326835811138153076171875,4.634402372677641324116848409175872802734375,4.52718592007431652746163308620452880859375,5.09511310633160974248312413692474365234375,5.87961334664350943057797849178314208984375,6.330933838923328949022106826305389404296875,6.874574433877796764136292040348052978515625,7.44733265515469611273147165775299072265625,8.29512513554846009355969727039337158203125,8.749486919410401242203079164028167724609375,9.635424360109709596144966781139373779296875,9.3003270339859227533452212810516357421875,9.281176968937188576092012226581573486328125,8.811349207926241433597169816493988037109375,8.0080731210109661333262920379638671875,7.32619484145971000543795526027679443359375,7.090051948733389508561231195926666259765625,6.290822882355996625847183167934417724609375,5.749458499235288400086574256420135498046875,5.7748652749187385779805481433868408203125,6.020591273371564966510049998760223388671875,6.462912438838202433544211089611053466796875,7.168025849300420304643921554088592529296875,6.93736707468769964179955422878265380859375,6.285549128728007417521439492702484130859375,5.993995590096119485679082572460174560546875,4.499330136073922403738833963871002197265625,3.530326810775704871048219501972198486328125,2.20523661197739784256555140018463134765625,1.35548095637795995571650564670562744140625,0.869699397463818968390114605426788330078125,0.98222968252639475394971668720245361328125,1.211053671833042244543321430683135986328125,2.067983693722226234967820346355438232421875,3.772833489608046875218860805034637451171875,4.56656321891068728291429579257965087890625,6.13639012603425726410932838916778564453125,7.378433956160051820916123688220977783203125,7.609988798018321176641620695590972900390625,7.60509527781914584920741617679595947265625,7.8992448854723988915793597698211669921875,7.079078359965706113143824040889739990234375,6.358056515571661293506622314453125,5.689879222016543280915357172489166259765625,3.12200445856115038623102009296417236328125,0.4760232353137325844727456569671630859375,-0.478466693364907769137062132358551025390625,-0.059544614913420446100644767284393310546875,-0.021787469727996722212992608547210693359375,0.95713972305702554876916110515594482421875,0.979891115463715323130600154399871826171875,1.616408385031036232248879969120025634765625,3.530931933573128844727762043476104736328125,6.002814286685179467895068228244781494140625,7.51006836435908553539775311946868896484375,7.84418093933572890819050371646881103515625,7.872261454255522039602510631084442138671875,7.799221817409488721750676631927490234375,9.114868603802960933535359799861907958984375,9.231073368346415009000338613986968994140625,9.7344433166335875284858047962188720703125,9.47504348367738202796317636966705322265625,8.83672204222830259823240339756011962890625,7.81844850591733120381832122802734375,7.15974442896686014137230813503265380859375,6.27334387489872824517078697681427001953125,3.55643241768439111183397471904754638671875,2.915382938215998365194536745548248291015625,2.527749050244210593518801033496856689453125,1.914940357013620086945593357086181640625,1.5209628053517008083872497081756591796875,1.26951607100136243388988077640533447265625,0.24233623879581500659696757793426513671875,-0.619538321510617606691084802150726318359375,-0.26116494342977603082545101642608642578125,-1.144984720546517564798705279827117919921875,-2.419544668681055554770864546298980712890625,-2.351744545951305553899146616458892822265625,-1.617559178840792810660786926746368408203125,-0.253932253389621109818108379840850830078125,1.45699388239745530881918966770172119140625,3.26036024852646733052097260951995849609375,5.008017124318939750082790851593017578125,6.680096554154033583472482860088348388671875,7.942466416457818922935985028743743896484375,8.34440157917924807406961917877197265625,7.93776918399453279562294483184814453125,7.185644174165872755111195147037506103515625,6.69096059920912011875770986080169677734375,5.726127929707445218809880316257476806640625,4.830669475533568402170203626155853271484375,4.70185640875888566370122134685516357421875,4.480502013160730712115764617919921875,4.36518518163620683480985462665557861328125,4.45601634856984674115665256977081298828125,4.585961838938374057761393487453460693359375,4.999236437411809674813412129878997802734375,5.459959290802771647577174007892608642578125,6.035703106018672770005650818347930908203125,5.901402807595104604843072593212127685546875,6.168276943169303194736130535602569580078125,6.185424972422651990200392901897430419921875,5.837999866287873373948968946933746337890625,5.42189832995018150541000068187713623046875,4.8806700976228967192582786083221435546875,4.820345295605875435285270214080810546875,4.218371933895468828268349170684814453125,3.262883753179949053446762263774871826171875,2.086475216250846642651595175266265869140625,0.886238663299309337162412703037261962890625,0.288403076536496882908977568149566650390625,-0.02307284106109364074654877185821533203125,-0.48256330578578854328952729701995849609375,-1.173327223594014867558144032955169677734375,-1.044006499668512333300895988941192626953125,-0.511692673554762222920544445514678955078125,0.307332306882699413108639419078826904296875,1.3002585111016742303036153316497802734375,2.205555599759463802911341190338134765625,2.83106021953381059574894607067108154296875,3.61447450436753570102155208587646484375,4.404726169050491080270148813724517822265625,4.9569050480249643442220985889434814453125,5.6102481468415135168470442295074462890625,5.91149668363505043089389801025390625,6.0967884645242520491592586040496826171875,5.73720778015194809995591640472412109375,5.614150610413844333379529416561126708984375,5.212900890308674206607975065708160400390625,4.956019552993211618741042912006378173828125,4.7252615526149384095333516597747802734375,4.39053717927527031861245632171630859375,4.20016985197389658424071967601776123046875,4.2590976279070673626847565174102783203125,4.6019981319795988383702933788299560546875,4.736445875058734600315801799297332763671875,5.132963523597709354362450540065765380859375,5.05884360266963994945399463176727294921875,5.1309992362921548192389309406280517578125,5.136221343385614090948365628719329833984375,5.190352360552196842036210000514984130859375,4.9913654597503409604541957378387451171875,4.981399724620814595255069434642791748046875,4.883446714399951815721578896045684814453125,4.8777165324418092495761811733245849609375,5.009907159743534066365100443363189697265625,4.645331694080823581316508352756500244140625,4.32479387410103299771435558795928955078125,3.941631583091975699062459170818328857421875,3.45480265911692185909487307071685791015625,2.45696061425815059919841587543487548828125,1.53070454602629979490302503108978271484375,0.171896827857608514023013412952423095703125,-0.6823727210858123726211488246917724609375,-1.0587747664440030348487198352813720703125,-1.408147176562806635047309100627899169921875,-1.69129834964724068413488566875457763671875,-1.911918005096367778605781495571136474609375,-1.605386158530336615513078868389129638671875,-1.153885373025332228280603885650634765625,-0.295845764529303778544999659061431884765625,0.339862320254042060696519911289215087890625,0.843513907019541875342838466167449951171875,1.21381598877678698045201599597930908203125,1.6377923892387116211466491222381591796875,2.22554524161250810720957815647125244140625,2.847059607560595395625568926334381103515625,3.256175376090823192498646676540374755859375,3.42858046566470875404775142669677734375,3.6612411654559764428995549678802490234375,3.39124274224241162301041185855865478515625,3.541594582877223729155957698822021484375,3.413118508980915066786110401153564453125,3.40755009567646993673406541347503662109375,3.036551491683212589123286306858062744140625,2.58385018633407526067458093166351318359375,2.36791319851408843533135950565338134765625,1.6178715878950242768041789531707763671875,1.0005739481466662255115807056427001953125,-0.074543969775504592689685523509979248046875,-1.7802094473454417311586439609527587890625,-3.89081009916890252497978508472442626953125,-5.25194542680264930822886526584625244140625,-5.856145865982171017094515264034271240234375,-6.444749336898212277446873486042022705078125,-6.24597005574969443841837346553802490234375,-5.354773822487686629756353795528411865234375,-4.798920414391659505781717598438262939453125,-3.01433520435830359929241240024566650390625,-0.933969839965584469609893858432769775390625,0.706550098861725928145460784435272216796875,1.608368765698969582444988191127777099609375,2.4005629316607155487872660160064697265625,2.93204951001871449989266693592071533203125,2.653557870351733072311617434024810791015625,3.155883891544135622098110616207122802734375,3.186238032700885014492087066173553466796875,3.308829343967090608202852308750152587890625,3.220805061698001736658625304698944091796875,3.33569781159530975855886936187744140625,3.300165569128921561059542000293731689453125,3.130050390193673592875711619853973388671875,3.5220456527358692255802452564239501953125,3.6680007788017974235117435455322265625,3.867215350730475620366632938385009765625,3.802629580577331580570898950099945068359375,3.9257969357995534664951264858245849609375,3.896438620460912716225720942020416259765625,4.1063327389174446580000221729278564453125,4.060228252759088718448765575885772705078125,3.768404113545329892076551914215087890625], + hp_c_mat = + [0.407431001005306825391016900539398193359375,0.4579401602813959470950067043304443359375,0.93912173677063037757761776447296142578125,1.377959682335131219588220119476318359375,1.19187195312815674697048962116241455078125,1.558045862658900659880600869655609130859375,1.712963252897679922170937061309814453125,0.6884244918546755798161029815673828125,-1.5345120235679132747463881969451904296875,-3.139931218246829303097911179065704345703125,-3.53271121675425092689692974090576171875,-4.666877646513967192731797695159912109375,-4.221675713357626591459847986698150634765625,-2.252310393678499167435802519321441650390625,0.123164010635946397087536752223968505859375,0.404549381016522602294571697711944580078125,1.940849018771814371575601398944854736328125,1.744212341848424330237321555614471435546875,0.908480285900850503821857273578643798828125,1.054783500752591862692497670650482177734375,0.883322229370833156281150877475738525390625,-0.1235374204197796643711626529693603515625,1.457210286927647757693193852901458740234375,2.64292966247785443556495010852813720703125,2.7724383492231936543248593807220458984375,2.401513175538639188744127750396728515625,1.64907671172704795026220381259918212890625,-0.09769869638103045872412621974945068359375,-1.60462476931934361346065998077392578125,-2.53433598145920768729411065578460693359375,-2.950438603197426346014253795146942138671875,-2.41734515404868943733163177967071533203125,-1.51916469707748547079972922801971435546875,-0.244160430633883152040652930736541748046875,0.325020974198878320748917758464813232421875,1.036524594884895122959278523921966552734375,1.65202230515706105506978929042816162109375,1.89547708725513075478374958038330078125,1.639340459399818428209982812404632568359375,1.993351330349241834483109414577484130859375,2.1694881755092865205369889736175537109375,1.761514503153875921270810067653656005859375,1.2833542982980361557565629482269287109375,0.025593474450261055608280003070831298828125,-2.285771564406104516820050776004791259765625,-3.2686077618063791305758059024810791015625,-2.341841667275502913980744779109954833984375,-1.463300149160886576282791793346405029296875,0.044788478260670672170817852020263671875,1.01709538783370589953847229480743408203125,0.267130371733173888060264289379119873046875,1.357330218576635161298327147960662841796875,1.56795390644356302800588309764862060546875,1.037895483457077716593630611896514892578125,0.47444677237581345252692699432373046875,-0.787799543341179742128588259220123291015625,-1.33121018945666946819983422756195068359375,-1.1646938716030490468256175518035888671875,-0.855190640211048958008177578449249267578125,-0.451856724208710147649981081485748291015625,-0.229997969282294434378854930400848388671875,-0.113367514177525663399137556552886962890625,-0.097533045438694898621179163455963134765625,-0.621668128620285642682574689388275146484375,-0.74827445842674933373928070068359375,-0.838226516722670567105524241924285888671875,-0.820489528701045855996198952198028564453125,-1.07829371446905497577972710132598876953125,-0.928966734927826109924353659152984619140625,-1.18654358462072195834480226039886474609375,-0.86277227281016166671179234981536865234375,-0.851446952538253754028119146823883056640625,-0.7603938487600316875614225864410400390625,-0.52041570903247702517546713352203369140625,-0.119100776680852504796348512172698974609375,0.310618187447516902466304600238800048828125,0.78689102529779120231978595256805419921875,1.32376348425123069318942725658416748046875,1.258879108841256311279721558094024658203125,1.235858809463024954311549663543701171875,0.879358407549943876801989972591400146484375,0.373606962927851782296784222126007080078125,0.1826399577048505307175219058990478515625,0.49408103848918472067452967166900634765625,0.313288726785913240746594965457916259765625,0.471175202638505652430467307567596435546875,0.610502063317881038528867065906524658203125,1.02518272805036758654750883579254150390625,1.313298643033476764685474336147308349609375,1.72255729914513722178526222705841064453125,1.51543988884577629505656659603118896484375,1.390350118934520651237107813358306884765625,1.1294041360970368259586393833160400390625,-0.0050883240101029514335095882415771484375,-0.64732781380143933347426354885101318359375,-1.390588445370440240367315709590911865234375,-1.810019741244104807265102863311767578125,-1.772417185498170510982163250446319580078125,-1.782152292831369777559302747249603271484375,-1.621845591574356149067170917987823486328125,-0.99451370698670871206559240818023681640625,-0.413095639963330540922470390796661376953125,-0.264566812811608542688190937042236328125,0.551535882038706404273398220539093017578125,1.362463416876153132761828601360321044921875,1.623781318284500230220146477222442626953125,1.608242817731706963968463242053985595703125,2.069680372688026182004250586032867431640625,1.890560595829128942568786442279815673828125,1.76794059575286155450157821178436279296875,1.263276943658638629131019115447998046875,-0.482140297490104785538278520107269287109375,-2.32705507151104029617272317409515380859375,-3.053243976062049114261753857135772705078125,-2.7106669966606204980053007602691650390625,-2.30177940497060262714512646198272705078125,-1.6207910775547134107910096645355224609375,-1.864270061536217326647602021694183349609375,-1.89490282112410568515770137310028076171875,-1.8989734728265830199234187602996826171875,-1.44571415380005419137887656688690185546875,-0.82784373990944004617631435394287109375,-0.293341480204389881691895425319671630859375,0.031549884870628375210799276828765869140625,0.565124647175025529577396810054779052734375,1.606755263916284093284048140048980712890625,1.710394557793961212155409157276153564453125,2.2789639590637307264842092990875244140625,2.59364139589115438866429030895233154296875,2.7432899845762221957556903362274169921875,2.474109211896802662522532045841217041015625,2.392355155250470488681457936763763427734375,2.32030377695582501473836600780487060546875,0.944285211834767324035055935382843017578125,0.71330028016609503538347780704498291015625,1.1969131864252631203271448612213134765625,1.187423806414017235510982573032379150390625,1.20808982938387998729012906551361083984375,0.92007792997173964977264404296875,0.003607282620805563055910170078277587890625,-0.78480949883260109345428645610809326171875,-1.70920836389495889306999742984771728515625,-2.78639764089211894315667450428009033203125,-3.597069762703313244855962693691253662109375,-3.615346921977788952062837779521942138671875,-2.99047232693692421889863908290863037109375,-2.091747328267729244544170796871185302734375,-1.511995337467624267446808516979217529296875,-0.73858056784365544444881379604339599609375,-0.1717592850918663316406309604644775390625,0.16369273824830088415183126926422119140625,0.36389055345580345601774752140045166015625,0.5130826350750794517807662487030029296875,0.52051311560717294923961162567138671875,0.4839955182005724054761230945587158203125,0.415486045545321758254431188106536865234375,0.100265680309576055151410400867462158203125,-0.323367483803167488076724112033843994140625,-0.18441127663891165866516530513763427734375,-0.247335837395212365663610398769378662109375,-0.23049470787418613326735794544219970703125,-0.12533221393869098392315208911895751953125,-0.001402664372335493681021034717559814453125,0.39753442460687438142485916614532470703125,0.62125205276652195607312023639678955078125,0.876005110767664518789388239383697509765625,1.00778916686658703838475048542022705078125,1.362661495199063210748136043548583984375,1.56993175406341833877377212047576904296875,1.52086608061517836176790297031402587890625,1.438239096802817584830336272716522216796875,1.51724437223447239375673234462738037109375,1.908188608489354010089300572872161865234375,1.788578463020030540064908564090728759765625,1.185542666219362217816524207592010498046875,0.570162018117343905032612383365631103515625,-0.23884351563219752279110252857208251953125,-0.731165536324851927929557859897613525390625,-1.0061269551542864064686000347137451171875,-1.307557135162142003537155687808990478515625,-1.571529268300537296454422175884246826171875,-1.570534088932845406816340982913970947265625,-1.693715069171275899861939251422882080078125,-1.583354574465147379669360816478729248046875,-1.52882425123198117944411933422088623046875,-1.275281773769165738485753536224365234375,-1.107342902292657527141273021697998046875,-0.82392428895263947197236120700836181640625,-0.5048975739964589593000710010528564453125,-0.1606920909589462098665535449981689453125,0.1650906151744493399746716022491455078125,0.38233316741707312758080661296844482421875,0.442063742244499735534191131591796875,0.173242417938809012412093579769134521484375,0.07445107112152982153929769992828369140625,-0.16704668603733807685784995555877685546875,-0.2084038525399591890163719654083251953125,-0.178547648187304730527102947235107421875,-0.251607476852086620056070387363433837890625,-0.269804285786449327133595943450927734375,-0.1773383942754662712104618549346923828125,-0.11033106618151578004471957683563232421875,-0.061997754730327869765460491180419921875,0.12625321141376844025216996669769287109375,0.065452031550876199617050588130950927734375,0.2442919706909378874115645885467529296875,0.2759707447467008023522794246673583984375,0.434381769171750420355238020420074462890625,0.473240086353371225413866341114044189453125,0.698065589500174610293470323085784912109375,0.83772984650249782134778797626495361328125,1.22962484602021504542790353298187255859375,1.528506652570058577111922204494476318359375,1.585719905885298430803231894969940185546875,1.551689928335463264374993741512298583984375,1.589233494011523362132720649242401123046875,1.405811634224619410815648734569549560546875,0.893664122797645177342928946018218994140625,0.357745136446510514360852539539337158203125,-0.37532970050096992054022848606109619140625,-0.720053251691069817752577364444732666015625,-0.8570871937636184156872332096099853515625,-1.090774373487647608271799981594085693359375,-1.22150996133359512896277010440826416015625,-1.546274651557951074209995567798614501953125,-1.7072039774657241650857031345367431640625,-1.778676562997361543239094316959381103515625,-1.66803159479013629606924951076507568359375,-1.4128217146489987499080598354339599609375,-1.096815066289536844124086201190948486328125,-1.018596015952425659634172916412353515625,-0.784334592955246989731676876544952392578125,-0.573753152380731989978812634944915771484375,-0.152119194511897148913703858852386474609375,0.16630369114182030898518860340118408203125,0.455167453839067093213088810443878173828125,0.97797334572487670811824500560760498046875,1.090799095231659521232359111309051513671875,1.419336081429491969174705445766448974609375,1.658135196227931373869068920612335205078125,2.0275850517136859707534313201904296875,2.270929144751562489545904099941253662109375,2.352854387215984388603828847408294677734375,2.659188354088428241084329783916473388671875,2.6749053698376883403398096561431884765625,2.4138962561546577489934861660003662109375,1.901192060138555461890064179897308349609375,0.64769337357347467332147061824798583984375,-0.911822984698801519698463380336761474609375,-1.89030567186955522629432380199432373046875,-2.32435373427642844035290181636810302734375,-2.575632267844639500253833830356597900390625,-2.390612659943826656672172248363494873046875,-1.850329621584023698233067989349365234375,-1.954305666926984486053697764873504638671875,-1.62169421989392503746785223484039306640625,-1.34238906594919171766377985477447509765625,-0.955265031691169497207738459110260009765625,-0.785808495563514952664263546466827392578125,-0.55722366845793658285401761531829833984375,-0.158642501327676654909737408161163330078125,-0.2132093178342984174378216266632080078125,-0.123884716834027130971662700176239013671875,-0.05786882691199934924952685832977294921875,0.0627524397486922680400311946868896484375,0.09887292516987145063467323780059814453125,0.140282095432894493569619953632354736328125,0.111518097715816111303865909576416015625,0.139796612940926934243179857730865478515625,0.298754307769513616221956908702850341796875,0.37718109332172389258630573749542236328125,0.506757534015605415333993732929229736328125,0.447605874257305913488380610942840576171875,0.51108847658406375558115541934967041015625,0.4453905308037064969539642333984375,0.565245173393122968263924121856689453125,0.50084323903502081520855426788330078125,0.334042958698546499363146722316741943359375]) df[:data] = 100*log.(df[:empl]) @testset "test hp filter" begin df[:hp_c], df[:hp_t] = hp_filter(df[:data], 1600) - @show df[:hp_c] - @show df[:hp_c_mat] @test isapprox(df[:hp_c], df[:hp_c_mat]) end diff --git a/test/util.jl b/test/util.jl index 70b80dd8..a0a38445 100644 --- a/test/util.jl +++ b/test/util.jl @@ -5,14 +5,13 @@ Utilities for testing QuantEcon @date: 2014-08-26 =# -using HDF5, JLD, MAT, CSV +using HDF5, JLD, MAT, DataFrames const test_path = dirname(@__FILE__()) const data_path = joinpath(test_path, "data") const quad_data_file_name = joinpath(data_path, "matlab_quad.mat") const ml_quad_data_url = "https://github.com/spencerlyon2/QuantEcon.jl/releases/download/v0.0.1/matlab_quad.mat" -const filter_data_file_name = joinpath(data_path, "employment.csv") if !(isfile(quad_data_file_name)) try From 7ceacadcb50d94bd81c112c1d73e8d9780a4fac0 Mon Sep 17 00:00:00 2001 From: Shunsuke Hori Date: Mon, 26 Mar 2018 20:09:58 -0700 Subject: [PATCH 8/8] be more specific --- src/filter.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/filter.jl b/src/filter.jl index e32a10dc..3add618e 100644 --- a/src/filter.jl +++ b/src/filter.jl @@ -77,7 +77,7 @@ Note: For seasonal data, it's desirable for `p` and `h` to be integer multiples - `y_cycle::Vector` : cyclical component - `y_trend::Vector` : trend component """ -function hamilton_filter(y::AbstractVector, h::Integer, p::Integer) +function hamilton_filter(y::Vector, h::Integer, p::Integer) T = length(y) y_cycle = fill(NaN, T) @@ -132,7 +132,7 @@ Note: For seasonal data, it's desirable for `h` to be an integer multiple - `y_cycle::Vector` : cyclical component - `y_trend::Vector` : trend component """ -function hamilton_filter(y::AbstractVector, h::Integer) +function hamilton_filter(y::Vector, h::Integer) T = length(y) y_cycle = fill(NaN, T) y_cycle[h+1:T] = y[h+1:T] - y[1:T-h]