Rcode Result
Rcode Result
> help(forecast)
> library(quantmod)
> library(tseries)
> library(tseries)
> library(forecast)
> library(xts)
> library(forecast)
> library(zoo)
> library(xts)
> library(TTR)
> library(quantmod)
> library(fpp2)
> gas
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
1956 1709 1646 1794 1878 2173 2321 2468 2416 2184 2121 1962 1825
1957 1751 1688 1920 1941 2311 2279 2638 2448 2279 2163 1941 1878
1958 1773 1688 1783 1984 2290 2511 2712 2522 2342 2195 1931 1910
1959 1730 1688 1899 1994 2342 2553 2712 2627 2363 2311 2026 1910
1960 1762 1815 2005 2089 2617 2828 2965 2891 2532 2363 2216 2026
1961 1804 1773 2015 2089 2627 2712 3007 2880 2490 2237 2205 1984
1962 1868 1815 2047 2142 2743 2775 3028 2965 2501 2501 2131 2015
1963 1910 1868 2121 2268 2690 2933 3218 3028 2659 2406 2258 2057
1964 1889 1984 2110 2311 2785 3039 3229 3070 2659 2543 2237 2142
1965 1962 1910 2216 2437 2817 3123 3345 3112 2659 2469 2332 2110
1966 1910 1941 2216 2342 2923 3229 3513 3355 2849 2680 2395 2205
1967 1994 1952 2290 2395 2965 3239 3608 3524 3018 2648 2363 2247
1968 1994 1941 2258 2332 3323 3608 3957 3672 3155 2933 2585 2384
1969 2057 2100 2458 2638 3292 3724 4652 4379 4231 3756 3429 3461
1970 3345 4220 4874 5064 5951 6774 7997 7523 7438 6879 6489 6288
1971 5919 6183 6594 6489 8040 9715 9714 9756 8595 7861 7753 8154
1972 7778 7402 8903 9742 11372 12741 13733 13691 12239 12502 11241 10829
1973 11569 10397 12493 11962 13974 14945 16805 16587 14225 14157 13016 12253
1974 11704 12275 13695 14082 16555 17339 17777 17592 16194 15336 14208 13116
1975 12354 12682 14141 14989 16159 18276 19157 18737 17109 17094 15418 14312
1976 13260 14990 15975 16770 19819 20983 22001 22337 20750 19969 17293 16498
1977 15117 16058 18137 18471 21398 23854 26025 25479 22804 19619 19627 18488
1978 17243 18284 20226 20903 23768 26323 28038 26776 22886 22813 22404 19795
1979 18839 18892 20823 22212 25076 26884 30611 30228 26762 25885 23328 21930
1980 21433 22369 24503 25905 30605 34984 37060 34502 31793 29275 28305 25248
1981 27730 27424 32684 31366 37459 41060 43558 42398 33827 34962 33480 32445
1982 30715 30400 31451 31306 40592 44133 47387 41310 37913 34355 34607 28729
1983 26138 30745 35018 34549 40980 42869 45022 40387 38180 38608 35308 30234
1984 28801 33034 35294 33181 40797 42355 46098 42430 41851 39331 37328 34514
1985 32494 33308 36805 34221 41020 44350 46173 44435 40943 39269 35901 32142
1986 31239 32261 34951 38109 43168 45547 49568 45387 41805 41281 36068 34879
1987 32791 34206 39128 40249 43519 46137 56709 52306 49397 45500 39857 37958
1988 35567 37696 42319 39137 47062 50610 54457 54435 48516 43225 42155 39995
1989 37541 37277 41778 41666 49616 57793 61884 62400 50820 51116 45731 42528
1990 40459 40295 44147 42697 52561 56572 56858 58363 45627 45622 41304 36016
1991 35592 35677 39864 41761 50380 49129 55066 55671 49058 44503 42145 38698
1992 38963 38690 39792 42545 50145 58164 59035 59408 55988 47321 42269 39606
1993 37059 37963 31043 41712 50366 56977 56807 54634 51367 48073 46251 43736
1994 39975 40478 46895 46147 55011 57799 62450 63896 57784 53231 50354 38410
1995 41600 41471 46287 49013 56624 61739 66600 60054
> periodicity(gas)
Monthly periodicity from Jan 1956 to Aug 1995
> plot(gas)
> attach(gas)
Error in attach(gas) :
'attach' only works for lists, data frames and environments
> summary(gas)
Min. 1st Qu. Median Mean 3rd Qu. Max.
1646 2675 16788 21415 38629 66600
> head(gas)
Jan Feb Mar Apr May Jun
1956 1709 1646 1794 1878 2173 2321
> tail(gas)
Mar Apr May Jun Jul Aug
1995 46287 49013 56624 61739 66600 60054
>
> ##convert to time series object
> gasts_ts= ts(gas, frequency = 12,start = c(1956),end = c(1995,8))
> View(gasts_ts)
> class(gasts_ts)
[1] "ts"
> plot(gasts_ts)
> decomp_gasts_ts = stl(gasts_ts,s.window = 'periodic')
> decomp_gasts_ts
Call:
stl(x = gasts_ts, s.window = "periodic")
Model Information:
Simple exponential smoothing
Call:
ses(y = gasts.train, h = 12, alpha = 0.2)
Smoothing parameters:
alpha = 0.2
Initial states:
l = 1915.675
sigma: 4208.612
Error measures:
ME RMSE MAE MPE MAPE MASE ACF1
Training set 503.1702 4199.373 2673.83 0.9465959 13.8564 1.524244 0.7710794
Forecasts:
Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
Jan 1994 47804.79 42411.24 53198.35 39556.07 56053.52
Feb 1994 47804.79 42304.43 53305.16 39392.71 56216.88
Mar 1994 47804.79 42199.65 53409.94 39232.46 56377.12
Apr 1994 47804.79 42096.79 53512.80 39075.16 56534.43
May 1994 47804.79 41995.76 53613.83 38920.64 56688.95
Jun 1994 47804.79 41896.45 53713.14 38768.77 56840.82
Jul 1994 47804.79 41798.79 53810.80 38619.40 56990.19
Aug 1994 47804.79 41702.69 53906.90 38472.42 57137.17
Sep 1994 47804.79 41608.07 54001.52 38327.73 57281.86
Oct 1994 47804.79 41514.88 54094.71 38185.21 57424.38
Nov 1994 47804.79 41423.06 54186.53 38044.77 57564.82
Dec 1994 47804.79 41332.53 54277.06 37906.32 57703.27
> autoplot(ses.gasts)
> ses.gasts
Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
Jan 1994 47804.79 42411.24 53198.35 39556.07 56053.52
Feb 1994 47804.79 42304.43 53305.16 39392.71 56216.88
Mar 1994 47804.79 42199.65 53409.94 39232.46 56377.12
Apr 1994 47804.79 42096.79 53512.80 39075.16 56534.43
May 1994 47804.79 41995.76 53613.83 38920.64 56688.95
Jun 1994 47804.79 41896.45 53713.14 38768.77 56840.82
Jul 1994 47804.79 41798.79 53810.80 38619.40 56990.19
Aug 1994 47804.79 41702.69 53906.90 38472.42 57137.17
Sep 1994 47804.79 41608.07 54001.52 38327.73 57281.86
Oct 1994 47804.79 41514.88 54094.71 38185.21 57424.38
Nov 1994 47804.79 41423.06 54186.53 38044.77 57564.82
Dec 1994 47804.79 41332.53 54277.06 37906.32 57703.27
> accuracy(ses.gasts, gasts.test)
ME RMSE MAE MPE MAPE MASE ACF
1 Theil's U
Training set 503.1702 4199.373 2673.830 0.9465959 13.85640 1.524244 0.771079
4 NA
Test set 3231.0385 8979.490 7750.868 3.6560301 14.93589 4.418462 0.618406
0 1.415467
> ses.gasts1 = ses(gasts.train, h=12)
> summary(ses.gasts1)
Model Information:
Simple exponential smoothing
Call:
ses(y = gasts.train, h = 12)
Smoothing parameters:
alpha = 0.9999
Initial states:
l = 2070.491
sigma: 2656.467
Error measures:
ME RMSE MAE MPE MAPE MASE ACF
1
Training set 91.38143 2650.635 1602.944 0.1732567 8.223326 0.9137747 0.305531
5
Forecasts:
Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
Jan 1994 43736.25 40331.85 47140.65 38529.67 48942.83
Feb 1994 43736.25 38921.94 48550.56 36373.40 51099.10
Mar 1994 43736.25 37840.05 49632.45 34718.79 52753.71
Apr 1994 43736.25 36927.96 50544.54 33323.87 54148.63
May 1994 43736.25 36124.39 51348.11 32094.92 55377.59
Jun 1994 43736.25 35397.90 52074.60 30983.85 56488.65
Jul 1994 43736.25 34729.83 52742.67 29962.12 57510.39
Aug 1994 43736.25 34108.00 53364.51 29011.11 58461.40
Sep 1994 43736.25 33523.96 53948.54 28117.90 59354.60
Oct 1994 43736.25 32971.56 54500.94 27273.08 60199.42
Nov 1994 43736.25 32446.16 55026.34 26469.55 61002.95
Dec 1994 43736.25 31944.15 55528.36 25701.78 61770.72
> autoplot(ses.gasts1)
> ses.gasts1
Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
Jan 1994 43736.25 40331.85 47140.65 38529.67 48942.83
Feb 1994 43736.25 38921.94 48550.56 36373.40 51099.10
Mar 1994 43736.25 37840.05 49632.45 34718.79 52753.71
Apr 1994 43736.25 36927.96 50544.54 33323.87 54148.63
May 1994 43736.25 36124.39 51348.11 32094.92 55377.59
Jun 1994 43736.25 35397.90 52074.60 30983.85 56488.65
Jul 1994 43736.25 34729.83 52742.67 29962.12 57510.39
Aug 1994 43736.25 34108.00 53364.51 29011.11 58461.40
Sep 1994 43736.25 33523.96 53948.54 28117.90 59354.60
Oct 1994 43736.25 32971.56 54500.94 27273.08 60199.42
Nov 1994 43736.25 32446.16 55026.34 26469.55 61002.95
Dec 1994 43736.25 31944.15 55528.36 25701.78 61770.72
> accuracy(ses.gasts1, gasts.test)
ME RMSE MAE MPE MAPE MASE
ACF1 Theil's U
Training set 91.38143 2650.635 1602.944 0.1732567 8.223326 0.9137747 0.3
055315 NA
Test set 7299.58164 11111.954 9357.207 11.8556176 17.076498 5.3341723 0.6
184060 1.755031
> #Simple exponential smoothing of difference
> ```{r}
Error: attempt to use zero-length variable name
> gasts.dif.train <- diff(gasts.train)
> gasts.dif.test <- diff(gasts.test)
> # autoplot(msales.train)
> autoplot(gasts.dif.train)
> ses.gasts.dif <- ses(gasts.dif.train, h = 12)
> ses.gasts.dif$model
Simple exponential smoothing
Call:
ses(y = gasts.dif.train, h = 12)
Smoothing parameters:
alpha = 0.5033
Initial states:
l = 29.8921
sigma: 2808.945
Call:
ses(y = gasts.dif.train, h = 12, alpha = 0.2)
Smoothing parameters:
alpha = 0.2
Initial states:
l = 53.13
sigma: 2817.901
AIC AICc BIC
10015.54 10015.57 10023.78
> accuracy(ses.gasts.dif, gasts.dif.test)
ME RMSE MAE MPE MAPE MASE AC
F1 Theil's U
Training set -10.1999 2802.765 1609.073 Inf Inf 1.593128 0.0050515
17 NA
Test set 2163.8071 6122.679 5120.476 128.7321 166.6047 5.069733 0.2883124
46 1.264665
> autoplot(ses.gasts.dif)
> accuracy(ses.gasts.dif1, gasts.dif.test)
ME RMSE MAE MPE MAPE MASE ACF1
Theil's U
Training set -11.76185 2811.701 1660.831 Inf Inf 1.644372 0.2535082
NA
Test set 874.92598 5794.017 4768.963 112.6735 119.217 4.721704 0.2883124
1.112246
> autoplot(ses.gasts.dif1)
> #Holts method
> ```{r}
Error: attempt to use zero-length variable name
> holt.sales <- holt(gasts.train, h = 12)
> autoplot(holt.sales)
> holt.sales$model
Holt's method
Call:
holt(y = gasts.train, h = 12)
Smoothing parameters:
alpha = 0.9391
beta = 0.5951
Initial states:
l = 1818.3319
b = 75.0712
sigma: 2812.209
Smoothing parameters:
alpha = 0.9999
beta = 0.2
Initial states:
l = 1653.3374
b = 165.6286
sigma: 2821.126
Call:
ets(y = gasts.train, model = "AAA")
Smoothing parameters:
alpha = 0.3862
beta = 0.002
gamma = 0.5958
Initial states:
l = 2649.4763
b = 31.9035
s = -2953.874 -1420.906 152.817 1334.408 3904.675 4816.773
3471.111 1650.429 -1708.804 -2036.11 -3410.916 -3799.603
sigma: 1608.316
Call:
ets(y = gasts.train, model = "MAM")
Smoothing parameters:
alpha = 0.7053
beta = 0.0279
gamma = 1e-04
phi = 0.9799
Initial states:
l = 2023.6395
b = 4.4351
s = 0.8519 0.9218 1.0072 1.0714 1.206 1.262
1.1752 1.0887 0.9176 0.8916 0.8087 0.7977
sigma: 0.05
Components
seasonal trend remainder
Jan 1956 -4083.7994 3000.295 2792.50473
Feb 1956 -3715.9678 2792.712 2569.25583
Mar 1956 -2165.1863 2585.129 1374.05703
Apr 1956 -1809.3076 2461.267 1226.04094
May 1956 1713.8461 2337.404 -1878.25008
Jun 1956 3591.8664 2261.258 -3532.12392
Jul 1956 5312.5120 2185.111 -5029.62308
Aug 1956 4256.0658 2100.722 -3940.78794
Sep 1956 1528.2903 2016.333 -1360.62357
Oct 1956 163.9636 2115.969 -158.93237
Nov 1956 -1471.7225 2215.604 1218.11825
Dec 1956 -3320.5600 2333.018 2812.54224
Jan 1957 -4083.7994 2450.431 3384.36823
Feb 1957 -3715.9678 2379.171 3024.79674
Mar 1957 -2165.1863 2307.911 1777.27535
Apr 1957 -1809.3076 2127.690 1622.61780
May 1957 1713.8461 1947.469 -1350.31467
Jun 1957 3591.8664 1848.064 -3160.93037
Jul 1957 5312.5120 1748.659 -4423.17138
Aug 1957 4256.0658 1813.580 -3621.64562
Sep 1957 1528.2903 1878.500 -1127.79062
Oct 1957 163.9636 2062.935 -63.89864
Nov 1957 -1471.7225 2247.370 1165.35277
Dec 1957 -3320.5600 2363.266 2835.29385
Jan 1958 -4083.7994 2479.162 3377.63692
Feb 1958 -3715.9678 2409.680 2994.28730
Mar 1958 -2165.1863 2340.199 1607.98779
Apr 1958 -1809.3076 2161.713 1631.59472
May 1958 1713.8461 1983.227 -1407.07326
Jun 1958 3591.8664 1884.956 -2965.82191
Jul 1958 5312.5120 1786.684 -4387.19588
Aug 1958 4256.0658 1853.630 -3587.69588
Sep 1958 1528.2903 1920.576 -1106.86664
Oct 1958 163.9636 2105.137 -74.10048
Nov 1958 -1471.7225 2289.697 1113.02509
Dec 1958 -3320.5600 2401.617 2828.94271
Jan 1959 -4083.7994 2513.537 3300.26232
Feb 1959 -3715.9678 2442.855 2961.11275
Mar 1959 -2165.1863 2372.173 1692.01329
Apr 1959 -1809.3076 2197.581 1605.72609
May 1959 1713.8461 2022.990 -1394.83603
Jun 1959 3591.8664 1929.417 -2968.28349
Jul 1959 5312.5120 1835.844 -4436.35628
Aug 1959 4256.0658 1907.484 -3536.55008
Sep 1959 1528.2903 1979.124 -1144.41464
Oct 1959 163.9636 2172.498 -25.46135
Nov 1959 -1471.7225 2365.871 1131.85135
Dec 1959 -3320.5600 2493.549 2737.01053
Jan 1960 -4083.7994 2621.228 3224.57169
Feb 1960 -3715.9678 2566.047 2964.92075
Mar 1960 -2165.1863 2510.866 1659.31991
Apr 1960 -1809.3076 2346.502 1551.80530
May 1960 1713.8461 2182.138 -1278.98423
Jun 1960 3591.8664 2092.325 -2856.19105
Jul 1960 5312.5120 2002.511 -4350.02321
Aug 1960 4256.0658 2067.275 -3432.34066
Sep 1960 1528.2903 2132.039 -1128.32889
Oct 1960 163.9636 2307.325 -108.28820
Nov 1960 -1471.7225 2482.611 1205.11192
Dec 1960 -3320.5600 2586.668 2759.89208
Jan 1961 -4083.7994 2690.725 3197.07424
Feb 1961 -3715.9678 2614.672 2874.29621
Mar 1961 -2165.1863 2538.618 1641.56828
Apr 1961 -1809.3076 2358.543 1539.76457
May 1961 1713.8461 2178.468 -1265.31406
Jun 1961 3591.8664 2080.397 -2960.26290
Jul 1961 5312.5120 1982.325 -4287.83706
Aug 1961 4256.0658 2048.106 -3424.17215
Sep 1961 1528.2903 2113.888 -1152.17801
Oct 1961 163.9636 2295.612 -222.57579
Nov 1961 -1471.7225 2477.337 1199.38586
Dec 1961 -3320.5600 2589.926 2714.63439
Jan 1962 -4083.7994 2702.514 3249.28492
Feb 1962 -3715.9678 2636.394 2894.57393
Mar 1962 -2165.1863 2570.273 1641.91305
Apr 1962 -1809.3076 2400.088 1551.22004
May 1962 1713.8461 2229.902 -1200.74790
Jun 1962 3591.8664 2136.080 -2952.94641
Jul 1962 5312.5120 2042.258 -4326.77024
Aug 1962 4256.0658 2108.492 -3399.55781
Sep 1962 1528.2903 2174.726 -1202.01615
Oct 1962 163.9636 2356.422 -19.38563
Nov 1962 -1471.7225 2538.118 1064.60431
Dec 1962 -3320.5600 2652.947 2682.61253
Jan 1963 -4083.7994 2767.777 3226.02273
Feb 1963 -3715.9678 2704.827 2879.14104
Mar 1963 -2165.1863 2641.877 1644.30946
Apr 1963 -1809.3076 2472.753 1604.55426
May 1963 1713.8461 2303.630 -1327.47586
Jun 1963 3591.8664 2210.048 -2868.91412
Jul 1963 5312.5120 2116.466 -4210.97770
Aug 1963 4256.0658 2180.771 -3408.83673
Sep 1963 1528.2903 2245.076 -1114.36653
Oct 1963 163.9636 2423.672 -181.63569
Nov 1963 -1471.7225 2602.268 1127.45457
Dec 1963 -3320.5600 2713.282 2664.27789
Jan 1964 -4083.7994 2824.296 3148.50319
Feb 1964 -3715.9678 2757.807 2942.16130
Mar 1964 -2165.1863 2691.317 1583.86952
Apr 1964 -1809.3076 2522.048 1598.25932
May 1964 1713.8461 2352.780 -1281.62581
Jun 1964 3591.8664 2259.615 -2812.48114
Jul 1964 5312.5120 2166.450 -4249.96180
Aug 1964 4256.0658 2230.649 -3416.71428
Sep 1964 1528.2903 2294.847 -1164.13753
Oct 1964 163.9636 2473.943 -94.90705
Nov 1964 -1471.7225 2653.040 1055.68285
Dec 1964 -3320.5600 2765.827 2696.73262
Jan 1965 -4083.7994 2878.615 3167.18439
Feb 1965 -3715.9678 2812.918 2813.04934
Mar 1965 -2165.1863 2747.222 1633.96440
Apr 1965 -1809.3076 2575.398 1670.91003
May 1965 1713.8461 2403.573 -1300.41927
Jun 1965 3591.8664 2305.902 -2774.76841
Jul 1965 5312.5120 2208.231 -4175.74287
Aug 1965 4256.0658 2266.392 -3410.45765
Sep 1965 1528.2903 2324.553 -1193.84321
Oct 1965 163.9636 2497.239 -192.20300
Nov 1965 -1471.7225 2669.926 1133.79663
Dec 1965 -3320.5600 2784.160 2646.39953
Jan 1966 -4083.7994 2898.395 3095.40442
Feb 1966 -3715.9678 2844.836 2812.13169
Mar 1966 -2165.1863 2791.277 1589.90907
Apr 1966 -1809.3076 2635.405 1515.90260
May 1966 1713.8461 2479.533 -1270.37880
Jun 1966 3591.8664 2393.690 -2756.55631
Jul 1966 5312.5120 2307.847 -4107.35916
Aug 1966 4256.0658 2372.828 -3273.89359
Sep 1966 1528.2903 2437.808 -1117.09879
Oct 1966 163.9636 2610.288 -94.25136
Nov 1966 -1471.7225 2782.767 1083.95548
Dec 1966 -3320.5600 2889.433 2636.12697
Jan 1967 -4083.7994 2996.099 3081.70044
Feb 1967 -3715.9678 2934.470 2733.49800
Mar 1967 -2165.1863 2872.841 1582.34568
Apr 1967 -1809.3076 2710.283 1494.02439
May 1967 1713.8461 2547.726 -1296.57182
Jun 1967 3591.8664 2456.627 -2809.49296
Jul 1967 5312.5120 2365.527 -4070.03943
Aug 1967 4256.0658 2425.056 -3157.12165
Sep 1967 1528.2903 2484.584 -994.87464
Oct 1967 163.9636 2658.324 -174.28742
Nov 1967 -1471.7225 2832.063 1002.65921
Dec 1967 -3320.5600 2951.194 2616.36596
Jan 1968 -4083.7994 3070.325 3007.47471
Feb 1968 -3715.9678 3024.231 2632.73696
Mar 1968 -2165.1863 2978.137 1445.04932
Apr 1968 -1809.3076 2833.487 1307.82061
May 1968 1713.8461 2688.837 -1079.68303
Jun 1968 3591.8664 2614.227 -2598.09293
Jul 1968 5312.5120 2539.616 -3895.12815
Aug 1968 4256.0658 2610.429 -3194.49465
Sep 1968 1528.2903 2681.242 -1054.53190
Oct 1968 163.9636 2855.062 -86.02572
Nov 1968 -1471.7225 3028.883 1027.83988
Dec 1968 -3320.5600 3149.738 2554.82243
Jan 1969 -4083.7994 3270.592 2870.20697
Feb 1969 -3715.9678 3257.759 2558.20905
Mar 1969 -2165.1863 3244.925 1378.26123
Apr 1969 -1809.3076 3161.328 1285.97978
May 1969 1713.8461 3077.730 -1499.57658
Jun 1969 3591.8664 3092.145 -2960.01109
Jul 1969 5312.5120 3106.559 -3767.07092
Aug 1969 4256.0658 3319.015 -3196.08120
Sep 1969 1528.2903 3531.472 -828.76225
Oct 1969 163.9636 3897.679 -305.64244
Nov 1969 -1471.7225 4263.886 636.83678
Dec 1969 -3320.5600 4606.160 2175.40004
Jan 1970 -4083.7994 4948.434 2480.36529
Feb 1970 -3715.9678 5154.938 2781.02977
Mar 1970 -2165.1863 5361.442 1677.74436
Apr 1970 -1809.3076 5476.726 1396.58126
May 1970 1713.8461 5592.011 -1354.85675
Jun 1970 3591.8664 5740.503 -2558.36940
Jul 1970 5312.5120 5888.995 -3204.50737
Aug 1970 4256.0658 6122.533 -2855.59859
Sep 1970 1528.2903 6356.070 -446.36056
Oct 1970 163.9636 6658.479 56.55689
Nov 1970 -1471.7225 6960.889 999.83377
Dec 1970 -3320.5600 7210.547 2398.01322
Jan 1971 -4083.7994 7460.205 2542.59466
Feb 1971 -3715.9678 7547.807 2351.16105
Mar 1971 -2165.1863 7635.409 1123.77754
Apr 1971 -1809.3076 7616.536 681.77198
May 1971 1713.8461 7597.662 -1271.50850
Jun 1971 3591.8664 7650.173 -1527.03972
Jul 1971 5312.5120 7702.684 -3301.19627
Aug 1971 4256.0658 7911.286 -2411.35182
Sep 1971 1528.2903 8119.888 -1053.17813
Oct 1971 163.9636 8470.825 -773.78889
Nov 1971 -1471.7225 8821.763 402.95977
Dec 1971 -3320.5600 9184.641 2289.91914
Jan 1972 -4083.7994 9547.519 2314.28050
Feb 1972 -3715.9678 9829.624 1288.34395
Mar 1972 -2165.1863 10111.729 956.45750
Apr 1972 -1809.3076 10319.764 1231.54402
May 1972 1713.8461 10527.798 -869.64439
Jun 1972 3591.8664 10756.307 -1607.17346
Jul 1972 5312.5120 10984.816 -2564.32786
Aug 1972 4256.0658 11289.412 -1854.47747
Sep 1972 1528.2903 11594.008 -883.29785
Oct 1972 163.9636 11933.039 404.99712
Nov 1972 -1471.7225 12272.071 440.65151
Dec 1972 -3320.5600 12548.563 1600.99669
Jan 1973 -4083.7994 12825.056 2827.74386
Feb 1973 -3715.9678 12982.385 1130.58315
Mar 1973 -2165.1863 13139.714 1518.47255
Apr 1973 -1809.3076 13196.967 574.34059
May 1973 1713.8461 13254.220 -994.06629
Jun 1973 3591.8664 13310.288 -1957.15390
Jul 1973 5312.5120 13366.355 -1873.86684
Aug 1973 4256.0658 13510.094 -1179.16024
Sep 1973 1528.2903 13653.834 -957.12442
Oct 1973 163.9636 13897.737 95.29894
Nov 1973 -1471.7225 14141.641 346.08171
Dec 1973 -3320.5600 14354.989 1218.57085
Jan 1974 -4083.7994 14568.337 1219.46199
Feb 1974 -3715.9678 14666.046 1324.92131
Mar 1974 -2165.1863 14763.756 1096.43074
Apr 1974 -1809.3076 14791.952 1099.35605
May 1974 1713.8461 14820.147 21.00644
Jun 1974 3591.8664 14846.258 -1099.12402
Jul 1974 5312.5120 14872.368 -2407.87981
Aug 1974 4256.0658 14936.015 -1600.08061
Sep 1974 1528.2903 14999.662 -333.95218
Oct 1974 163.9636 15111.099 60.93689
Nov 1974 -1471.7225 15222.537 457.18538
Dec 1974 -3320.5600 15332.213 1104.34727
Jan 1975 -4083.7994 15441.888 995.91115
Feb 1975 -3715.9678 15503.908 894.05945
Mar 1975 -2165.1863 15565.928 740.25786
Apr 1975 -1809.3076 15602.883 1195.42478
May 1975 1713.8461 15639.837 -1194.68322
Jun 1975 3591.8664 15716.829 -1032.69579
Jul 1975 5312.5120 15793.822 -1949.33369
Aug 1975 4256.0658 15956.766 -1475.83136
Sep 1975 1528.2903 16119.709 -538.99980
Oct 1975 163.9636 16378.921 551.11580
Nov 1975 -1471.7225 16638.132 251.59082
Dec 1975 -3320.5600 16923.141 709.41864
Jan 1976 -4083.7994 17208.151 135.64844
Feb 1976 -3715.9678 17453.005 1252.96329
Mar 1976 -2165.1863 17697.858 442.32825
Apr 1976 -1809.3076 17889.769 689.53869
May 1976 1713.8461 18081.680 23.47420
Jun 1976 3591.8664 18239.031 -847.89703
Jul 1976 5312.5120 18396.382 -1707.89358
Aug 1976 4256.0658 18548.770 -467.83532
Sep 1976 1528.2903 18701.157 520.55218
Oct 1976 163.9636 18888.111 916.92489
Nov 1976 -1471.7225 19075.066 -310.34299
Dec 1976 -3320.5600 19300.746 517.81386
Jan 1977 -4083.7994 19526.427 -325.62730
Feb 1977 -3715.9678 19728.963 45.00472
Mar 1977 -2165.1863 19931.499 370.68684
Apr 1977 -1809.3076 20073.825 206.48291
May 1977 1713.8461 20216.150 -531.99595
Jun 1977 3591.8664 20364.032 -101.89881
Jul 1977 5312.5120 20511.915 200.57300
Aug 1977 4256.0658 20685.981 536.95350
Sep 1977 1528.2903 20860.046 415.66323
Oct 1977 163.9636 21050.922 -1595.88577
Nov 1977 -1471.7225 21241.798 -143.07535
Dec 1977 -3320.5600 21429.666 378.89435
Jan 1978 -4083.7994 21617.533 -290.73396
Feb 1978 -3715.9678 21771.256 228.71169
Mar 1978 -2165.1863 21924.979 466.20745
Apr 1978 -1809.3076 22079.176 633.13132
May 1978 1713.8461 22233.374 -179.21973
Jun 1978 3591.8664 22362.700 368.43394
Jul 1978 5312.5120 22492.026 233.46228
Aug 1978 4256.0658 22581.055 -61.12029
Sep 1978 1528.2903 22670.083 -1312.37362
Oct 1978 163.9636 22751.098 -102.06162
Nov 1978 -1471.7225 22832.113 1043.60981
Dec 1978 -3320.5600 22970.967 144.59309
Jan 1979 -4083.7994 23109.821 -187.02164
Feb 1979 -3715.9678 23330.179 -722.21139
Mar 1979 -2165.1863 23550.537 -562.35103
Apr 1979 -1809.3076 23787.702 233.60525
May 1979 1713.8461 24024.867 -662.71339
Jun 1979 3591.8664 24245.116 -952.98284
Jul 1979 5312.5120 24465.366 833.12239
Aug 1979 4256.0658 24727.827 1244.10699
Sep 1979 1528.2903 24990.289 243.42082
Oct 1979 163.9636 25336.443 384.59320
Nov 1979 -1471.7225 25682.598 -882.87500
Dec 1979 -3320.5600 26144.492 -893.93159
Jan 1980 -4083.7994 26606.386 -1089.58619
Feb 1980 -3715.9678 27090.586 -1005.61786
Mar 1980 -2165.1863 27574.786 -906.59943
Apr 1980 -1809.3076 28017.702 -303.39485
May 1980 1713.8461 28460.619 430.53480
Jun 1980 3591.8664 28870.852 2521.28146
Jul 1980 5312.5120 29281.085 2466.40279
Aug 1980 4256.0658 29707.731 538.20333
Sep 1980 1528.2903 30134.377 130.33310
Oct 1980 163.9636 30587.308 -1476.27175
Nov 1980 -1471.7225 31040.240 -1263.51717
Dec 1980 -3320.5600 31572.407 -3003.84705
Jan 1981 -4083.7994 32104.574 -290.77494
Feb 1981 -3715.9678 32678.979 -1539.01124
Mar 1981 -2165.1863 33253.384 1595.80257
Apr 1981 -1809.3076 33779.544 -604.23628
May 1981 1713.8461 34305.704 1439.44995
Jun 1981 3591.8664 34690.229 2777.90449
Jul 1981 5312.5120 35074.754 3170.73371
Aug 1981 4256.0658 35215.498 2926.43603
Sep 1981 1528.2903 35356.242 -3057.53242
Oct 1981 163.9636 35361.111 -563.07503
Nov 1981 -1471.7225 35365.981 -414.25823
Dec 1981 -3320.5600 35499.255 266.30495
Jan 1982 -4083.7994 35632.529 -833.72988
Feb 1982 -3715.9678 35865.288 -1749.32000
Mar 1982 -2165.1863 36098.046 -2481.86000
Apr 1982 -1809.3076 36251.730 -3136.42227
May 1982 1713.8461 36405.413 2472.74053
Jun 1982 3591.8664 36339.626 4201.50771
Jul 1982 5312.5120 36273.838 5800.64956
Aug 1982 4256.0658 36175.581 878.35355
Sep 1982 1528.2903 36077.323 307.38677
Oct 1982 163.9636 36001.310 -1810.27406
Nov 1982 -1471.7225 35925.298 153.42453
Dec 1982 -3320.5600 35871.964 -3822.40393
Jan 1983 -4083.7994 35818.630 -5596.83041
Feb 1983 -3715.9678 35907.307 -1446.33941
Mar 1983 -2165.1863 35995.985 1187.20170
Apr 1983 -1809.3076 36248.119 110.18807
May 1983 1713.8461 36500.254 2765.89952
Jun 1983 3591.8664 36686.348 2590.78560
Jul 1983 5312.5120 36872.442 2837.04635
Aug 1983 4256.0658 36893.169 -762.23526
Sep 1983 1528.2903 36913.897 -262.18764
[ reached getOption("max.print") -- omitted 143 rows ]
> plot(decomp_gasts_ts)
> deseasonal_gasts=seasadj(decomp_gasts_ts)
> plot(deseasonal_gasts)
> Check for stationarity
Error: unexpected 'for' in "Check for"
> ```{r}
Error: attempt to use zero-length variable name
> adf.test(gasts_ts, alternative = "stationary")
data: gasts_ts
Dickey-Fuller = -2.7131, Lag order = 7, p-value = 0.2764
alternative hypothesis: stationary
> acf(gasts_ts)
> acf(gasts_ts, lag.max = 24)
> pacf(gasts_ts, lag.max = 24)
> count_d1 = diff(deseasonal_gasts, differences = 1)
> plot(count_d1)
> adf.test(count_d1, alternative = "stationary")
data: count_d1
Dickey-Fuller = -18.14, Lag order = 7, p-value = 0.01
alternative hypothesis: stationary
Warning message:
In adf.test(count_d1, alternative = "stationary") :
p-value smaller than printed p-value
> Acf(count_d1, main='ACF for Differenced Series')
> Pacf(count_d1, main='PACF for Differenced Series')
> gaststrain = window(deseasonal_gasts, end = c(1994,12))
> gastsARIMA = arima(gaststrain, order=c(0,1,0),season=list(order = c(2,0,2),
period=12))
> gaststest= window(deseasonal_gasts, start = c(1995,1))
> gastsARIMA
Call:
arima(x = gaststrain, order = c(0, 1, 0), seasonal = list(order = c(2, 0, 2),
period = 12))
Coefficients:
sar1 sar2 sma1 sma2
0.6836 0.2407 -0.3221 -0.2448
s.e. 0.3290 0.3063 0.3234 0.2031
Coefficients:
ar1 ma1 ma2 ma3 ma4 sma1
-0.8842 0.4434 -0.4443 -0.1713 -0.1894 -0.6072
s.e. 0.0712 0.0798 0.0604 0.0581 0.0533 0.0389
Box-Pierce test
data: gastsARIMA$residuals
X-squared = 34.871, df = 1, p-value = 3.523e-09
> Box.test(autoarima1$residuals)
Box-Pierce test
data: autoarima1$residuals
X-squared = 0.023919, df = 1, p-value = 0.8771
Box-Pierce test
data: gastsARIMA$residuals
X-squared = 34.871, df = 1, p-value = 3.523e-09
> Box.test(autoarima1$residuals)
Box-Pierce test
data: autoarima1$residuals
X-squared = 0.023919, df = 1, p-value = 0.8771