Skip to content

Commit 6dcd899

Browse files
author
andre_ramos
committed
change type to int
1 parent 2351c61 commit 6dcd899

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

src/models/default_model.jl

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,61 @@
11
"""
2-
ξ_size(T::Int64)::Int64
2+
ξ_size(T::Int)::Int
33
44
Calculates the size of ξ innovation matrix based on the input T.
55
66
# Arguments
7-
- `T::Int64`: Length of the original time series.
7+
- `T::Int`: Length of the original time series.
88
99
# Returns
10-
- `Int64`: Size of ξ calculated from T.
10+
- `Int`: Size of ξ calculated from T.
1111
1212
"""
13-
ξ_size(T::Int64)::Int64 = T - 2
13+
ξ_size(T::Int)::Int = T - 2
1414

1515
"""
16-
ζ_size(T::Int64, ζ_ω_threshold::Int64)::Int64
16+
ζ_size(T::Int, ζ_ω_threshold::Int)::Int
1717
1818
Calculates the size of ζ innovation matrix based on the input T.
1919
2020
# Arguments
21-
- `T::Int64`: Length of the original time series.
22-
- `ζ_ω_threshold::Int64`: Stabilize parameter ζ.
21+
- `T::Int`: Length of the original time series.
22+
- `ζ_ω_threshold::Int`: Stabilize parameter ζ.
2323
2424
# Returns
25-
- `Int64`: Size of ζ calculated from T.
25+
- `Int`: Size of ζ calculated from T.
2626
2727
"""
28-
ζ_size(T::Int64, ζ_ω_threshold::Int64)::Int64 = T-ζ_ω_threshold-2
28+
ζ_size(T::Int, ζ_ω_threshold::Int)::Int = T-ζ_ω_threshold-2
2929

3030
"""
31-
ω_size(T::Int64, s::Int64)::Int64
31+
ω_size(T::Int, s::Int)::Int
3232
3333
Calculates the size of ω innovation matrix based on the input T.
3434
3535
# Arguments
36-
- `T::Int64`: Length of the original time series.
37-
- `s::Int64`: Seasonal period.
36+
- `T::Int`: Length of the original time series.
37+
- `s::Int`: Seasonal period.
3838
3939
# Returns
40-
- `Int64`: Size of ω calculated from T.
40+
- `Int`: Size of ω calculated from T.
4141
4242
"""
43-
ω_size(T::Int64, s::Int64, ζ_ω_threshold::Int64)::Int64 = T - ζ_ω_threshold - s + 1
43+
ω_size(T::Int, s::Int, ζ_ω_threshold::Int)::Int = T - ζ_ω_threshold - s + 1
4444

4545
"""
46-
create_ξ(T::Int64, steps_ahead::Int64)::Matrix
46+
create_ξ(T::Int, steps_ahead::Int)::Matrix
4747
4848
Creates a matrix of innovations ξ based on the input sizes, and the desired steps ahead (this is necessary for the forecast function)
4949
5050
# Arguments
51-
- `T::Int64`: Length of the original time series.
52-
- `steps_ahead::Int64`: Number of steps ahead (for estimation purposes this should be set at 0).
51+
- `T::Int`: Length of the original time series.
52+
- `steps_ahead::Int`: Number of steps ahead (for estimation purposes this should be set at 0).
5353
5454
# Returns
5555
- `Matrix`: Matrix of innovations ξ constructed based on the input sizes.
5656
5757
"""
58-
function create_ξ(T::Int64, steps_ahead::Int64)::Matrix
58+
function create_ξ(T::Int, steps_ahead::Int)::Matrix
5959
ξ_matrix = Matrix{Float64}(undef, T+steps_ahead, T - 1)
6060
for t in 1:T+steps_ahead
6161
ξ_matrix[t, :] = t < T ? vcat(ones(t-1), zeros(T-t)) : ones(T-1)
@@ -65,20 +65,20 @@ function create_ξ(T::Int64, steps_ahead::Int64)::Matrix
6565
end
6666

