0
$\begingroup$

I have an univariate time series with daily values of temperature over 60 years with missing values. The size of the gaps varies from a day to a couple of years. My goal is:

  • to impute the missing values
  • to estimate the uncertainty at each day to generate an heatmap (x-axis: days and y-axis: year).

My first thought is to fit a curve going through all the points and then calculate the absolute difference between the true value and the predicted value at each day. I am conscious that I won't have any uncertainty estimation when a value is missing.

Is my approach correct? If yes, how can I do this? If no, do you have any better ideas?

Note:

  • There is definitely a trend and seasonal effect in the time series
  • I am ready to assume stationarity
  • I am coding in R
$\endgroup$
  • $\begingroup$ Facebook Prophet does all of that, and also doesn't require stationarity. $\endgroup$ – Skander H. Jul 7 '18 at 10:19
0
$\begingroup$

You can use Arima combined with kalman smoothing. Below is the code implemented in R:

#Install and load imputeTS package
install.packages("imputeTS")
library(imputeTS)

#Create a time series
myts <- AirPassengers

#Plot the time series
plot(myts)

#Create missing values
missing_index <- c(30:50, 70:80, 120:130)
myts[missing_index] <- NA

#Fit arima model combined with Kalman smoothing
imp <- na.kalman(myts, model = "auto.arima", smooth = TRUE)

#Plot the imputed part
imp[setdiff(seq(1,length(myts)), missing_index)] <- NA    
lines(imp, col = "blue")

There is a very nice paper which describes diverse techniques of imputations for univariate time series available here: https://arxiv.org/pdf/1510.03924.pdf

For more details regarding forecasting or imputations, I would recommend this book: https://robjhyndman.com/uwafiles/fpp-notes.pdf

$\endgroup$

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.