Skip to content

Commit 5731396

Browse files
devmotionJose Storopoli
andauthored
Remove Model and rewrite turing_model (#45)
* Remove `Model` and rewrite `turing_model` * Apply suggestions from code review Co-authored-by: Jose Storopoli <[email protected]> Co-authored-by: Jose Storopoli <[email protected]>
1 parent ae06605 commit 5731396

13 files changed

+273
-452
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TuringGLM"
22
uuid = "0004c1f4-53c5-4d43-a221-a1dac6cf6b74"
33
authors = ["Jose Storopoli <[email protected]>, Rik Huijzer <[email protected]>, and contributors"]
4-
version = "1.0.0"
4+
version = "2.0.0"
55

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

docs/src/index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ The most popular ones are `DataFrame`s and `NamedTuple`s.
4848
TuringGLM supports non-hiearchical and hierarchical models.
4949
For hierarchical models, only single random-intercept hierarchical models are supported.
5050

51-
For likelihoods, `TuringGLM.jl` supports:
51+
Currently, for likelihoods `TuringGLM.jl` supports:
5252

53-
* `Gaussian()` (the default if not specified): linear regression
54-
* `Student()`: robust linear regression
55-
* `Logistic()`: logistic regression
56-
* `Pois()`: Poisson count data regression
57-
* `NegBin()`: negative binomial robust count data regression
53+
* `Normal` (the default if not specified): linear regression
54+
* `TDist`: robust linear regression
55+
* `Bernoulli`: logistic regression
56+
* `Poisson`: Poisson count data regression
57+
* `NegativeBinomial`: negative binomial robust count data regression
5858

5959
## Tutorials
6060

docs/src/tutorials/custom_priors.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ priors = CustomPrior(Normal(0, 2.5), Normal(10, 20), nothing);
6464

6565
# ╔═╡ 56498ac7-3476-42eb-9c12-078562fff51d
6666
md"""
67-
We instantiate our model with `turing_model` without specifying any model, thus the default model will be used: `Gaussian()`.
67+
We instantiate our model with `turing_model` without specifying any model, thus the default model will be used (`model=Normal`).
6868
Notice that we are specifying the `priors` keyword argument:
6969
"""
7070

docs/src/tutorials/hierarchical_models.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fm = @formula(y ~ (1 | cheese) + background)
5959

6060
# ╔═╡ 934b7ec9-d4b3-435c-876f-49215dca8809
6161
md"""
62-
We instantiate our model with `turing_model` without specifying any model, thus the default model will be used: `Gaussian()`
62+
We instantiate our model with `turing_model` without specifying any model, thus the default model will be used (`model=Normal`):
6363
"""
6464

6565
# ╔═╡ 5fc736a2-068e-4deb-9a77-bd21d93f6f32

docs/src/tutorials/linear_regression.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fm = @formula(kid_score ~ mom_hs * mom_iq)
5757

5858
# ╔═╡ 43d63761-adf5-4a52-b996-4ad3adfb35d0
5959
md"""
60-
Next, we instantiate our model with `turing_model` without specifying any model, thus the default model will be used: `Gaussian()`:
60+
Next, we instantiate our model with `turing_model` without specifying any model, thus the default model will be used (`model=Normal`):
6161
"""
6262

6363
# ╔═╡ 55b91963-001e-4753-93a6-2fa64190f353

docs/src/tutorials/logistic_regression.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ fm = @formula(switch ~ dist + arsenic + assoc + educ)
5858

5959
# ╔═╡ 2ebfa422-f8a5-44d3-8f2c-a34d7832d3f2
6060
md"""
61-
Now we instantiate our model with `turing_model` passing a third argument `Logistic()` to indicate that the model is a logistic regression:
61+
Now we instantiate our model with `turing_model` passing a keyword argument `model=Bernoulli` to indicate that the model is a logistic regression:
6262
"""
6363

6464
# ╔═╡ 1f1158ce-73f0-49fd-a48a-af3b36376030
65-
model = turing_model(fm, wells, Logistic());
65+
model = turing_model(fm, wells; model=Bernoulli);
6666

6767
# ╔═╡ ebe074cb-7bad-4b52-9c9d-b9752af4bedd
6868
chn = sample(model, NUTS(), 2_000);

docs/src/tutorials/negative_binomial_regression.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ fm = @formula(y ~ roach1 + treatment + senior)
5757

5858
# ╔═╡ 124aeb01-7661-4402-a2fa-77d2771b686c
5959
md"""
60-
We instantiate our model with `turing_model` passing a third argument `NegBin()` to indicate that the model is a negative binomial regression:
60+
We instantiate our model with `turing_model` passing a keyword argument `model=NegativeBinomial` to indicate that the model is a negative binomial regression:
6161
"""
6262

6363
# ╔═╡ 7ea3a50d-3b0d-4cfd-b311-806d6ae59c1a
64-
model = turing_model(fm, roaches, NegBin());
64+
model = turing_model(fm, roaches; model=NegativeBinomial);
6565

6666
# ╔═╡ 597ce5d7-df3e-44e3-a154-e06e64894854
6767
chn = sample(model, NUTS(), 2_000);

docs/src/tutorials/poisson_regression.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,11 @@ fm = @formula(y ~ roach1 + treatment + senior)
5757

5858
# ╔═╡ 65f4f379-e9a5-4571-bc80-77c024f3f560
5959
md"""
60-
We instantiate our model with `turing_model` passing a third argument `Pois()` to
61-
indicate that the model is a Poisson Regression
60+
We instantiate our model with `turing_model` passing a keyword argument `model=Poisson` to indicate that the model is a Poisson Regression:
6261
"""
6362

6463
# ╔═╡ 9147ed9e-a047-42ca-aa36-f522fad8388b
65-
model = turing_model(fm, roaches, Pois());
64+
model = turing_model(fm, roaches; model=Poisson);
6665

6766
# ╔═╡ aeeac527-2c32-407f-84a1-912cc74f51b7
6867
md"""

docs/src/tutorials/robust_regression.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,11 @@ fm = @formula(kid_score ~ mom_hs * mom_iq)
5555

5656
# ╔═╡ 4f9ff3fd-3f04-49a5-924e-aa23702e75a0
5757
md"""
58-
We instantiate our model with `turing_model` passing a third argument `Student()` to
59-
indicate that the model is a robust regression with the Student's t-distribution:
58+
We instantiate our model with `turing_model` passing a keyword argument `model=TDist` to indicate that the model is a robust regression with the Student's t-distribution:
6059
"""
6160

6261
# ╔═╡ 3f4241d4-1c76-4d7c-99c1-aaa2111385f9
63-
model = turing_model(fm, kidiq, Student());
62+
model = turing_model(fm, kidiq; model=TDist);
6463

6564
# ╔═╡ 7bbe4fe4-bcaf-4699-88e4-0dff92250d30
6665
chn = sample(model, NUTS(), 2_000);

src/TuringGLM.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@ end
4141
include("utils.jl")
4242
include("data_constructors.jl")
4343
include("priors.jl")
44-
include("model.jl")
4544
include("turing_model.jl")
4645

4746
export turing_model
4847
export CustomPrior, DefaultPrior
49-
export Gaussian, Student, Logistic, Pois, NegBin
5048

5149
end # module

0 commit comments

Comments
 (0)