6767
"""
68-
create_ζ(T::Int64, steps_ahead::Int64, ζ_ω_threshold::Int64)::Matrix
68+
create_ζ(T::Int, steps_ahead::Int, ζ_ω_threshold::Int)::Matrix
6969
7070
Creates a matrix of innovations ζ based on the input sizes, and the desired steps ahead (this is necessary for the forecast function).
7171
7272
# Arguments
73-
- `T::Int64`: Length of the original time series.
74-
- `steps_ahead::Int64`: Number of steps ahead (for estimation purposes this should be set at 0).
75-
- `ζ_ω_threshold::Int64`: Stabilize parameter ζ.
73+
- `T::Int`: Length of the original time series.
74+
- `steps_ahead::Int`: Number of steps ahead (for estimation purposes this should be set at 0).
75+
- `ζ_ω_threshold::Int`: Stabilize parameter ζ.
7676
7777
# Returns
7878
- `Matrix`: Matrix of innovations ζ constructed based on the input sizes.
7979
8080
"""
81-
function create_ζ(T::Int64, steps_ahead::Int64, ζ_ω_threshold::Int64)::Matrix
81+
function create_ζ(T::Int, steps_ahead::Int, ζ_ω_threshold::Int)::Matrix
8282
ζ_matrix = Matrix{Float64}(undef, T+steps_ahead, T - 2)
8383
for t in 1:T+steps_ahead
8484
ζ_matrix[t, :] = t < T ? vcat(collect(t-2:-1:1), zeros(T-2-length(collect(t-2:-1:1)))) : collect(t-2:-1:t-T+1)
@@ -87,25 +87,25 @@ function create_ζ(T::Int64, steps_ahead::Int64, ζ_ω_threshold::Int64)::Matrix
8787
end
8888

