Skip to content

Commit 8c671ec

Browse files
Merge branch 'master' into naive_models
2 parents 72b32b2 + 809189e commit 8c671ec

19 files changed

+777
-33
lines changed

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1717
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
1818

1919
[compat]
20-
Distributions = "0.23, 0.24"
20+
Distributions = "0.16, 0.17, 0.18, 0.19, 0.20, 0.21, 0.22, 0.23, 0.24"
2121
MatrixEquations = "1"
22-
Optim = "0.20, 0.21, 0.22, 1.2"
22+
Optim = "0.17, 0.18, 0.19, 0.20, 0.21, 0.22, 1.2"
2323
OrderedCollections = "1"
2424
Polynomials = "1"
2525
RecipesBase = "1"
2626
ShiftedArrays = "1"
27-
StatsBase = "0.33"
27+
StatsBase = "0.27, 0.28, 0.29, 0.30, 0.31, 0.32, 0.33"
2828
julia = "1"
2929

3030
[extras]

datasets/sunspot_year.csv

Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
year,value
2+
1700,5
3+
1701,11
4+
1702,16
5+
1703,23
6+
1704,36
7+
1705,58
8+
1706,29
9+
1707,20
10+
1708,10
11+
1709,8
12+
1710,3
13+
1711,0
14+
1712,0
15+
1713,2
16+
1714,11
17+
1715,27
18+
1716,47
19+
1717,63
20+
1718,60
21+
1719,39
22+
1720,28
23+
1721,26
24+
1722,22
25+
1723,11
26+
1724,21
27+
1725,40
28+
1726,78
29+
1727,122
30+
1728,103
31+
1729,73
32+
1730,47
33+
1731,35
34+
1732,11
35+
1733,5
36+
1734,16
37+
1735,34
38+
1736,70
39+
1737,81
40+
1738,111
41+
1739,101
42+
1740,73
43+
1741,40
44+
1742,20
45+
1743,16
46+
1744,5
47+
1745,11
48+
1746,22
49+
1747,40
50+
1748,60
51+
1749,80.9
52+
1750,83.4
53+
1751,47.7
54+
1752,47.8
55+
1753,30.7
56+
1754,12.2
57+
1755,9.6
58+
1756,10.2
59+
1757,32.4
60+
1758,47.6
61+
1759,54
62+
1760,62.9
63+
1761,85.9
64+
1762,61.2
65+
1763,45.1
66+
1764,36.4
67+
1765,20.9
68+
1766,11.4
69+
1767,37.8
70+
1768,69.8
71+
1769,106.1
72+
1770,100.8
73+
1771,81.6
74+
1772,66.5
75+
1773,34.8
76+
1774,30.6
77+
1775,7
78+
1776,19.8
79+
1777,92.5
80+
1778,154.4
81+
1779,125.9
82+
1780,84.8
83+
1781,68.1
84+
1782,38.5
85+
1783,22.8
86+
1784,10.2
87+
1785,24.1
88+
1786,82.9
89+
1787,132
90+
1788,130.9
91+
1789,118.1
92+
1790,89.9
93+
1791,66.6
94+
1792,60
95+
1793,46.9
96+
1794,41
97+
1795,21.3
98+
1796,16
99+
1797,6.4
100+
1798,4.1
101+
1799,6.8
102+
1800,14.5
103+
1801,34
104+
1802,45
105+
1803,43.1
106+
1804,47.5
107+
1805,42.2
108+
1806,28.1
109+
1807,10.1
110+
1808,8.1
111+
1809,2.5
112+
1810,0
113+
1811,1.4
114+
1812,5
115+
1813,12.2
116+
1814,13.9
117+
1815,35.4
118+
1816,45.8
119+
1817,41.1
120+
1818,30.1
121+
1819,23.9
122+
1820,15.6
123+
1821,6.6
124+
1822,4
125+
1823,1.8
126+
1824,8.5
127+
1825,16.6
128+
1826,36.3
129+
1827,49.6
130+
1828,64.2
131+
1829,67
132+
1830,70.9
133+
1831,47.8
134+
1832,27.5
135+
1833,8.5
136+
1834,13.2
137+
1835,56.9
138+
1836,121.5
139+
1837,138.3
140+
1838,103.2
141+
1839,85.7
142+
1840,64.6
143+
1841,36.7
144+
1842,24.2
145+
1843,10.7
146+
1844,15
147+
1845,40.1
148+
1846,61.5
149+
1847,98.5
150+
1848,124.7
151+
1849,96.3
152+
1850,66.6
153+
1851,64.5
154+
1852,54.1
155+
1853,39
156+
1854,20.6
157+
1855,6.7
158+
1856,4.3
159+
1857,22.7
160+
1858,54.8
161+
1859,93.8
162+
1860,95.8
163+
1861,77.2
164+
1862,59.1
165+
1863,44
166+
1864,47
167+
1865,30.5
168+
1866,16.3
169+
1867,7.3
170+
1868,37.6
171+
1869,74
172+
1870,139
173+
1871,111.2
174+
1872,101.6
175+
1873,66.2
176+
1874,44.7
177+
1875,17
178+
1876,11.3
179+
1877,12.4
180+
1878,3.4
181+
1879,6
182+
1880,32.3
183+
1881,54.3
184+
1882,59.7
185+
1883,63.7
186+
1884,63.5
187+
1885,52.2
188+
1886,25.4
189+
1887,13.1
190+
1888,6.8
191+
1889,6.3
192+
1890,7.1
193+
1891,35.6
194+
1892,73
195+
1893,85.1
196+
1894,78
197+
1895,64
198+
1896,41.8
199+
1897,26.2
200+
1898,26.7
201+
1899,12.1
202+
1900,9.5
203+
1901,2.7
204+
1902,5
205+
1903,24.4
206+
1904,42
207+
1905,63.5
208+
1906,53.8
209+
1907,62
210+
1908,48.5
211+
1909,43.9
212+
1910,18.6
213+
1911,5.7
214+
1912,3.6
215+
1913,1.4
216+
1914,9.6
217+
1915,47.4
218+
1916,57.1
219+
1917,103.9
220+
1918,80.6
221+
1919,63.6
222+
1920,37.6
223+
1921,26.1
224+
1922,14.2
225+
1923,5.8
226+
1924,16.7
227+
1925,44.3
228+
1926,63.9
229+
1927,69
230+
1928,77.8
231+
1929,64.9
232+
1930,35.7
233+
1931,21.2
234+
1932,11.1
235+
1933,5.7
236+
1934,8.7
237+
1935,36.1
238+
1936,79.7
239+
1937,114.4
240+
1938,109.6
241+
1939,88.8
242+
1940,67.8
243+
1941,47.5
244+
1942,30.6
245+
1943,16.3
246+
1944,9.6
247+
1945,33.2
248+
1946,92.6
249+
1947,151.6
250+
1948,136.3
251+
1949,134.7
252+
1950,83.9
253+
1951,69.4
254+
1952,31.5
255+
1953,13.9
256+
1954,4.4
257+
1955,38
258+
1956,141.7
259+
1957,190.2
260+
1958,184.8
261+
1959,159
262+
1960,112.3
263+
1961,53.9
264+
1962,37.5
265+
1963,27.9
266+
1964,10.2
267+
1965,15.1
268+
1966,47
269+
1967,93.8
270+
1968,105.9
271+
1969,105.5
272+
1970,104.5
273+
1971,66.6
274+
1972,68.9
275+
1973,38
276+
1974,34.5
277+
1975,15.5
278+
1976,12.6
279+
1977,27.5
280+
1978,92.5
281+
1979,155.4
282+
1980,154.7
283+
1981,140.5
284+
1982,115.9
285+
1983,66.6
286+
1984,45.9
287+
1985,17.9
288+
1986,13.4
289+
1987,29.2
290+
1988,100.2

