christophsax / tempdisagg

Methods for Temporal Disaggregation and Interpolation of Time Series
http://cran.r-project.org/web/packages/tempdisagg
36 stars 5 forks source link

Non-negative constraint in disaggregated numbers #42

Open AdamElderfield opened 4 years ago

AdamElderfield commented 4 years ago

Hi,

Great package, thanks for all your work so far!

I have question, is it possible to impose a constraint that the disaggregated data not go negative? This happens when annual data is close to zero.

Thanks

Adam

christophsax commented 4 years ago

Need to look into it. Can you provide a reproducible example? Thank you!

wian-boonzaaier commented 3 years ago

Hi,

I have also experienced the non-negative constraint issue when working with near-zero observations. Here is an example with no indicator variable using Denton-Cholette and truncated.rho = 0):

library(tempdisagg)
library(zoo)

lfreq <- c(0.5496272909, 0.5053369531,
           0.3997841521, 0.2173665480,
           0.1641758216, 0.1990214600,
           0.0791224856, 0.0011010778,
           0.0008603003, 0.0006170139,
           0.0003076042) 

lfreq <- ts(lfreq,
            start=2010,
            frequency=1)

denton <- td(lfreq ~ 1, to = "quarterly", method = "denton-cholette", conversion = "mean", truncated.rho=0)

as.matrix(predict(denton))

I would appreciate your thoughts on this. The quarterly SNA handbook only references the transformation of zeroes to near zeroes, which in this case should not be a problem.

Sincerely,

Wian