## Time-Series [1:476] from 1956 to 1996: 1709 1646 1794 1878 2173 ...
## Time-Series [1:119] from 1965 to 1994: 6172 6709 6633 6660 6786 ...
## Time-Series [1:1108] from 1 to 1108: 306 300 303 297 304 ...
X | Sales | AdBudget | GDP |
---|---|---|---|
Mar-81 | 1020.2 | 659.2 | 251.8 |
Jun-81 | 889.2 | 589.0 | 290.9 |
Sep-81 | 795.0 | 512.5 | 290.8 |
Dec-81 | 1003.9 | 614.1 | 292.4 |
Mar-82 | 1057.7 | 647.2 | 279.1 |
Jun-82 | 944.4 | 602.0 | 254.0 |
Sep-82 | 778.5 | 530.7 | 295.6 |
Dec-82 | 932.5 | 608.4 | 271.7 |
Mar-83 | 996.5 | 637.9 | 259.6 |
Jun-83 | 907.7 | 582.4 | 280.5 |
## Time-Series [1:275] from 1973 to 1996: 55 60 68 63 65 61 54 52 46 42 ...
## Time-Series [1:72] from 1973 to 1979: 9007 8106 8928 9137 10017 ...
## Time-Series [1:155] from 1956 to 1994: 189 204 208 197 187 214 227 223 199 229 ...
## Time-Series [1:141] from 1875 to 2015: 213.1 109.3 92.9 22.2 36.3 ...
## - attr(*, "names")= chr [1:141] "1875" "1876" "1877" "1878" ...
devtools::install_github(“yixuan/showtext”) suppressWarnings(suppressMessages(library(forecast))) suppressWarnings(suppressMessages(library(showtext))) suppressWarnings(suppressMessages(library(ggplot2))) suppressWarnings(suppressMessages(library(kableExtra))) suppressWarnings(suppressMessages(library(fma))) suppressWarnings(suppressMessages(library(fpp))) suppressWarnings(suppressMessages(library(fpp2)))
font_add_google(name = “Corben”, family = “corben”, regular.wt = 400, bold.wt = 700)
Question 2:1
str(gas) autoplot(gas, ylab=“gas production”, xlab=“”) str(woolyrnq) autoplot(woolyrnq, ylab=“wool yarn production”, xlab=“”) str(gold) autoplot(gold, ylab=“gold price”, xlab=“”)+scale_x_discrete(limits=c(1,365,730,1095), labels=c(“1985”,“1986”,“1987”,“1988”,“1989”))
which.max(gold)
tute1 <- read.csv(“C:/Users/dawig/Desktop/Data624/tute1.csv”, header=TRUE) kable_input<-kable(tute1[1:10,], “html”) %>% kable_styling(“striped”, full_width = F) %>% column_spec(1, bold = T, color = “white”, background = “#3dc666”) %>% column_spec(2, bold = T, color = “#3dc666”, background = “white”) %>% column_spec(3, bold = T, color = “#3dc666”, background = “white”) %>% column_spec(4, bold = T, color = “#3dc666”, background = “white”) add_header_above(kable_input, header = c(‘’, “Head of Tute1 Dataset”=3), bold = TRUE, italic = TRUE)%>% kable_styling(bootstrap_options = “striped”, font_size = 22)
mytimeseries <- ts(tute1[,-1], start=1981, frequency=4) autoplot(mytimeseries, facets=TRUE, ylab=“tute 1 small business”, xlab=“”) autoplot(mytimeseries, facets=FALSE, ylab=“tute1 small business”, xlab=“”)
retaildata <- readxl::read_excel(“C:/Users/dawig/Desktop/Data624/retail.xlsx”, skip=1) turnover <- ts(retaildata[,“A3349608L”], frequency=12, start=c(1982,4)) autoplot(turnover, ylab=“turnover”, xlab=“”)+ theme(panel.background = element_rect(fill = ‘#efeae8’)) ggseasonplot(turnover)+ theme(panel.background = element_rect(fill = ‘#efeae8’)) ggsubseriesplot(turnover)+ theme(panel.background = element_rect(fill = ‘#efeae8’))+ ggtitle(“”) gglagplot(turnover)+ theme(panel.background = element_rect(fill = ‘#efeae8’))+ ggtitle(“”) ggAcf(turnover)+ theme(panel.background = element_rect(fill = ‘#efeae8’)) ggPacf(turnover)+ theme(panel.background = element_rect(fill = ‘#efeae8’))
str(hsales) autoplot(hsales, xlab=“year”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’)) ggseasonplot(hsales, xlab=“month”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’)) ggsubseriesplot(hsales, xlab=“month”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’))+ ggtitle(“”)
gglagplot(hsales, xlab=“hsales”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’))+ ggtitle(“”)
ggAcf(hsales, xlab=“lag”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’)) ggPacf(hsales, xlab=“lag”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’))
str(usdeaths) autoplot(usdeaths, xlab=“year”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’)) ggseasonplot(usdeaths, xlab=“month”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’)) ggsubseriesplot(usdeaths, xlab=“month”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’))+ ggtitle(“”)
gglagplot(usdeaths, xlab=“usdeaths”)+scale_x_continuous(breaks=c(7000,9000,11000),labels=c(“7000”,“9000”,“11000”))+ theme(axis.text.x = element_text(angle=-45),panel.background = element_rect(fill = ‘#f9f8ef’))+ ggtitle(“”)
ggAcf(usdeaths, xlab=“lag”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’)) ggPacf(usdeaths, xlab=“lag”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’))
str(bricksq) autoplot(bricksq, xlab=“year”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’)) ggseasonplot(bricksq, xlab=“year”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’)) ggsubseriesplot(bricksq, xlab=“year”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’))+ ggtitle(“”) gglagplot(bricksq, xlab=expression(y[“t-k”]), ylab=expression(y[“t”]))+ theme(panel.background = element_rect(fill = ‘#f9f8ef’),axis.title = element_text(size=14))+ ggtitle(“”)+scale_x_continuous(breaks=c(250,350,450,550),labels=c(‘250’,‘350’,‘450’,‘550’)) ggAcf(bricksq, xlab=“year”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’))
str(sunspotarea) autoplot(sunspotarea, xlab=“year”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’)) ggseasonplot(sunspotarea, xlab=“year”) ggsubseriesplot(sunspotarea, xlab=“year”) gglagplot(sunspotarea, xlab=expression(y[“t-k”]), ylab=expression(y[“t”]))+ theme(panel.background = element_rect(fill = ‘#f9f8ef’),legend.position=“none”,axis.title = element_text(size=14))+ ggtitle(“”) ggAcf(sunspotarea, xlab=“year”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’)) ggPacf(sunspotarea, xlab=“year”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’))
autoplot(gasoline, xlab=“year”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’)) ggseasonplot(gasoline, xlab=“week”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’)) ggsubseriesplot(gasoline, xlab=“year”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’))
gglagplot(gasoline, xlab=expression(y[“t-k”]), ylab=expression(y[“t”]))+ theme(panel.background = element_rect(fill = ‘#f9f8ef’),legend.position=“none”)+theme(axis.title = element_text(size=14))+ ggtitle(“”)
ggAcf(gasoline, xlab=“weeks lag”)+ theme(panel.background = element_rect(fill = ‘#f9f8ef’))