4

I am dealing with a forecast of time series in R. I have several questions:

  1. I would like to ask how we can handle missing values in time series?
  2. I guess we can somehow interpolate them?
  3. Can you suggest some solution in R for this?
Artem
  • 3,304
  • 3
  • 18
  • 41
syeenn
  • 191
  • 2
  • 3
  • 11
  • Check the `mice` package. – hpesoj626 Apr 27 '18 at 14:18
  • As addition to hpesoj626's answer: Be a little bit careful, mice does only work if you have a multivariate time-series (with more than 1 variable). Might make sense to use a package that is specialized especially in time-series imputation as suggested in Artem's answer. – Steffen Moritz Aug 07 '18 at 19:24
  • You might get better results asking on http://stats.stackexchange.com since they'd be able to help you with the actual statistics of your problem, not just the programing parts of it – divibisan Aug 07 '18 at 19:35

2 Answers2

3

One of the solutions imputeTS library.

library(imputeTS)

# amount of NA
table(is.na(tsAirgap))

# Kalman smoothing imputation (one of the best)
imp_tsAirgap <- na_kalman(tsAirgap)

# Imputed time-series, no NAs
table(is.na(imp_tsAirgap))
Steffen Moritz
  • 7,277
  • 11
  • 36
  • 55
Artem
  • 3,304
  • 3
  • 18
  • 41
1

If you would like to delete the missing values and their corresponding time-stamps, you can also use the na.remove function within the tseries package.