[R] Internal NA removal out of Time Series with na.omit.ts()
kjetil@entelnet.bo
kjetil at entelnet.bo
Tue Mar 9 03:20:00 CET 2004
On 8 Mar 2004 at 15:29, Jan Verbesselt wrote:
> Thanks for the tips and advice!
>
> I found out how the NA's came into the time series. By a threshold
> mechanism, extreme values (outliers) are removed from the time series
> (environmental data, remote sensing data) and set as NA. A solution
> could be to detect an outlier and replace it by the quadratic fit of 2
> values before and 2 values after the outlier.
>
> In R, 'lsfit does a least squares fit on the available data but can
> this be used on time series since values are auto correlated?
>
> Are there R-functions that "fit or interpolate" a new value based on a
> set window around the outlier valid for seasonal time series? Which
> function is the best to use?
>
Can something along this lines be of use?
(R1.8.1, on windows XP)
test <- arima.sim(model=list(ar=0.4, ma=0.4), n=100)
test[51:53] <- NA
test.m1 <- arima(test, order=c(1,0,1) )
test.sm <- KalmanSmooth(test, test.m1$model)$smooth
> cbind(test, test.sm)[50:55, ]
test test.sm.Series 1 test.sm.Series 2
[1,] 0.8719321 0.8719321 0.251871564
[2,] NA 0.7359504 0.000512806
[3,] NA 0.4116944 0.000928828
[4,] NA 0.2370341 0.001682354
[5,] 0.2366336 0.2366336 0.019878832
[6,] 0.5924668 0.5924668 0.084405316
?
Kjetil Halvorsen
> Thanks,
> Jan
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list