# forecast rainfall using ARIMA in R

I am a new student approaching ARIMA prediction analysis in R. If the question is too simple or incorrect, please forgive and guide me.

I am currently using the ARIMA provided in R. I use the data as the rainfall time series to forecast rainfall for the next several years.

I used the code to draw the following diagram:

datats <- ts(mydata, start = c(2000,1), frequency = 12)
datats
adf.test (datats, alternative = "stationary")
plot(datats, xlab="Year", ylab="Rainfall(mm)", main="Rainfall in Quy Nhon since 2000 to 2017", lwd=4, col="chartreuse4")
dec <- decompose(datats, type = "additive")
plot(dec, col= "firebrick1", lwd = 3)
acf (ts (datats), main="ACF For Rainfall", col="blue", lwd = 4)   Because our data has a rainfall month with a negative value, I used the command auto.arima () with the properties as follows:

ARIMAfit <- auto.arima(y=log(datats + 1), approximation = FALSE, trace = TRUE, ic="aic", test="kpss")
ARIMAfit


Code run result: Best model: ARIMA(0,0,0)(0,1,1)

%Series: (log(datats + 1))
%ARIMA(0,0,0)(0,1,1)
%Coefficients:
%sma1
%-0.8855
%s.e.
%0.0729
%sigma^2 estimated as 1.064:  log likelihood=-304.42
%AIC=612.84   AICc=612.9   BIC=619.48


Make predictions for the next 48 months:

fact <- forecast (ARIMAfit, h=48)
fact


Code run result: After that, I proceeded to graph the predictive data for the data using the exp() function - to convert the predicted value into the original value.

plot(exp(fact), col = "chartreuse4", lwd=3)


But this results in an error: Error in exp(fact) : non-numeric argument to mathematical function

My question is:

1. Could you please help me to see if my prediction method is accurate and how to handle errors in R?

2. Could you please help me run the code in R to predict rainfall according to the above data?

## 1 Answer

You asked 2 questions ...

1)Could you please help me to see if my prediction method is accurate and how to handle errors in R.

I wouldn't think so because you didn't fully extract a sufficient equation as per Help me about using ARIMA forecasting rainfall

2) Could you please help me run the code in R to predict rainfall according to the above data

can't help you there !

your arima model ( in logspace ) is essentially self-cancelling

[(1-B** 12)]Y(T) = + [(1- .885B** 12)] [A(T)]

[(1-1.0B** 12)]Y(T) = + [(1- .885B** 12)] [A(T)]

Y(T) = +{ [(1- .885B** 12)]/[(1-1.0B** 12)] } [A(T)]

or Y(T)= Y(T-12) + .885* A(T-12)

imposing an unwarranted seasonal differencing yields a now necessary seasonal ma seasonal coefficient

The errors from your model are HUGE reflecting a model that has not adequately dealt with the observed data

It devolves to a seasonal random walk forecast.

With a low R square value

R Square = .420171

Also a simultaneous plot of the actual and model errors is dispiriting • Thanks @IrishStart very much. This means that it is not appropriate to choose the coefficients in the ARIMA model. – Dương Nguyễn Quốc Nov 28 '19 at 14:52
• more importantly it didn't chose an appropriate model . Note that the parameter is optimal for the chosen model BUT it is not a good choice of model. – IrishStat Nov 28 '19 at 14:54
• Thanks for your enthusiastic support. Would you please explain to me how to choose the factors to optimize the model, thank you – Dương Nguyễn Quốc Nov 28 '19 at 14:59
• one needs to set up a tournament where one identifies and combines both memory (arima) and latent deterministic structure simultaneously. The arima prtion is similar but distinctly superior to auto.arima and the latent deterministic structure is similar to the results from tsoutlier . AUTOBOX ( a commercial piece of software that I have helped to develop with an R interface) weaves them together with validating parameter and error variance constancy over time. If you wanted to write your own scripts in R to duplicate my results it might take some effort on your behalf. – IrishStat Nov 28 '19 at 15:28
• bothers ? I am not sure what you are stating/asking . some additional reading for you on time series modelling . stats.stackexchange.com/search?tab=newest&q=user%3a3382 – IrishStat Nov 28 '19 at 16:54