1
$\begingroup$

I have time series measured every 10 seconds with missing periods in between and a repeating pattern.How do I handle this data to fit a model and forecast the future using R

$\endgroup$
3
$\begingroup$

I would recommend a two step approach:

1. Imputation / Estimation (replacing missing values with resonable values). This is a interpolation task.

2. Forecasting (predicting future values). This is a extrapolation task.

Most forecasting methods require time series without NAs, that's why the imputation step is required.

Assuming you have a univariate time series (just one attribute observed over time), an R approach could include the packages

Both packages provide multiple algorithms, you would have to choose the best one for your specific dataset.

I will provide you an example for algortihms, which I think perform good in most of the cases:

library(imputeTS)
library(forecast)

# tsAirgap is a example time series with missing data included in imputeTS package
x <- tsAirgap

#Replace missing data using na.kalman method from imputeTS
x <- na.kalman(x)

#Perform a forecast using ets method from forecast
# The h parameter specifies how far in the future to forecast
result <- forecast(ets(x),h=10)$mean

#This is the result
result

This is the solution for univariate time series. Beware, AMELIA, which was mentioned in another answer does not work for univariate data.

If you have multivariate time series (two or more variables observed over time) the solution would look different. Here imputeTS would not work and now the AMELIA or mice or VIM packages would have to be used.

$\endgroup$
0
$\begingroup$

Dealing with missing data in time series is generally called imputation.

There are several methods for imputing, which are/can be selected depending on the nature of the series.

The Amelia library in R, would help you deal with missing data.

$\endgroup$
  • 1
    $\begingroup$ Please show a concrete example, not only links. $\endgroup$ – user81847 Nov 26 '15 at 7:22
  • $\begingroup$ Thank You.Is it possible to separate the data based on the breaks abd apply some methods ? $\endgroup$ – MRI Nov 26 '15 at 7:23
  • $\begingroup$ @Pascal What do you mean by a concrete example? These links are enough for the OP to handle the problem. $\endgroup$ – Dawny33 Nov 26 '15 at 7:26
  • $\begingroup$ @MRI Why would you want to separate the data based on the breaks. If the missing data is not due to human or any other error, then doing so makes else. Else, No $\endgroup$ – Dawny33 Nov 26 '15 at 7:27
  • $\begingroup$ For example, you create a time serie with missing value and you show how to implement the Amelia solution. $\endgroup$ – user81847 Nov 26 '15 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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