@@ -194,40 +194,7 @@ function selectSeasonalIntegrationOrder(
194
194
elseif test == " ch"
195
195
return StateSpaceModels. canova_hansen_test (y, seasonality)
196
196
elseif test == " ocsb"
197
- try
198
- if ! (" PyCall" ∈ keys (Pkg. project (). dependencies))
199
- # Warning message
200
- @warn " The PyCall package is not installed. Please install it to use the 'ocsb' test."
201
- @warn " Using the 'seas' test instead."
202
- return StateSpaceModels. seasonal_strength_test (y, seasonality)
203
- end
204
-
205
- return Sarimax. seasonal_diffs (y, seasonality)
206
- catch e
207
- println (e)
208
- throw (
209
- Error (
210
- " It seems that the pmdarima package is not installed. Please install it to use the 'ocsb' test." ,
211
- ),
212
- )
213
- end
214
- elseif test == " ocsbR"
215
- try
216
- if ! (" RCall" ∈ keys (Pkg. project (). dependencies))
217
- # Warning message
218
- @warn " The RCall package is not installed. Please install it to use the 'ocsbR' test."
219
- @warn " Using the 'seas' test instead."
220
- return StateSpaceModels. seasonal_strength_test (y, seasonality)
221
- end
222
- return Sarimax. seasonal_diffsR (y, seasonality)
223
- catch e
224
- println (e)
225
- throw (
226
- Error (
227
- " It seems that the R forecast package is not installed. Please install it to use the 'ocsbR' test." ,
228
- ),
229
- )
230
- end
197
+ return ocsb_test (y;m= seasonality)[" seasonal_difference" ]
231
198
end
232
199
throw (ArgumentError (" The test $test is not supported" ))
233
200
end
@@ -260,23 +227,13 @@ function selectIntegrationOrder(
260
227
) where {Fl<: AbstractFloat }
261
228
if test == " kpss"
262
229
return StateSpaceModels. repeated_kpss_test (y, maxd, D, seasonality)
263
- elseif test == " kpssR"
264
- try
265
- if ! (" RCall" ∈ keys (Pkg. project (). dependencies))
266
- # Warning message
267
- @warn " The RCall package is not installed. Please install it to use the 'kpssR' test."
268
- @warn " Using the 'kpss' test instead."
269
- return StateSpaceModels. repeated_kpss_test (y, maxd, D, seasonality)
230
+ elseif test == " kpssSarimax"
231
+ for d in 0 : maxd
232
+ diffSeries = differentiate (y, d, D, seasonality)
233
+ result = kpss_test (diffSeries)
234
+ if result[" p_value" ] <= 0.05
235
+ return d
270
236
end
271
-
272
- return Sarimax. kpssR (y, maxd, D, seasonality)
273
- catch e
274
- println (e)
275
- throw (
276
- ArgumentError (
277
- " It seems that the R forecast package is not installed. Please install it to use the 'kpssR' test." ,
278
- ),
279
- )
280
237
end
281
238
end
282
239
@@ -291,7 +248,7 @@ Automatically applies differentiation to each series in a TimeArray.
291
248
# Arguments
292
249
- `series::TimeArray`: The input TimeArray containing the time series data.
293
250
- `seasonalPeriod::Int=1`: The seasonal period of the time series.
294
- - `seasonalIntegrationTest::String="seas "`: The test used to select the seasonal integration order.
251
+ - `seasonalIntegrationTest::String="ocsb "`: The test used to select the seasonal integration order.
295
252
- `integrationTest::String="kpss"`: The test used to select the integration order.
296
253
- `maxd::Int=2`: The maximum order of differencing to consider.
297
254
@@ -307,12 +264,12 @@ Throws an AssertionError if invalid test options or seasonal period are provided
307
264
function automaticDifferentiation (
308
265
series:: TimeArray ;
309
266
seasonalPeriod:: Int = 1 ,
310
- seasonalIntegrationTest:: String = " seas " ,
267
+ seasonalIntegrationTest:: String = " ocsb " ,
311
268
integrationTest:: String = " kpss" ,
312
269
maxd:: Int = 2 ,
313
270
)
314
271
@assert integrationTest ∈ [" kpss" ]
315
- @assert seasonalIntegrationTest ∈ [" seas" , " ch" ]
272
+ @assert seasonalIntegrationTest ∈ [" seas" , " ch" , " ocsb " ]
316
273
@assert seasonalPeriod ≥ 1
317
274
318
275
diffSeriesVector:: Array{TimeArray} = []
0 commit comments