-
Notifications
You must be signed in to change notification settings - Fork 168
/
week7.R
83 lines (57 loc) · 1.43 KB
/
week7.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
library(fpp3)
#### Amazon STOCK PRICE 2018 ----------------
amazon_2018 <- gafa_stock |>
filter(Symbol == "AMZN", year(Date) == 2018)
amazon_2018 |> autoplot(Close)
amazon_2018 |>
ACF(Close) |>
autoplot()
amazon_2018 |> autoplot(difference(Close)) +
ylab("Google closing stock price") + xlab("Day")
amazon_2018 |>
ACF(difference(Close)) |>
autoplot()
amazon_2018 |>
features(Close, unitroot_kpss)
amazon_2018 |>
features(difference(Close), unitroot_kpss)
amazon_2018 |>
features(Close, unitroot_ndiffs)
## A10 drugs
a10 <- PBS |>
filter(ATC2 == "A10") |>
summarise(Cost = sum(Cost) / 1e6)
a10 |> autoplot(Cost)
a10 |> autoplot(log(Cost))
a10 |> autoplot(
log(Cost) |> difference(lag = 12)
)
a10 |>
features(log(Cost), feat_stl)
a10 |>
features(log(Cost) |> difference(lag=12), feat_stl)
a10 |>
features(log(Cost), unitroot_nsdiffs)
a10 |>
features(log(Cost) |> difference(lag=12), unitroot_ndiffs)
## H02 drugs
h02 <- PBS |>
filter(ATC2 == "H02") |>
summarise(Cost = sum(Cost) / 1e6)
h02 |> autoplot(Cost)
h02 |> autoplot(log(Cost))
h02 |> autoplot(
log(Cost) |> difference(12)
)
h02 |> autoplot(
log(Cost) |> difference(12) |> difference(1)
)
h02 |>
mutate(log_sales = log(Cost)) |>
features(log_sales, feat_stl)
h02 |>
mutate(log_sales = log(Cost)) |>
features(log_sales, unitroot_nsdiffs)
h02 |>
mutate(d_log_sales = difference(log(Cost), 12)) |>
features(d_log_sales, unitroot_ndiffs)