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

Temporal disaggregation of quarterly time series fails #17

Closed stefanle closed 10 years ago

stefanle commented 10 years ago

Due to probably incorrect time series attributes (handling) td fails in some cases. For example the following produces an error: td(defl_x_tot1 ~ ppi, to = 12, conversion = "last") Error: identical(dim(C)[2], dim(X)[1]) is not TRUE

Changing line 33-38 in td.calc.R and substituting n.fc (which is not always identical to an integer although it looks on screen like an integer) solves the problem.

if (n.fc > 0){ C <- cbind(C, matrix(0, nrow=n_l, ncol = n - fr * n_l)) } if (n.bc > 0){ C <- cbind(matrix(0, nrow=n_l, ncol = n - fr * n_l), C) }

Maybe you can provide a better workaround or enlighten me how to adjust attributes(ppi) in order to avoid this problem...

christophsax commented 10 years ago

This seems to be the same problem:

> require(tempdisagg)
Loading required package: tempdisagg
> s1.q = ts(c(1,2,3), start=c(2000,1), frequency=4)
> s2.m = ts(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14), start=c(2000,1), frequency=12)
> z = td(s1.q ~ s2.m, conv="first")
Error: identical(dim(C)[2], dim(X)[1]) is not TRUE
christophsax commented 10 years ago

underlying problem:

> as.integer(4.9999999999999)
[1] 4
> as.integer(round(4.9999999999999))
[1] 5