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.
My data: https://drive.google.com/drive/u/1/folders/1MmFeWoUSfXrGNbsL4SiK28FoMAby0gwD
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)[12]
%Series: (log(datats + 1))
%ARIMA(0,0,0)(0,1,1)[12]
%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:
Could you please help me to see if my prediction method is accurate and how to handle errors in R?
Could you please help me run the code in R to predict rainfall according to the above data?