Download the file tute1.csv from the book website, open it in Excel. You should find four columns of information. Columns B through D each contain a quarterly series, labelled Sales, AdBudget and GDP. Sales contains the quarterly sales for a small company over the period 1981-2005. AdBudget is the advertising budget and GDP is the gross domestic product. All series have been adjusted for inflation.
1. Convert the data set into tsibble
2. Construct a time series plot (geom_line()) for each three series
3. Construct a time series plot facet_grid() for all (together) three series (transform the data using pivot_longer)
The USgas package contains data on the demand for
natural gas in the US.
1. Install the `USgas` package.
2. Create a tsibble from `us_total` with year as the index and state as the key.
3. Plot the annual natural gas consumption by state for the New England area (comprising the states of Maine, Vermont, New Hampshire, Massachusetts, Connecticut and Rhode Island).
Download tourism.xlsx from the book website and read it into R
using readxl::read_excel().
1. Create a tsibble which is identical to the `tourism` tsibble from the `tsibble` package.
2. Find what combination of `Region` and `Purpose` had the maximum number of overnight trips on average.
3. Create a new tsibble which combines the Purposes and Regions, and just has total trips by State.
The aus_arrivals data set comprises quarterly
international arrivals to Australia from Japan, New Zealand, UK and the
US.
1. Use `autoplot()`, `gg_season()` and `gg_subseries()` to compare the differences between the arrivals from these four countries.
2. Can you identify any unusual observations?
Monthly Australian retail data is provided in
aus_retail. Select one of the time series as follows (but
choose your own seed value):
set.seed(12345678)
myseries <- aus_retail %>%
filter(`Series ID` == sample(aus_retail$`Series ID`,1))
Explore your chosen retail time series using the following functions:
`autoplot()`, `gg_season()`, `gg_subseries()`, `gg_lag()`,
`ACF() %>% autoplot()`
Can you spot any seasonality, cyclicity and trend? What do you learn about the series?
By using the gafa_stock data set:
1. calculate the mean and standard deviation of the Facebook closing stock prices.
2. calculate the mean, standard deviation, kurtosis and Skewenss of the first difference of Facebook closing stock prices.
3. Now, you should calculate the mean, standard deviation, kurtosis and Skewenss of the Facebook closing stock prices without using the functions in R (in other words, you should compute the statistic by coding it in R).
Go to Yahoo Finance and download a time series of any stock of your preference year-to-date (YTD.
1. Load the excel file into R
2. Clean the dataset to only show the Date and adj. Close
3. Transform it into a tsibble (index it correctly!!!)
4. Plot the Adj. Close price using geom_line() only for the month of June.
5. Calculate the mean and variance per month.