library(fpp2)
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
## ── Attaching packages ──────────────────────────────────────────── fpp2 2.5.1 ──
## ✔ ggplot2 4.0.1 ✔ fma 2.5
## ✔ forecast 9.0.0 ✔ expsmooth 2.3
##
##help(gas)
autoplot(gold)+ggtitle("Plot for Gold Time Series")+xlab("Day")+ylab("Price")
frequency_gold<-frequency(gold)
frequency_gold
## [1] 1
outlier_index<-which.max(gold)
outlier_index
## [1] 770
gold[outlier_index]
## [1] 593.7
library(fpp2)
library(readxl)
library(ggplot2)
retaildata<-readxl::read_excel("C:/Users/杨凯迪/Desktop/retail.xlsx",skip=1)
myts<-ts(retaildata[,"A3349873A"],frequency=12,start=c(1982,4))
autoplot(myts)+ggtitle("Plot for Australain retail data")+xlab("Time")+ylab("Retail")
ggseasonplot(myts)+ggtitle("plot for Australain retail data")+xlab("Time")+ylab("Retail")
ggsubseriesplot(myts)+ggtitle("Plot for Australain retail data")+xlab("Time")+ylab("Retail")
gglagplot(myts)
ggAcf(myts)
### 2.10.4
library(fpp2)
autoplot(bicoal)
autoplot(chicken)
autoplot(dole)
autoplot(usdeaths)
autoplot(lynx)
autoplot(goog)
autoplot(writing)
autoplot(fancy)
autoplot(a10)
autoplot(h02)
help(bicoal)
## starting httpd help server ... done
help(chicken)
help(usdeaths)
help(lynx)
help(goog)
help(writing)
help(fancy)
help(a10)
help(h02)
autoplot(goog)+ggtitle("Google Stock Prices Over Times")+xlab("Year")+ylab("Price")
autoplot(hsales)+ggtitle("House Sales")
autoplot(usdeaths)+ggtitle("US Deaths")
autoplot(bricksq)+ggtitle("Bricks Quarterly Sales")
autoplot(sunspotarea)+ggtitle("Summer Area")
autoplot(gasoline)+ggtitle("Gasoline Sales")
ggseasonplot(hsales)+ggtitle("Seasonal plot of House Sales")
ggseasonplot(bricksq)+ggtitle("Seasonal Plot of Bricks Quarterly Sales")
ggseasonplot(gasoline)+ggtitle("Subseries Plot of House Sales")
ggsubseriesplot(hsales)+ggtitle("Subseries Plot of House sales")
ggsubseriesplot(usdeaths)+ggtitle("Subseries Plot of US Deaths")
ggsubseriesplot(bricksq)+ggtitle("Subseries Plot of Bricks Quarterly Sales")
gglagplot(hsales)+ggtitle("Lag Plot Houses Sales")
gglagplot(usdeaths)+ggtitle("Lag Plot of US Deaths")
gglagplot(bricksq)
gglagplot(sunspotarea)+ggtitle("Lag Plot of Sun Spot Area")
gglagplot(gasoline)+ggtitle("Lag Plot of Gasoline")
ggAcf(hsales)+ggtitle("Acf of House Sales")
ggAcf(usdeaths)+ggtitle("Acf of US Deaths")
ggAcf(bricksq)+ggtitle("Acf of Bricks Quarterly Sales")
ggAcf(sunspotarea)+ggtitle("Acf of Sun Spot Area")
ggAcf(gasoline)+ggtitle("Acf Plot of Gasoline")
library(forecast)
library(ggplot2)
library(fpp2)
Japan<-arrivals[,"Japan"]
New_Zealand<-arrivals[, 2]
UK<-arrivals[,"UK"]
US<-arrivals[,"US"]
autoplot(arrivals)+ggtitle("Monthly Arrivals from Different Countries to Australia")+xlab("Year")+ylab("Number of Arrivals")
japan_arrivals<-arrivals[,"Japan"]
ggseasonplot(japan_arrivals)+ggtitle("Monthly Arrivals from Japan to Australia")+xlab("Year")+ylab("Number of Arrivals")
japan_arrivals<-arrivals[,"Japan"]
ggsubseriesplot(japan_arrivals)+ggtitle("Monthly Arrivals from Japan to Australia")+xlab("Year")+ylab("Number of Arrivals")
#1-B;2-C;3-D;4-A
library(ggplot2)
library(forecast)
set.seed(123)
dj<-cumsum(rnorm(292))
ddj<-diff(dj)
plot(ddj,type='l',main="Daily Changes in Dow Jones Index",ylab="Daily Changes",xlab="Days")
acf(ddj,main="Acf of Daily Changes in Dow Jones Index")