library(tidyverse) library(tsibble) library(lubridate) library(fable) library(verification) data(tourism) #简化州名 tourism <- tourism %>% mutate( State = recode(State, "Australian Capital Territory" = "ACT", "New South Wales" = "NSW", "Northern Territory" = "NT", "Queensland" = "QLD", "South Australia" = "SA", "Tasmania" = "TAS", "Victoria" = "VIC", "Western Australia" = "WA" ) ) #单序列预测 snowy <- tourism %>% filter( Region == "Snowy Mountains", Purpose == "Holiday" ) snowy %>% autoplot(Trips) #seasonal naive、ETS和arima fit <- snowy %>% model( snaive = SNAIVE(Trips ~ lag("year")), ets = ETS(Trips),