4
$\begingroup$

I have the following time series

1.3578511
0.5119648
1.3189847
0.9214787
1.2272616
4.9167998
1.2272616
1.2272616
0.8854192
2.3386331
1.6132899
0.2030302
0.8426226
1.2277843
NA
1.3189847
1.3578511
0.8530141
2.3386331
1.0541099
0.7747481
0.5764672
1.3189847
1.2160533
1.2272616
0.6715839
0.9651803
1.6132899
1.2006974
0.6875047
1.3245534
1.2006974
0.8221709
1.3101684
1.6132899
1.6132899
1.2006974
1.3189847
1.0018480
1.2277843
1.4424190
1.6132899
1.2277843
1.2006974
0.7779642
0.9381081
0.8854192
NA
NA
1.3189847
1.1070461
0.8221709
4.9167998
0.9214787
1.3189847
1.3189847
1.2277843
1.4424190
1.6132899
1.6132899
4.9167998
0.8235792
0.9708839
1.1070461
1.2160533
0.8354292
1.4424190
1.1958634
0.5119648
1.4424190
1.4424190
1.6132899
1.6132899
0.6710844
1.2272616
0.9708839
0.8890464
1.4424190
0.8890464
0.8221709
1.1958634
0.8132233
0.4630722
4.9167998
0.8890464
1.3189847
0.7373181
1.1070461
1.2279813
0.8890464
0.3588158
1.4424190
0.8132233
0.4297043
1.3578511
4.9167998
1.2272616
0.8426226
1.4424190
1.6132899
NA

in which NA are missing values, and I want to predict/forecast it. I searched over internet, but I haven't found that the Amelia package can impute missing values.

I used it as follows:

library(Amelia)
t <- read.table("C:\\Users\\exam\\Desktop\\missing_ts.txt")
a.out <- amelia(t)

but I got the following error:

Amelia Error Code:  42 
There is only 1 column of data. Cannot impute

Likewise,

amelia(x=as.matrix(1:101,t$V1))

resulted in

Amelia Error Code:  39 
Your data has no missing values.  Make sure the code for 
missing data is set to the code for R, which is NA.

Is there something wrong in the way I'm trying to forecast this time series? If yes, then what method should I use?

$\endgroup$

3 Answers 3

3
$\begingroup$

This data enter image description herehas similar statistical characteristics identical except for the placement of the anomalies ( i.e. non time series data riddled by a number of pulses AND missing values as Which model should I prefer for time series forecasting?. As Micheal Chernick has suggested identify and estimate a parsimonious model enter image description here providing actual/fit/forevast enter image description here . Now a review of the identified interventions which reflects adjustments for both unusual data and NA data which is treated as a "0.0" to begin with we see enter image description here . The estimates of the three missing values are simply 1.123 per the equation. The missing value (NA) at the end of the series is simply the 1 period out forecast which in this case is 1.123. This query and my answer points out that Intervention Detection is in reality the imputation for bad/missing values. Now another trick suggested to me about 30 years by T.W. Anderson was to reverse the time series and like Michael reflected predict backwards. In my opinion for AMELIA to delivery anything useful the robust estimate of the mean (1.123) would have had to be suggested. For AMELIA to do this it would have had to detect the anomalies and to identify an approriate underlying ARIMA model of (0,0,0)(0,0,0) or maybe that model is assumed. If the series had seasonal pulses , level shifts and/or local time trends , procedures like AMELIA my come up short. It looks like AMELIA doesn't handle univariate time series [ Amelia Error Code: 42 There is only 1 column of data. Cannot impute ] or maybe even multivariate time series unless it makes a ton of assumptions about dependencies.

$\endgroup$
1
$\begingroup$

Read Box and Jenkins book. They call it backcasting. Fit an ARMA model to the data by conditional maximum likelihood. Then use the data after the missing value and use the model to predict the value of the missing point like forecasting but going back in time instead. You could also forecast using the time points preceding and average the two.

$\endgroup$
0
$\begingroup$

Actually forecasting might not be the correct term here. Substitution of NAs within a time series is rather referred to as imputation.

Usually forecasting means you are doing extrapolation, while at imputation (or also estimation) you are interpolating. You are able to interpolate here, because you have data before and after the NA available.

The problem you have is, that a lot of R packages for imputation like Amelia do not work for univariate time series data. (see also http://arxiv.org/abs/1510.03924 )

You can solve this by adding one or more lags of the actual time series as additional attributes to your dataset.

You can also have a look at the imputeTS package on Cran, which is able to work with univariate time series. (https://cran.r-project.org/web/packages/imputeTS/index.html)

Also the forecast and the zoo packages have imputation methods.

You can also as mentioned before use the forecast package to fit an arima model. You could do a combination of a forecast and a backcast, in order to fill the gaps.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.