Skip to content

Commit 0015053

Browse files
author
LuizFCDuarte
committed
📦 Update dependencies
1 parent ac076ab commit 0015053

File tree

6 files changed

+119
-55
lines changed

6 files changed

+119
-55
lines changed

Project.toml

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,59 @@ uuid = "32cb7113-d955-45ac-bb89-2e20d5d4d2f9"
33
authors = ["LuizFDuarte <[email protected]>"]
44
version = "0.1.0"
55

6-
[compat]
7-
julia = "1.6 - 1.11"
8-
96
[deps]
107
Alpine = "07493b3f-dabb-5b16-a503-4139292d7dd4"
118
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
129
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
13-
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
1410
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
1511
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
1612
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
17-
GLMNet = "8d5ece8b-de18-5317-b113-243142960cc6"
1813
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
1914
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
2015
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
2116
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
2217
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
2318
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
2419
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
25-
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
26-
RCall = "6f49c342-dc21-5d91-9882-a32aef131414"
20+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
2721
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
28-
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
29-
SCIP = "82193955-e24f-5292-bf16-6f2c5261a85f"
22+
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
3023
StateSpaceModels = "99342f36-827c-5390-97c9-d7f9ee765c78"
3124
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
3225
TimeSeries = "9e3dc215-6440-5c97-bce1-76c03772f85e"
3326

27+
[weakdeps]
28+
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
29+
RCall = "6f49c342-dc21-5d91-9882-a32aef131414"
30+
31+
[compat]
32+
Alpine = "0.5.6"
33+
CSV = "0.10.14"
34+
Combinatorics = "1.0.2"
35+
DataFrames = "1.6.1"
36+
Dates = "1.11.0"
37+
Distributions = "0.25.108"
38+
HiGHS = "1.9.0"
39+
Ipopt = "1.6.2"
40+
JuMP = "1.21.1"
41+
LinearAlgebra = "1.11.0"
42+
MathOptInterface = "1.29.0"
43+
OffsetArrays = "1.14.0"
44+
Optim = "1.9.4"
45+
Pkg = "1.11.0"
46+
PyCall = "1.96.4"
47+
RCall = "0.14.1"
48+
Random = "1.11.0"
49+
Requires = "1.3.0"
50+
StateSpaceModels = "0.6.7"
51+
Statistics = "1.11.1"
52+
TimeSeries = "0.24.2"
53+
julia = "1.0 - 1.11"
54+
3455
[extras]
3556
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
57+
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
3658
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3759

3860
[targets]
39-
test = ["Test", "JSON"]
61+
test = ["Test", "JSON", "Revise"]

src/Sarimax.jl

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,42 +8,26 @@ using CSV
88
using DataFrames
99
using Dates
1010
using Distributions
11-
using HiGHS
1211
using Ipopt
1312
using JuMP
1413
using LinearAlgebra
1514
using MathOptInterface
1615
using OffsetArrays
1716
using Optim
17+
using Pkg
1818
using Random
19-
using SCIP
19+
using Requires
2020
using StateSpaceModels
2121
using Statistics
2222
using TimeSeries
23-
using PyCall
24-
using Conda
25-
using RCall
26-
# using GLMNet
27-
# using Lasso
2823

2924
abstract type SarimaxModel end
3025

31-
try
32-
pyimport("pmdarima")
33-
pyimport("numpy")
34-
catch e
35-
@warn "Could not load python libraries. Please make sure you have numpy and pmdarima installed."
26+
function __init__()
27+
@require PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" include("python_init.jl")
28+
@require RCall = "6f49c342-dc21-5d91-9882-a32aef131414" include("r_init.jl")
3629
end
3730

38-
try
39-
R"""
40-
library(forecast)
41-
"""
42-
catch e
43-
@warn "Could not load R libraries. Please make sure you have forecast installed."
44-
end
45-
46-
4731
include("datasets.jl")
4832
include("datetime_utils.jl")
4933
include("exceptions.jl")

src/python_init.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using PyCall
2+
3+
export seasonal_diffs
4+
5+
try
6+
pyimport("pmdarima")
7+
pyimport("numpy")
8+
catch e
9+
@warn "Could not load python libraries. Please make sure you have numpy and pmdarima installed."
10+
end
11+
12+
function seasonal_diffs(y, seasonality)
13+
py"""
14+
def seasonal_diffs(ts, seasonal_period):
15+
ts_np = numpy.array(ts)
16+
return pmdarima.arima.nsdiffs(ts_np, m=seasonal_period)
17+
"""
18+
return py"seasonal_diffs"(y, seasonality)
19+
end

