Due Date: September 27, 2021

Instructions

Please complete each problem below to the best of your ability. Where plain text is required, you can type directly into the .RMD file. Where code and output is required, be sure to include all code in the code chunks provided. The assignment must be submitted, via email, as both the .RMD file and the knitted file (whether .html or .pdf, whichever is best for yourself)

Problem 1

Complete Chapter 2, Exercise 1 from the textbook. You can find both the varnish.csv and the guesswhat.csv files in the Lecture Notes/data folders.

Part 1A

##On the book’s website, you will find two small bivariate data sets that are
##not time series. Draw a scatter plot for each set and then calculate the
##correlation. Comment on your results.

varnish <- read.csv("C:/CS-637-Time-Series-and-Forecasting--main/Lecture Notes/data/varnish.csv")

varx <- varnish$x
vary <- varnish$y

cor(varx,vary)
## [1] -0.2528782
acf(varnish, plot = TRUE)

plot(varx,vary, main = "Amount of Catalyst vs. Drying Time", xlab = "Amt. of Catalyst in Varnish", ylab = "Drying Time of a Set Volume")

## Correlation is -0.25, trending slightly downward

Part 1B

gw <- read.csv("C:/CS-637-Time-Series-and-Forecasting--main/Lecture Notes/data/guesswhat.csv")

gwx <- gw$x
gwy <- gw$y

cor(gwx,gwy)
## [1] 0.06457764
plot(gwx,gwy)

## whatever this is the correlation seems significant. 

Problem 2

Complete Chapter 2, Exercise 2 from the textbook.

Part 2A

Seren <- c(39, 35, 16, 18, 7, 22, 13, 18, 20, 9, −12, −11, −19, −9, −2, 16)
Cagey <- c(47, −26, 42, −10, 27, −8, 16, 6, −1, 25, 11, 1, 25, 7, −5, 3)

plot(ts(Seren))

plot(ts(Cagey))

Part 2B

Seren <- c(39, 35, 16, 18, 7, 22, 13, 18, 20, 9, −12, −11, −19, −9, −2, 16)
Cagey <- c(47, −26, 42, −10, 27, −8, 16, 6, −1, 25, 11, 1, 25, 7, −5, 3)

plot(x = Seren[1:15], y = Seren[2:16], xlab = "x_t", ylab = "x_t+1")

plot(x = Cagey[1:15], y = Cagey[2:16], xlab = "x_t", ylab = "x_t+1")

Part 2C

Seren <- c(39, 35, 16, 18, 7, 22, 13, 18, 20, 9, −12, −11, −19, −9, −2, 16)
Cagey <- c(47, −26, 42, −10, 27, −8, 16, 6, −1, 25, 11, 1, 25, 7, −5, 3)

acf(Seren)

acf(Cagey)

##ACF for both were significant during first couple lags

Problem 3

Complete Chapter 2, Exercise 3 from the textbook.

Part 3A

Global_file <- read.csv("C:/CS-637-Time-Series-and-Forecasting--main/Lecture Notes/data/Global.csv")

Global = data.frame()
for(row in 1:nrow(Global_file)){
  for(column in 1:ncol(Global_file)){
    Global = rbind.data.frame(Global, Global_file[row,column])
  }
}
    
Global.ts <- ts(Global, st = c(1980, 1), end = c(2005, 12), fr = 12)
Global.annual <- aggregate(Global.ts, FUN = mean)
layout(1:2)
plot(Global.ts)
plot(Global.annual)

plot(decompose(Global.ts))

sd(Global.ts)
## [1] 0.2110313
##sd(Global.ts - Global.decom$trend)

#### Part 3B

Problem 4

Complete Chapter 2, Exercise 4 from the textbook.

adflow <- read.csv("C:/CS-637-Time-Series-and-Forecasting--main/Lecture Notes/data/Fontdsdt.csv")


plot(ts(adflow), ylab = 'adflow')

acf(adflow, plot = TRUE)

##acf(adflow.decom$random[7:138])