autoplot(gold) +
ggtitle("Daily morning gold prices in US dollars. 1 January 1985 – 31 March 1989.") +
xlab('Day') +
ylab('Gold price in USD')
autoplot(woolyrnq) +
ggtitle('Quarterly production of woollen yarn in Australia: tonnes. Mar 1965 – Sep 1994.') +
xlab('Quarter') +
ylab('Tonnes')
autoplot(gas) +
ggtitle('Australian monthly gas production: 1956–1995.') +
xlab('Month') +
ylab('Gas production')
print(paste('Frequency of gold =', frequency(gold) ))
## [1] "Frequency of gold = 1"
print(paste('Frequency of woolyrnq =', frequency(woolyrnq) ))
## [1] "Frequency of woolyrnq = 4"
print(paste('Frequency of gas =', frequency(gas) ))
## [1] "Frequency of gas = 12"
which.max(gold)
## [1] 770
gold[which.max(gold)]
## [1] 593.7
tute1 <- read.csv("tute1.csv", header=TRUE)
mytimeseries <- ts(tute1[,-1], start=1981, frequency=4)
autoplot(mytimeseries, facets=TRUE)
autoplot(mytimeseries)
retaildata <- readxl::read_excel("retail.xlsx", skip=1)
myts <- ts(retaildata[,"A3349532C"],
frequency=12, start=c(1982,4))
autoplot(myts) +
ggtitle('Retail Data') +
xlab('Year') +
ylab('Sales')
ggseasonplot(myts) +
ggtitle('Retail Data') +
xlab('Year') +
ylab('Sales')
ggsubseriesplot(myts) +
ggtitle('Retail Data') +
xlab('Year') +
ylab('Sales')
gglagplot(myts) +
ggtitle('Retail Data') +
xlab('Year') +
ylab('Sales')
#### Strong positive correlation across all the lags suggest storng positive trend in the time series
ggAcf(myts) +
ggtitle('Retail Data') +
xlab('Year') +
ylab('Sales')
analyzets = function(ts, plottitle)
{
print(autoplot(ts) + ggtitle(plottitle))
try(print(ggseasonplot(ts) + ggtitle(plottitle)))
try(print(ggsubseriesplot(ts) + ggtitle(plottitle)))
print(gglagplot(ts) + ggtitle(plottitle))
print(ggAcf(ts) + ggtitle(plottitle))
}
analyzets(hsales, "hsales analysis")
analyzets(usdeaths, "usdeath analysis")
analyzets(bricksq, 'bricksq analysis')
analyzets(sunspotarea, 'sunspotarea analysis')
## Error in ggseasonplot(ts) : Data are not seasonal
## Error in ggsubseriesplot(ts) : Data are not seasonal
gasoline = ts(gasoline, frequency = 52)
analyzets(gasoline, 'gasoline analysis')
ggseasonplot(gasoline, polar=TRUE) +
ggtitle('Gasoline seasonal plot')
From the above plot we can see that gasoline supply is higher during week 47 to 50. This may be due to holiday season