Skip to content

Commit a047701

Browse files
Update diagnostics and bump version (#135)
1 parent ca1652b commit a047701

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ScoreDrivenModels"
22
uuid = "4a87933e-d659-11e9-0e65-7f40dedd4a3a"
33
authors = ["guilhermebodin <[email protected]>, raphaelsaavedra <[email protected]>"]
4-
version = "0.1.7"
4+
version = "0.1.8"
55

66
[deps]
77
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"

src/diagnostics.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@ function quantile_residuals(obs::Vector{T}, gas::Model{D, T};
1010

1111
for t in axes(params_fitted[len_ini_par + 1:end - 1, :], 1)
1212
dist = update_dist(D, params_fitted[len_ini_par + 1:end - 1, :], t)
13-
prob = cdf(dist, obs[t + len_ini_par])
14-
quant_res[t] = quantile(Normal(0, 1), prob)
13+
# Continuous distributions PIT
14+
if supertype(D).parameters[2] == Continuous
15+
prob = cdf(dist, obs[t + len_ini_par])
16+
quant_res[t] = quantile(Normal(0, 1), prob)
17+
else # Discrete distributions PIT
18+
lb = cdf(dist, obs[t + len_ini_par] - 1)
19+
ub = cdf(dist, obs[t + len_ini_par])
20+
prob = rand(Uniform(lb, ub))
21+
quant_res[t] = quantile(Normal(0, 1), prob)
22+
end
1523

1624
# Treat possible infinity values
1725
if quant_res[t] == Inf

0 commit comments

Comments
 (0)