-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path82-methodswithtrend.R
60 lines (50 loc) · 1.55 KB
/
82-methodswithtrend.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
aus_economy <- global_economy |>
filter(Code == "AUS") |>
mutate(Pop = Population / 1e6)
fit <- aus_economy |>
model(AAN = ETS(Pop ~ error("A") + trend("A") + season("N")))
report(fit)
components(fit) |> autoplot()
components(fit) |>
left_join(fitted(fit), by = c("Country", ".model", "Year"))
fit |>
forecast(h = 10)|>
autoplot(aus_economy) +
labs(y = "Millions", title = "Population: Australia")
aus_economy |>
model(
`Holt's method` = ETS(Pop ~ error("A") +
trend("A") + season("N")),
`Damped Holt's method` = ETS(Pop ~ error("A") +
trend("Ad", phi = 0.9) + season("N"))
) |>
forecast(h = 15) |>
autoplot(aus_economy, level = NULL) +
labs(title = "Australian population",
y = "Millions") +
guides(colour = guide_legend(title = "Forecast"))
www_usage <- as_tsibble(WWWusage)
www_usage |> autoplot(value) +
labs(x="Minute", y="Number of users",
title = "Internet usage per minute")
www_usage |>
stretch_tsibble(.init = 10) |>
model(
SES = ETS(value ~ error("A") + trend("N") + season("N")),
Holt = ETS(value ~ error("A") + trend("A") + season("N")),
Damped = ETS(value ~ error("A") + trend("Ad") +
season("N"))
) |>
forecast(h = 1) |>
accuracy(www_usage)
fit <- www_usage |>
model(
Damped = ETS(value ~ error("A") + trend("Ad") +
season("N"))
)
tidy(fit)
fit |>
forecast(h = 10) |>
autoplot(www_usage) +
labs(x="Minute", y="Number of users",
title = "Internet usage per minute")