-
Notifications
You must be signed in to change notification settings - Fork 0
/
seasonal-example.R
executable file
·93 lines (83 loc) · 5.77 KB
/
seasonal-example.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
82
83
84
85
86
87
88
89
90
91
92
93
library(seasonal)
# ---- Gas data ----
gas =
structure(c(12099L, 11580L, 12272L, 12443L, 13449L, 13427L, 13874L,
13825L, 13140L, 13663L, 13064L, 13488L, 12527L, 12060L, 13163L,
13377L, 14089L, 13999L, 14447L, 14121L, 13376L, 13961L, 13520L,
13736L, 12714L, 12293L, 13647L, 13645L, 14351L, 14720L, 15138L,
15596L, 14722L, 14856L, 14536L, 15004L, 13871L, 13212L, 14757L,
14630L, 15945L, 16207L, 16057L, 16217L, 15194L, 15157L, 14681L,
15185L, 14473L, 14159L, 15616L, 16024L, 17428L, 16957L, 17039L,
17271L, 15975L, 16671L, 16237L, 16575L, 15956L, 14912L, 16562L,
16364L, 17316L, 17049L, 17478L, 17733L, 16791L, 17162L, 16006L,
16371L, 15235L, 14063L, 15358L, 15687L, 16780L, 16730L, 17294L,
16818L, 15859L, 16410L, 15373L, 16120L, 15115L, 14270L, 16298L,
17201L, 17908L, 17923L, 19120L, 19278L, 18559L, 18967L, 18232L,
19653L, 17693L, 18294L, 20819L, 19768L, 21214L, 22242L, 22264L,
22138L, 21668L, 21712L, 20898L, 21106L, 20089L, 18935L, 20797L,
21661L, 23850L, 23244L, 22072L, 22653L, 21379L, 20434L, 18437L,
17832L, 17504L, 16704L, 19833L, 21106L, 22228L, 21666L, 22981L,
23131L, 21378L, 22265L, 20887L, 20936L, 21204L, 20852L, 23872L,
22829L, 23293L, 22801L, 23994L, 24965L, 23400L, 23645L, 21946L,
22386L, 22773L, 22554L, 25602L, 26207L, 28578L, 28403L, 29286L,
28729L, 27351L, 29544L, 27676L, 27303L, 25566L, 24982L, 29380L,
30549L, 31151L, 31862L, 33888L, 36204L, 36260L, 36557L, 31260L,
31264L, 30800L, 29253L, 33887L, 36002L, 39016L, 39126L, 40585L,
41051L, 34830L, 33208L, 31556L, 32662L, 30922L, 29762L, 35603L,
36677L, 41378L, 40481L, 40696L, 40387L, 37675L, 39425L, 39802L,
39014L, 38691L, 37617L, 42231L, 43668L, 48521L, 50095L, 51739L,
49079L, 45195L, 40637L, 29879L, 26387L, 26552L, 25631L, 28462L,
29449L, 32973L, 35963L, 36359L, 37003L, 34373L, 35054L, 34374L,
35286L, 34184L, 31927L, 37281L, 38344L, 39216L, 38251L, 39093L,
38572L, 37189L, 38490L, 37071L, 39075L, 37986L, 36622L, 44283L,
45770L, 48148L, 47412L, 48086L, 48206L, 45336L, 45013L, 42883L,
42667L, 41332L, 42150L, 48326L, 47610L, 49157L, 46462L, 46655L,
50210L, 47240L, 49049L, 44522L, 42694L, 41832L, 42258L, 47725L,
46756L, 49088L, 48331L, 49616L, 49298L, 45767L, 46155L, 42016L,
42734L, 42164L, 40152L, 45742L, 46630L, 49803L, 48322L, 49438L,
48302L, 45062L, 44942L, 39730L, 36515L, 32002L, 31033L, 36075L,
36297L, 40093L, 40929L), .Tsp = c(1992, 2015.41666666667, 12), class = "ts")
# ---- Beer data ----
beer =
structure(c(1509L, 1541L, 1597L, 1675L, 1822L, 1775L, 1912L,
1862L, 1770L, 1882L, 1831L, 2511L, 1614L, 1529L, 1678L, 1713L,
1796L, 1792L, 1950L, 1777L, 1707L, 1757L, 1782L, 2443L, 1548L,
1505L, 1714L, 1757L, 1830L, 1857L, 1981L, 1858L, 1823L, 1806L,
1845L, 2577L, 1555L, 1501L, 1725L, 1699L, 1807L, 1863L, 1886L,
1861L, 1845L, 1788L, 1879L, 2598L, 1679L, 1652L, 1837L, 1798L,
1957L, 1958L, 2034L, 2062L, 1781L, 1860L, 1992L, 2547L, 1706L,
1621L, 1853L, 1817L, 2060L, 2002L, 2098L, 2079L, 1892L, 2050L,
2082L, 2821L, 1846L, 1768L, 1894L, 1963L, 2140L, 2059L, 2209L,
2118L, 2031L, 2163L, 2154L, 3037L, 1866L, 1808L, 1986L, 2099L,
2210L, 2145L, 2339L, 2140L, 2126L, 2219L, 2273L, 3265L, 1920L,
1976L, 2190L, 2132L, 2357L, 2413L, 2463L, 2422L, 2358L, 2352L,
2549L, 3375L, 2109L, 2052L, 2327L, 2231L, 2470L, 2526L, 2483L,
2518L, 2316L, 2409L, 2638L, 3542L, 2114L, 2109L, 2366L, 2300L,
2569L, 2486L, 2568L, 2595L, 2297L, 2401L, 2601L, 3488L, 2121L,
2046L, 2273L, 2333L, 2576L, 2433L, 2611L, 2660L, 2461L, 2641L,
2660L, 3654L, 2293L, 2219L, 2398L, 2553L, 2685L, 2643L, 2867L,
2622L, 2618L, 2727L, 2763L, 3801L, 2219L, 2316L, 2530L, 2640L,
2709L, 2783L, 2924L, 2791L, 2784L, 2801L, 2933L, 4137L, 2424L,
2519L, 2753L, 2791L, 3017L, 3055L, 3117L, 3024L, 2997L, 2913L,
3137L, 4269L, 2569L, 2603L, 3005L, 2867L, 3262L, 3364L, 3322L,
3292L, 3057L, 3087L, 3297L, 4403L, 2678L, 2810L, 2993L, 3002L,
3427L, 3287L, 3525L, 3482L, 3160L, 3362L, 3398L, 4475L, 2924L,
2792L, 3037L, 3144L, 3483L, 3322L, 3573L, 3416L, 3281L, 3444L,
3375L, 4652L, 2897L, 2935L, 3235L, 3333L, 3491L, 3463L, 3683L,
3481L, 3392L, 3525L, 3552L, 4720L, 2913L, 3012L, 3279L, 3394L,
3504L, 3585L, 3778L, 3612L, 3553L, 3552L, 3686L, 4944L, 3029L,
3238L, 3591L, 3449L, 3830L, 3862L, 3779L, 3799L, 3548L, 3673L,
3920L, 5193L, 3200L, 3274L, 3674L, 3511L, 4025L, 3866L, 4059L,
4127L, 3683L, 3839L, 4082L, 5284L, 3396L, 3372L, 3697L, 3713L,
4202L, 4098L, 4249L, 4223L, 3861L, 4092L, 4137L, 5610L, 3578L,
3519L, 3882L, 3867L, 4371L, 4239L), .Tsp = c(1992, 2015.41666666667,
12), class = "ts")
# --- Deault Seasonal Adjustment ----
m.gas = seas(gas)
m.beer = seas(beer)
plot(gas, main = "Retail sales - Gasoline stations")
lines(final(m.gas), col='red')
plot(beer, main = 'Retail sales - Beer, wine, and liquor stores')
lines(final(m.beer), col='red')
# ---- Run same input file as BLS ----
s = import.spc()