Anda di halaman 1dari 2

1. install.

packages("tseries"):
library (t-series)
[Put it in library]

2. mydata<- read.csv("C:/Econometrics/Data/timeseries_ppi.csv"):
attach (mydata)
[Read the .csv file timeseries_ppi]

3. Defining variables:

Y <- ppi [Dependant Variable]


d.Y <- diff(Y)[Difference in the ppi]
t <- yearqrt []

4. Descriptive statistics and plotting the data:


Summary (Y)[Gives Mean,median, Mode etc.]
summary (d.Y) [Gives Mean,median, Mode etc.]
plot (t,Y)[plotting t against Y, Graph is not stationary as its increasing]
plot (d.Y)[Plotting differenced variable,]

5. Dickey-Fuller test for variable [For Checking Stationarity]:


adf.test(Y, alternative="stationary", k=0) [Result: Cant Reject the Null as
p-value is high, We have Non-Stationary]
adf.test(Y, alternative="explosive", k=0)[Result: p-value is less than 5%, so
we accept alternative hypothesis as :Explosive, We have Non-Stationarity ]
[K=0, is number of addidtional lags you can put]
summary(lm(dppi ~ lppi, na.action=na.omit))
summary(lm(dppi ~ lppi + trend, na.action=na.omit))
[Regression of Differenced Dependant Variable on the lagged Variable. Again,
since Lagged variable Estimate is not significantly different than zero, so we
dont have Stationarity]

6. Augmented Dickey-Fuller test:


adf.test(Y, alternative="stationary")

7. DF and ADF tests for differenced variable:

adf.test(d.Y, k=0)[Dickey Fuller Test, without any additional lags]


adf.test(d.Y)
[Dickey Fuller Test, with additional lags. Since the p-value is less than 5%,
we reject Null hypothesis and so we have Stationarity, which is a good thing.
The conclusion is we need to use Differenced variables in our ARIMA Models.]

8. ACF and PACF (Auto-correlation & Partial Auto-correlation Functions):


acf(Y)[Very slow decaying is an indication of Non-Stationarity]
pacf(Y)[No correlation at all.]
acf(d.Y)[Rapid decay, so its Stationary]
pacf(d.Y)[Not Significant, outside of Confidence interval]

9. ARIMA(1,0,0) or AR(1):
arima(Y, order = c(1,0,0))

10.ARIMA(2,0,0) or AR(2):
arima(Y, order = c(2,0,0))

11.ARIMA(0,0,1) or MA(1):
arima(Y, order = c(0,0,1))
12.ARIMA(1,0,1) or AR(1) MA(1)
arima(Y, order = c(1,0,1))

# ARIMA on differenced variable


13.

ARIMA(1,1,0)

arima(d.Y, order = c(1,0,0))

14.

ARIMA(0,1,1)

arima(d.Y, order = c(0,0,1))

15. ARIMA(1,1,1)
arima(d.Y, order = c(1,0,1))
16. ARIMA(1,1,3)
arima(d.Y, order = c(1,0,3))
17.ARIMA(2,1,3)
arima(d.Y, order = c(2,0,3))
18.ARIMA(1,0,1) forecasting:
mydata.arima101 <- arima(Y, order = c(1,0,1))
mydata.pred1 <- predict(mydata.arima101, n.ahead=100)
plot (Y)
lines(mydata.pred1$pred, col="blue")
lines(mydata.pred1$pred+2*mydata.pred1$se, col="red")
lines(mydata.pred1$pred-2*mydata.pred1$se, col="red")
19. ARIMA(1,1,1) forecasting:
mydata.arima111 <- arima(d.Y, order = c(1,0,1))
mydata.pred1 <- predict(mydata.arima111, n.ahead=100)
plot (d.Y)
lines(mydata.pred1$pred, col="blue")
lines(mydata.pred1$pred+2*mydata.pred1$se, col="red")
lines(mydata.pred1$pred-2*mydata.pred1$se, col="red")

Anda mungkin juga menyukai