docs/src/manual.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ The package provides a variaty of pre-defined models. If there is any model that
4646
UnobservedComponents
4747
ExponentialSmoothing
4848
SARIMA
49+
DAR
4950
BasicStructural
51+
BasicStructuralExplanatory
5052
LinearRegression
5153
LocalLevel
5254
LocalLevelCycle

src/StateSpaceModels.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ include("models/locallevelcycle.jl")
4141
include("models/locallevelexplanatory.jl")
4242
include("models/locallineartrend.jl")
4343
include("models/basicstructural.jl")
44+
include("models/basicstructural_explanatory.jl")
4445
include("models/basicstructural_multivariate.jl")
4546
include("models/sarima.jl")
4647
include("models/linear_regression.jl")
4748
include("models/unobserved_components.jl")
4849
include("models/exponential_smoothing.jl")
4950
include("models/naive_models.jl")
51+
include("models/dar.jl")
5052

5153
include("visualization/forecast.jl")
5254
include("visualization/components.jl")
@@ -56,6 +58,8 @@ include("visualization/diagnostics.jl")
5658
# Exported types and structs
5759
export BasicStructural
5860
export ExperimentalSeasonalNaive
61+
export BasicStructuralExplanatory
62+
export DAR
5963
export ExponentialSmoothing
6064
export LinearMultivariateTimeInvariant
6165
export LinearMultivariateTimeVariant

src/datasets.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,15 @@ Federal Reserve Bank of St Louis.
9797
# References
9898
* Hyndman, Rob J., Athanasopoulos, George. "Forecasting: Principles and Practice"
9999
"""
100-
const US_CHANGE = joinpath(dirname(@__DIR__()), "datasets", "uschange.csv")
100+
const US_CHANGE = joinpath(dirname(@__DIR__()), "datasets", "uschange.csv")
101+
102+
@doc raw"""
103+
SUNSPOTS_YEAR
104+
105+
Yearly numbers of sunspots from 1700 to 1988 (rounded to one digit).
106+
Federal Reserve Bank of St Louis.
107+
108+
# References
109+
* H. Tong (1996) Non-Linear Time Series. Clarendon Press, Oxford, p. 471.
110+
"""
111+
const SUNSPOTS_YEAR = joinpath(dirname(@__DIR__()), "datasets", "sunspot_year.csv")

src/kalman_filter_and_smoother.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,11 @@ function kalman_filter(model::StateSpaceModel; filter::KalmanFilter=default_filt
181181
assert_possible_to_filter(model)
182182
filter_output = FilterOutput(model)
183183
reset_filter!(filter)
184-
free_unconstrained_values = get_free_unconstrained_values(model)
185-
update_model_hyperparameters!(model, free_unconstrained_values)
186-
update_filter_hyperparameters!(filter, model)
184+
if has_hyperparameter(model)
185+
free_unconstrained_values = get_free_unconstrained_values(model)
186+
update_model_hyperparameters!(model, free_unconstrained_values)
187+
update_filter_hyperparameters!(filter, model)
188+
end
187189
return kalman_filter!(filter_output, model.system, filter)
188190
end
189191

0 commit comments

Comments
 (0)