Temporal Disaggregation Of Time Series In Python
I am trying to find a package that enables temporal disaggregation of timeseries. There is a package in R called tempdisagg. https://journal.r-project.org/archive/2013/RJ-2013-028
Solution 1:
I've created an open source Python package called timedisagg that is based on the R tempdisagg package. The package implements the basic Chow-Lin and Litterman methods. It also allows for basic average, sum, first and last conversion choices like the R package.
Given the following function call in R to disaggregate sales.a
as a function of exports.q
:
model <- td(sales.a ~ 0 + exports.q,method="chow-lin-maxlog",conversion="sum")
A similar call can be made using timedisagg as below:
from timedisagg.td importTempDisaggtd_obj= TempDisagg(conversion="sum", method="chow-lin-maxlog")
final_disaggregated_output = td_obj(expected_dataset)
where the expected_dataset
is a pandas dataframe with the following format:
indexgrainXy01972 11432.63900 NaN11972 21456.89100 NaN21972 31342.56200 NaN31972 41539.39400 NaN41973 11535.75400 NaN51973 21578.45800 NaN61973 31574.72400 NaN71973 41652.17100 NaN81974 12047.83400 NaN91974 22117.97100 NaN101974 31925.92600 NaN111974 41798.19000 NaN121975 11818.81700 136.702329131975 21808.22500 136.702329141975 31649.20600 136.702329151975 41799.66500 136.702329161976 11985.75300 151.056074171976 22064.66300 151.056074181976 31856.38700 151.056074191976 41919.08700 151.056074..............1522010 119915.79514988.3096761532010 219482.48000988.3096761542010 318484.64900988.3096761552010 418026.46869988.3096761562011 119687.52100NaN1572011 218913.06608NaN
Here X is is exports.q
and y is sales.a
.
The output final_disaggregated_output
will appear as below where y_hat
is the disaggregated sales:
indexgrainXyy_hat01972 11432.639 NaN21.65687911972 21456.891 NaN22.21973721972 31342.562 NaN20.85541331972 41539.394 NaN23.93791641973 11535.754 NaN24.229008
Edit - If someone needs help working their data into my package, feel free to raise an issue at the git for the package.
Post a Comment for "Temporal Disaggregation Of Time Series In Python"