src/r_init.jl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using RCall
2+
3+
export seasonal_diffsR, kpssR
4+
5+
try
6+
R"""
7+
library(forecast)
8+
"""
9+
catch e
10+
@warn "Could not load R libraries. Please make sure you have forecast installed."
11+
end
12+
13+
function seasonal_diffsR(y, seasonality)
14+
@rput y seasonality
15+
R"""
16+
# Example time series data (replace with your actual data)
17+
ts_data <- ts(y, frequency = seasonality)
18+
D <- nsdiffs(ts_data)
19+
"""
20+
D::Int = @rget D
21+
return D
22+
end
23+
24+
function kpssR(y, maxd, D, seasonality)
25+
@rput y maxd D seasonality
26+
R"""
27+
diffy <- y
28+
if (D > 0 & seasonality > 1) {
29+
diffy <- diff(y, differences = D, lag = seasonality)
30+
}
31+
d <- ndiffs(diffy, test="kpss", max.d = maxd)
32+
"""
33+
d::Int = @rget d
34+
return d
35+
end

src/utils.jl

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -158,26 +158,27 @@ function selectSeasonalIntegrationOrder(
158158
return StateSpaceModels.canova_hansen_test(y, seasonality)
159159
elseif test == "ocsb"
160160
try
161-
py"""
162-
def seasonal_diffs(ts, seasonal_period):
163-
ts_np = numpy.array(ts)
164-
return pmdarima.arima.nsdiffs(ts_np, m=seasonal_period)
165-
"""
166-
return py"seasonal_diffs"(y, seasonality)
161+
if !("PyCall" keys(Pkg.project().dependencies))
162+
# Warning message
163+
@warn "The PyCall package is not installed. Please install it to use the 'ocsb' test."
164+
@warn "Using the 'seas' test instead."
165+
return StateSpaceModels.seasonal_strength_test(y, seasonality)
166+
end
167+
168+
return seasonal_diffs(y, seasonality)
167169
catch e
168170
println(e)
169171
throw(Error("It seems that the pmdarima package is not installed. Please install it to use the 'ocsb' test."))
170172
end
171173
elseif test == "ocsbR"
172174
try
173-
@rput y seasonality
174-
R"""
175-
# Example time series data (replace with your actual data)
176-
ts_data <- ts(y, frequency = seasonality)
177-
D <- nsdiffs(ts_data)
178-
"""
179-
D::Int = @rget D
180-
return D
175+
if !("RCall" keys(Pkg.project().dependencies))
176+
# Warning message
177+
@warn "The RCall package is not installed. Please install it to use the 'ocsbR' test."
178+
@warn "Using the 'seas' test instead."
179+
return StateSpaceModels.seasonal_strength_test(y, seasonality)
180+
end
181+
return seasonal_diffsR(y, seasonality)
181182
catch e
182183
println(e)
183184
throw(Error("It seems that the R forecast package is not installed. Please install it to use the 'ocsbR' test."))
@@ -216,16 +217,14 @@ function selectIntegrationOrder(
216217
return StateSpaceModels.repeated_kpss_test(y, maxd, D, seasonality)
217218
elseif test == "kpssR"
218219
try
219-
@rput y maxd D seasonality
220-
R"""
221-
diffy <- y
222-
if (D > 0 & seasonality > 1) {
223-
diffy <- diff(y, differences = D, lag = seasonality)
224-
}
225-
d <- ndiffs(diffy, test="kpss", max.d = maxd)
226-
"""
227-
d::Int = @rget d
228-
return d
220+
if !("RCall" keys(Pkg.project().dependencies))
221+
# Warning message
222+
@warn "The RCall package is not installed. Please install it to use the 'kpssR' test."
223+
@warn "Using the 'kpss' test instead."
224+
return StateSpaceModels.repeated_kpss_test(y, maxd, D, seasonality)
225+
end
226+
227+
return kpssR(y, maxd, D, seasonality)
229228
catch e
230229
println(e)
231230
throw(Error("It seems that the R forecast package is not installed. Please install it to use the 'kpssR' test."))

test/utils.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@
7777
@test_throws ArgumentError Sarimax.selectIntegrationOrder(values(airPassengers), 2, 0, 12,"hegy")
7878
end
7979

80+
@testset "selectIntegrationOrderR" begin
81+
airPassengers = loadDataset(AIR_PASSENGERS)
82+
@test Sarimax.selectIntegrationOrder(values(airPassengers), 2, 0, 12,"kpssR") == 1
83+
end
84+
8085
@testset "automaticDifferentiation" begin
8186
gdpc1Data = loadDataset(GDPC1)
8287
nrouData = loadDataset(NROU)

0 commit comments

Comments
 (0)