8989
"""
90-
create_ω(T::Int64, s::Int64, steps_ahead::Int64)::Matrix
90+
create_ω(T::Int, s::Int, steps_ahead::Int)::Matrix
9191
9292
Creates a matrix of innovations ω based on the input sizes, and the desired steps ahead (this is necessary for the forecast function).
9393
9494
# Arguments
95-
- `T::Int64`: Length of the original time series.
96-
- `freq_seasonal::Int64`: Seasonal period.
97-
- `steps_ahead::Int64`: Number of steps ahead (for estimation purposes this should be set at 0).
95+
- `T::Int`: Length of the original time series.
96+
- `freq_seasonal::Int`: Seasonal period.
97+
- `steps_ahead::Int`: Number of steps ahead (for estimation purposes this should be set at 0).
9898
9999
# Returns
100100
- `Matrix`: Matrix of innovations ω constructed based on the input sizes.
101101
102102
"""
103-
function create_ω(T::Int64, freq_seasonal::Int64, steps_ahead::Int64, ζ_ω_threshold::Int64)::Matrix
103+
function create_ω(T::Int, freq_seasonal::Int, steps_ahead::Int, ζ_ω_threshold::Int)::Matrix
104104
ω_matrix_size = ω_size(T, freq_seasonal, ζ_ω_threshold) + ζ_ω_threshold
105105
ω_matrix = zeros(T+steps_ahead, ω_matrix_size)
106106
for t in freq_seasonal+1:T+steps_ahead
107107
ωₜ_coefs = zeros(ω_matrix_size)
108-
Mₜ = Int64(floor((t-1)/freq_seasonal))
108+
Mₜ = Int(floor((t-1)/freq_seasonal))
109109
lag₁ = [t - j*freq_seasonal for j in 0:Mₜ-1]
110110
lag₂ = [t - j*freq_seasonal - 1 for j in 0:Mₜ-1]
111111
ωₜ_coefs[lag₁[lag₁.<=ω_matrix_size+(freq_seasonal - 1)] .- (freq_seasonal - 1)] .= 1
@@ -116,14 +116,14 @@ function create_ω(T::Int64, freq_seasonal::Int64, steps_ahead::Int64, ζ_ω_thr
116116
end
117117

118118
"""
119-
create_initial_states_Matrix(T::Int64, s::Int64, steps_ahead::Int64, level::Bool, trend::Bool, seasonal::Bool)::Matrix
119+
create_initial_states_Matrix(T::Int, s::Int, steps_ahead::Int, level::Bool, trend::Bool, seasonal::Bool)::Matrix
120120
121121
Creates an initial states matrix based on the input parameters.
122122
123123
# Arguments
124-
- `T::Int64`: Length of the original time series.
125-
- `freq_seasonal::Int64`: Seasonal period.
126-
- `steps_ahead::Int64`: Number of steps ahead.
124+
- `T::Int`: Length of the original time series.
125+
- `freq_seasonal::Int`: Seasonal period.
126+
- `steps_ahead::Int`: Number of steps ahead.
127127
- `level::Bool`: Flag for considering level component.
128128
- `trend::Bool`: Flag for considering trend component.
129129
- `seasonal::Bool`: Flag for considering seasonal component.
@@ -132,7 +132,7 @@ end
132132
- `Matrix`: Initial states matrix constructed based on the input parameters.
133133
134134
"""
135-
function create_initial_states_Matrix(T::Int64, freq_seasonal::Int64, steps_ahead::Int64, level::Bool, trend::Bool, seasonal::Bool)::Matrix
135+
function create_initial_states_Matrix(T::Int, freq_seasonal::Int, steps_ahead::Int, level::Bool, trend::Bool, seasonal::Bool)::Matrix
136136

137137
initial_states_matrix = zeros(T+steps_ahead, 0)
138138
level ? initial_states_matrix = hcat(initial_states_matrix, ones(T+steps_ahead, 1)) : nothing
@@ -151,21 +151,21 @@ function create_initial_states_Matrix(T::Int64, freq_seasonal::Int64, steps_ahea
151151
end
152152

153153
"""
154-
create_X(model_input::Dict, Exogenous_X::Matrix{Fl}, steps_ahead::Int64=0, Exogenous_Forecast::Matrix{Fl}=zeros(steps_ahead, size(Exogenous_X, 2))) where Fl
154+
create_X(model_input::Dict, Exogenous_X::Matrix{Fl}, steps_ahead::Int=0, Exogenous_Forecast::Matrix{Fl}=zeros(steps_ahead, size(Exogenous_X, 2))) where Fl
155155
156156
Creates the StateSpaceLearning matrix X based on the model type and input parameters.
157157
158158
# Arguments
159159
- `model_type::String`: Type of model.
160160
- `Exogenous_X::Matrix{Fl}`: Exogenous variables matrix.
161-
- `steps_ahead::Int64`: Number of steps ahead (default: 0).
161+
- `steps_ahead::Int`: Number of steps ahead (default: 0).
162162
- `Exogenous_Forecast::Matrix{Fl}`: Exogenous variables forecast matrix (default: zeros).
163163
164164
# Returns
165165
- `Matrix`: StateSpaceLearning matrix X constructed based on the input parameters.
166166
"""
167167
function create_X(model_input::Dict, Exogenous_X::Matrix{Fl},
168-
steps_ahead::Int64=0, Exogenous_Forecast::Matrix{Fl}=zeros(steps_ahead, size(Exogenous_X, 2))) where Fl
168+
steps_ahead::Int=0, Exogenous_Forecast::Matrix{Fl}=zeros(steps_ahead, size(Exogenous_X, 2))) where Fl
169169

170170
outlier = model_input["outlier"]; ζ_ω_threshold = model_input["ζ_ω_threshold"]; T = size(Exogenous_X, 1)
171171

@@ -203,52 +203,52 @@ function get_components_indexes(Exogenous_X::Matrix{Fl}, model_input::Dict)::Dic
203203
initial_states_indexes = [1]
204204
FINAL_INDEX += length(μ1_indexes)
205205
else
206-
μ1_indexes = Int64[]
207-
initial_states_indexes = Int64[]
206+
μ1_indexes = Int[]
207+
initial_states_indexes = Int[]
208208
end
209209

210210
if model_input["trend"]
211211
ν1_indexes = [2]
212212
initial_states_indexes = vcat(initial_states_indexes, ν1_indexes)
213213
FINAL_INDEX += length(ν1_indexes)
214214
else
215-
ν1_indexes = Int64[]
215+
ν1_indexes = Int[]
216216
end
217217

218218
if model_input["seasonal"]
219219
γ1_indexes = collect(FINAL_INDEX+1:FINAL_INDEX+model_input["freq_seasonal"])
220220
initial_states_indexes = vcat(initial_states_indexes, γ1_indexes)
221221
FINAL_INDEX += length(γ1_indexes)
222222
else
223-
γ1_indexes = Int64[]
223+
γ1_indexes = Int[]
224224
end
225225

226226
if model_input["stochastic_level"]
227227
ξ_indexes = collect(FINAL_INDEX+1:FINAL_INDEX+ξ_size(T))
228228
FINAL_INDEX += length(ξ_indexes)
229229
else
230-
ξ_indexes = Int64[]
230+
ξ_indexes = Int[]
231231
end
232232

233233
if model_input["stochastic_trend"]
234234
ζ_indexes = collect(FINAL_INDEX+1:FINAL_INDEX+ζ_size(T, ζ_ω_threshold))
235235
FINAL_INDEX += length(ζ_indexes)
236236
else
237-
ζ_indexes = Int64[]
237+
ζ_indexes = Int[]
238238
end
239239

240240
if model_input["stochastic_seasonal"]
241241
ω_indexes = collect(FINAL_INDEX+1:FINAL_INDEX+ω_size(T, model_input["freq_seasonal"], ζ_ω_threshold))
242242
FINAL_INDEX += length(ω_indexes)
243243
else
244-
ω_indexes = Int64[]
244+
ω_indexes = Int[]
245245
end
246246

247247
if outlier
248248
o_indexes = collect(FINAL_INDEX+1:FINAL_INDEX+o_size(T))
249249
FINAL_INDEX += length(o_indexes)
250250
else
251-
o_indexes = Int64[]
251+
o_indexes = Int[]
252252
end
253253

254254
exogenous_indexes = collect(FINAL_INDEX + 1:FINAL_INDEX + size(Exogenous_X, 2))
@@ -259,20 +259,20 @@ function get_components_indexes(Exogenous_X::Matrix{Fl}, model_input::Dict)::Dic
259259
end
260260

261261
"""
262-
get_variances(ε::Vector{Fl}, coefs::Vector{Fl}, components_indexes::Dict{String, Vector{Int64}})::Dict where Fl
262+
get_variances(ε::Vector{Fl}, coefs::Vector{Fl}, components_indexes::Dict{String, Vector{Int}})::Dict where Fl
263263
264264
Calculates variances for each innovation component and for the residuals.
265265
266266
# Arguments
267267
- `ε::Vector{Fl}`: Vector of residuals.
268268
- `coefs::Vector{Fl}`: Vector of coefficients.
269-
- `components_indexes::Dict{String, Vector{Int64}}`: Dictionary containing indexes for different components.
269+
- `components_indexes::Dict{String, Vector{Int}}`: Dictionary containing indexes for different components.
270270
271271
# Returns
272272
- `Dict`: Dictionary containing variances for each innovation component.
273273
274274
"""
275-
function get_variances::Vector{Fl}, coefs::Vector{Fl}, components_indexes::Dict{String, Vector{Int64}})::Dict where Fl
275+
function get_variances::Vector{Fl}, coefs::Vector{Fl}, components_indexes::Dict{String, Vector{Int}})::Dict where Fl
276276

277277
variances = Dict()
278278
for component in ["ξ", "ζ", "ω"]

0 commit comments

Comments
 (0)