I am currently using the ARIMA provided in R. I use the data as the rainfall time series in QuyNhon (Vietnam) from 2000 to 2017 to forecast rainfall for the next several years. I wish that the professor could answer for me if I have used the ARIMA model to accurately predict. If the model is wrong, I hope professor can help me rewrite the R code to forecast rainfall more accurately.

I hope that the professor gives me a 95% confidence interval that is correct for rain forecast. And how to use ggplot () to represent this confidence interval.

Link data and code rainfall: https://drive.google.com/drive/u/1/folders/1MmFeWoUSfXrGNbsL4SiK28FoMAby0gwD

Once again, I thank you very much. I am looking forward to hearing from you soon.


1 Answer 1


The problem with using a simple arima approach is that model identification is done when it is based upon the tacit assumption that there is no deterministic structure in the data and model parameters are invariant over time.

Your rainfall data (216 monthly values) has two significant seasonal dummies ( October and November) and a few pulses ( 6 of them all in the 4th quarter of the year ) .. one time anomalies and an arima structure (0,0,0)(1,0,0,). You need to integrate both memory (arima) and latent deterministic structure to get a useful/thorough model which has decomposed the observed data to signal and white noise i.e. an error term free of identifiable structure .

Your data enter image description here has an ACF enter image description here . A useful model is here enter image description here and here enter image description here with model summary stats here enter image description here with forecasts here for the next 36 months enter image description here with an ACF of here suggesting model sufficiency enter image description here

The model's residuals are here enter image description here

The Actual/Fit and Forecast is here enter image description here

You can probably come close to this result by using the TSOUTLIER package in R . I would closely examine the resultant error term to assess it's randomness i.e. the sufficiency of your model.

Hope this helps . Sorry , I do not write R code .

Note that the prediction limits are based upon bootstrapping the model residuals and you can safely truncate the lower values to be => 0.0 .

You asked for 95% prediction limits ..enter image description here


Using standard computation assuming normality of the errors and no future anomalies this is the Actual/Fit and Forecast enter image description here providing more realistic limits ... again simply change the lower limit if it is less than zero to zero.


auto.arima can work if there are no latent deterministic structures . Your data has them in a major way. Simply trying a brute-force AIC optimization fails because it uses the ACF while "The correlogram should be calculated from residuals using a model that controls for intervention administration, otherwise the intervention effects are taken to be Gaussian noise, underestimating the actual autoregressive effect." see @Adam0's comment on Interrupted Time Series Analysis - ARIMAX for High Frequency Biological Data?.

auto.arima incorrectly uses seasonally differences and a seasonal ma term while the correct fix for seasonal non-stationarity (in this case) is to identify and incorporate fixed effects for the two months (Oct and Nov) . Being unable to identify large pulses and there are a few, it used an ma(1) model memory rather than fixed pulse effects.

Finally model identification is an iterative , multi-state approach like peeling an onion https://autobox.com/pdfs/ARIMA%20FLOW%20CHART.pdf .

enter image description here

  • 1
    $\begingroup$ Note that the lower bounds are somewhat funny for rainfall. Is the earth going to sprinkle water back into the clouds? I'd try looking at log(rainfall) to circumvent this model insufficiency. $\endgroup$
    – AlexR
    Commented Nov 27, 2019 at 18:49
  • $\begingroup$ @Alex Good observation. However, almost everywhere in the world there are plenty of days with no precipitation, so a log transform isn't a likely choice. A time series version of a GLM might be a good approach. $\endgroup$
    – whuber
    Commented Nov 27, 2019 at 18:53
  • $\begingroup$ As I mentioned the simulation of the forecasts generating a family of forecasts for each period can simply be truncated at 0.0 . There is absolutely no need to include unwarranted transformations like logs stats.stackexchange.com/questions/18844/… which is meant to decouple the variance of the errors from the expected value of the model when one can safely ignore values lower than 0.0 $\endgroup$
    – IrishStat
    Commented Nov 27, 2019 at 18:57
  • 1
    $\begingroup$ GLM can deal with error variances that change at deterministic points in time but that is not present here. $\endgroup$
    – IrishStat
    Commented Nov 27, 2019 at 18:58
  • 1
    $\begingroup$ I re-ran and used standard time series theory to obtain prediction limits which assume normality of the errors and no anomalies in the future ...good observation @whuber $\endgroup$
    – IrishStat
    Commented Nov 27, 2019 at 19:09

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