Dear Rmetrics core team,
sorry for bothering you again, but do you have any news on the issue described in the mail below?

Thanks,
Marco Giuliano

From: Marco Giuliano
Sent: martedì 2 ottobre 2012 18:41
To: 'Rmetrics-core@r-project.org'
Subject: TimeSeries align odd behavior

Dear Rmetrics-core team,
I have a question about a strange behavior of timeSeries align function.

For example, consider the following timeSeries:
> TS <- timeSeries(c(1,NA,3,4),
                   charvec=c('2010-01-01','2010-01-02','2010-01-03','2010-01-05'),
                   format='%Y-%m-%d', zone='GMT', units='V')

> TS
GMT
            V
2010-01-01  1
2010-01-02 NA
2010-01-03  3
2010-01-05  4

If we call the function align, with method='fillNA':
> align(TS,by='day',include.weekends=T,method='fillNA')
we get the following result:
> GMT
            V
2010-01-01  1
2010-01-02  2
2010-01-03  3
2010-01-04 NA
2010-01-05  4

So, basically the NA in the original timeSeries is interpolated and then the missing day is correctly added by setting the value to NA.
That doesn't seem correct to me, since only the missing days of the timeSeries should be filled with NA, while the other values should remain unchanged (in particular in case of fillNA method).

Looking at the code, it appears clear what happens: when the method is fillNA, an approxfun with method "linear" is applied. Then to replace the interpolated values with NA the following code is performed:
if (Method == "fillNA")
      yout[!(xout %in% u)] = NA
but obviously this code will put NA only in the missing dates added to the original ts and not to ALL the interpolated values.

Is this the desired behavior?
If so, in my opinion should be clearly specified in the align documentation.


Thanks in advance for any answer and thanks a lot for your work on this great package.

Regards,
Marco Giuliano




________________________________

ORS Srl

Via Agostino Morando 1/3 12060 Roddi (Cn) - Italy
Tel. +39 0173 620211
Fax. +39 0173 620299 / +39 0173 433111
Web Site www.ors.it

------------------------------------------------------------------------------------------------------------------------
Qualsiasi utilizzo non autorizzato del presente messaggio e dei suoi allegati è vietato e potrebbe costituire reato.
Se lei avesse ricevuto erroneamente questo messaggio, Le saremmo grati se provvedesse alla distruzione dello stesso
e degli eventuali allegati.
Opinioni, conclusioni o altre informazioni riportate nella e-mail, che non siano relative alle attività e/o
alla missione aziendale di O.R.S. Srl si intendono non attribuibili alla società stessa, né la impegnano in alcun modo.

	[[alternative HTML version deleted]]

