0% found this document useful (0 votes)
52 views

ASM Assignment Codes For Apendix

1) The document analyzes a time series dataset with 16 values representing export volume index over time. It plots the original time series and calculates its autocorrelation function out to a lag of 15 values. 2) It then creates differenced versions of the time series (first and second differences) and plots these. It runs Box tests on the differenced series to test for independence. 3) The Box tests find no significant lack of independence in the differenced series up to a lag of 5, indicating the differencing successfully removed autocorrelation in the time series.

Uploaded by

sadyehclen
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

ASM Assignment Codes For Apendix

1) The document analyzes a time series dataset with 16 values representing export volume index over time. It plots the original time series and calculates its autocorrelation function out to a lag of 15 values. 2) It then creates differenced versions of the time series (first and second differences) and plots these. It runs Box tests on the differenced series to test for independence. 3) The Box tests find no significant lack of independence in the differenced series up to a lag of 5, indicating the differencing successfully removed autocorrelation in the time series.

Uploaded by

sadyehclen
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

VI.

ANALYSIS AND DISCUSSION (Code input and Output)


setwd("C:\\Users\\se7en\\Desktop")
Y<-read.table("timeseries.txt.txt ",header=TRUE)
plot.ts(x = Y, ylab = expression(paste(Y[t]," (export volume
index)")), xlab = "t (Year) ",type="o", col = "red", main = "Time
Series with 16 values")

ACF <- acf(x=Y, lag.max = 15, type = c ("correlation"), plot = TRUE)

ACF$"acf"[2:16]
[1] 0.747010464 0.510874178 0.238122449 0.005676017 -0.187818571
[6] -0.165416131 -0.167339752 -0.139557065 -0.155305290 -0.165771437

[11] -0.275418418 -0.269032582 -0.206288111 -0.155269981 -0.114465769

Y <- ts(Y)
Z <- ts(diff(Y, lag=1))
Z2 <- ts(diff (Z, lag=1))
ts.plot(Y,gpars=list(main="Original Values", xlab="Year",
ylab="Export Volume Index", lty=1))

acf(Y)

pacf(Y)

ts.plot(Z, gpars=list(main= "First Difference", xlab="Year",


ylab="Export Volume Index", lty=1))

acf(Z, main="Z")

pacf(Z, main="Z")

Box.test(Z, lag = 5)
Output
Box-Pierce test

data: Z
X-squared = 2.9786, df = 5, p-value = 0.7033

Box.test(Z, lag = 5,type="Ljung")


Output
Box-Ljung test
data: Z
X-squared = 4.4428, df = 5, p-value = 0.4876

ts.plot(Z2, gpars=list(main= "Second Difference", xlab="Year",


ylab="Export Volume Index", lty=1))

acf(Z2, main="Z2")

pacf(Z2, main="Z2")

Box.test(Z2, lag = 5)
Box-Pierce test
data: Z2
X-squared = 4.5467, df = 5, p-value = 0.4737
Box.test(Z2, lag = 5,type="Ljung")
Box-Ljung test
data: Z2
X-squared = 6.7073, df = 5, p-value = 0.2433

You might also like