I am new in this forum, and new in R. So it will be hard to help me :)
Sorry for the display, I tried to make it as clear as possible but that is not easy !
I want to forecast the prices of natural gas for my internship so I naturally went to R.
Here is my code (I think it is full of mistakes but I am a very beginner so be cool with me please !)
require(urca)
require(tseries)
require(forecast)
require(rugarch)
require(rmgarch)
setwd(file.path("C:","Users","I0309781","Desktop","ARMA"))
gaz <- read.csv2("gaz.csv",header=TRUE,sep=";")
Time=as.Date(gaz$Day,"%d/%m/%Y")
Time=Time[1:length(Time)]
R<-gaz$R[1:(length(gaz$R))]
R<-na.omit(R)
P<-gaz$Prix[1:length(gaz$Prix)]
plot.default(Time, R, xlim=c(min(Time), max(Time)),
ylim=c(min(R),max(R)), main="Rendement log - Valeur Cal+1",
ylab="Rendement", type="l")
res_rac<-ur.df(R,type="none",lags=1)
arma01=arma(R,order=c(0,1))
arma10=arma(R,order=c(1,0))
AvM<-gaz$AvM[1:58]
Aarma11=arma(AvM,order=c(1,1))
res01=arma01$residuals[2:length(arma01$residuals)]
res10=arma10$residuals[2:length(arma10$residuals)]
res11=Aarma11$residuals[2:length(Aarma11$residuals)]
squared.res11=res11^2
plot(squared.res11,type="l",main="Squared residuals")
par(mfcol=c(3,1))
plot(squared.res11,main='Squared Residuals',type="l")
acf.squared11=acf(squared.res11,main='ACF Squared Residuals',lag.max=25)
pacf.squared11=pacf(squared.res11,main='PACF Squared Residuals',lag.max=25)
arch01=garch(res11,order=c(0,1),trace=F)
arch02=garch(res11,order=c(0,2),trace=F)
arch03=garch(res11,order=c(0,3),trace=F)
plot(forecast(arch01))
i do not think you have to read all but my main problem is with the forecast(arch01) for example.
Rstudio returns me :
plot(forecast(arch01))
Error in is.constant(y) :
(list) object cannot be coerced to type 'double'
And I really don't understand why ... I tried to use as.numeric(arch01) but it did not work !
Thanks :)