R Code Discussion 3_4

pdf

School

Binghamton University *

*We aren’t endorsed by this school

Course

467

Subject

Statistics

Date

Apr 3, 2024

Type

pdf

Pages

2

Uploaded by ColonelParrotMaster1064

Report
1. Explore your chosen retail time series using the following functions: auto- plot(), gg season(), gg subseries(), gg lag(). > data <- tsibble( + date = yearmonth("1990 Jan") + 0:368, + Turnover = as.numeric(data_practice$Turnover) + ) > autoplot(data) > gg_season(data) > gg_subseries(data) > gg_lag(data) 2. Do a STL decomposition of data. Is your decomposition additive or multiplicative? > data %>% + model( + STL(Turnover ~ trend(window = 368) + season(window = "periodic"), + robust = TRUE)) %>% + components() %>% + autoplot() 3. Do a SEATS/X11 decomposition of data. Is your decomposition additive or multiplicative? > x11_dcmp <- data %>% + model(x11 = X_13ARIMA_SEATS(Turnover ~ x11()))%>% + components() > autoplot(x11_dcmp) + + labs(title = "Decomposition of Turnover Data using X-11") 4. Create a training dataset consisting of observations before 2017. > training_data <- data %>% + filter(date <= yearmonth("2017 Dec")) > training_data %>% + model( + SNAIVE(Turnover ~ lag("yearmonth")) + ) 5. Fit a seasonal na ̈ıve model using SNAIVE() applied to your training data. > snaiveplot <- training_data %>% + model( + SNAIVE(Turnover ~ lag("yearmonth"))
+ ) > View(snaiveplot) > snaiveplot %>% + forecast()%>% + autoplot() > augment(snaiveplot) 6. Check your residuals. Does your residuals look like a white noise? > snaiveplot1 <- training_data %>% + model( + `SNAIVE` = SNAIVE(Turnover) + ) > snaiveplotfc <- snaiveplot1 %>% + forecast() > snaiveplotfc %>% + autoplot(snaiveplot1, level = NULL) + + autolayer( + filter_index(data_practice, "2018 Jan" ~ .), + colour = "black" + ) Error in `validate_index()`: ! Can't determine index and please specify argument `index`. Run `rlang::last_error()` to see where the error occurred.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help