Skip to content

Commit f8d7c90

Browse files
Add TDist (#88)
* add TDist * change location scale name order
1 parent ac0934f commit f8d7c90

18 files changed

+99
-33
lines changed

docs/src/manual.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@ ScoreDrivenModels.Chi
9494
ScoreDrivenModels.Chisq
9595
ScoreDrivenModels.Exponential
9696
ScoreDrivenModels.Gamma
97-
ScoreDrivenModels.LocationScaleTDist
9897
ScoreDrivenModels.LogitNormal
9998
ScoreDrivenModels.LogNormal
10099
ScoreDrivenModels.Normal
101100
ScoreDrivenModels.Poisson
101+
ScoreDrivenModels.TDist
102+
ScoreDrivenModels.TDistLocationScale
102103
ScoreDrivenModels.Weibull
103104
```
104105

examples/cpichg.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using ScoreDrivenModels, DelimitedFiles
33
y = readdlm("./test/data/cpichg.csv")[:]
44

55
# Define a model where only \mu and \sigma^2 is varying over time
6-
gas = Model(1, 1, LocationScaleTDist, 0.0, time_varying_params = [1; 2])
6+
gas = Model(1, 1, TDistLocationScale, 0.0, time_varying_params = [1; 2])
77

88
# Estimate the model
99
@time f = fit!(gas, y)

src/ScoreDrivenModels.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ include("distributions/logitnormal.jl")
4040
include("distributions/lognormal.jl")
4141
include("distributions/normal.jl")
4242
include("distributions/poisson.jl")
43-
include("distributions/locationscalestd.jl")
43+
include("distributions/tdist.jl")
44+
include("distributions/tdistlocationscale.jl")
4445
include("distributions/weibull.jl")
4546

4647
end

src/distributions/beta.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
1212
* Default link
1313
"""
14-
function Beta end
14+
Beta
1515

1616
function score!(score_til::Matrix{T}, y::T, ::Type{Beta}, param::Matrix{T}, t::Int) where T
1717
score_til[t, 1] = log(y) + digamma(param[t, 1] + param[t, 2]) - digamma(param[t, 1])

src/distributions/chi.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ parametrized in k
1212
1313
* Default link
1414
"""
15-
function Chi end
15+
Chi
1616

1717
function score!(score_til::Matrix{T}, y::T, ::Type{Chi}, param::Matrix{T}, t::Int) where T
1818
score_til[t, 1] = log(y) - log(2)/2 - digamma(param[t, 1]/2)/2

src/distributions/chisq.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ parametrized in k
1212
1313
* Default link
1414
"""
15-
function Chisq end
15+
Chisq
1616

1717
function score!(score_til::Matrix{T}, y::T, ::Type{Chisq}, param::Matrix{T}, t::Int) where T
1818
score_til[t, 1] = (log(y) - log(2) - digamma(param[t, 1]/2))/2

src/distributions/common_interface.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const DISTS = [
99
LogNormal,
1010
Normal,
1111
Poisson,
12-
LocationScaleTDist,
12+
TDist,
13+
TDistLocationScale,
1314
Weibull
1415
]
1516

@@ -22,7 +23,8 @@ export Beta,
2223
LogNormal,
2324
Normal,
2425
Poisson,
25-
LocationScaleTDist,
26+
TDist,
27+
TDistLocationScale,
2628
Weibull
2729

2830
# Query params for generic distribution

src/distributions/exponential.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ parametrized in \\lambda
1212
1313
* Default link
1414
"""
15-
function Exponential end
15+
Exponential
1616

1717
function score!(score_til::Matrix{T}, y::T, ::Type{Exponential}, param::Matrix{T}, t::Int) where T
1818
score_til[t, 1] = 1/param[t, 1] - y

src/distributions/gamma.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ parametrized in \\alpha and \\theta
1212
1313
* Default link
1414
"""
15-
function Gamma end
15+
Gamma
1616

1717
function score!(score_til::Matrix{T}, y::T, ::Type{Gamma}, param::Matrix{T}, t::Int) where T
1818
score_til[t, 1] = log(y) - digamma(param[t, 1]) - log(param[t, 2])

src/distributions/logitnormal.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ parametrized in \\mu and \\sigma^2
1212
1313
* Default link
1414
"""
15-
function LogitNormal end
15+
LogitNormal
1616

1717
logit(x) = log(x) - log(1-x)
1818

0 commit comments

Comments
 (0)