-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from ShouvikGhosh2048/adding-tests
Added basic tests
- Loading branch information
Showing
6 changed files
with
106 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[deps] | ||
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" | ||
RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b" | ||
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
mtcars = dataset("datasets", "mtcars") | ||
|
||
priors = [ | ||
Prior_Ridge(), | ||
Prior_Laplace(), | ||
Prior_Cauchy(), | ||
Prior_TDist(), | ||
Prior_Uniform(), | ||
] | ||
|
||
model = @fitmodel((MPG ~ HP + WT + Gear), mtcars, LinearRegression()) | ||
@test sizeof(model) > 0 | ||
|
||
for prior in priors | ||
model = @fitmodel((MPG ~ HP + WT + Gear), mtcars, LinearRegression(), prior) | ||
@test sizeof(model) > 0 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
turnout = dataset("Zelig", "turnout")[1:100,:] # Take a subset of rows to reduce input size | ||
|
||
links = [Logit(), Probit(), Cloglog(), Cauchit()] | ||
|
||
priors = [ | ||
Prior_Ridge(), | ||
Prior_Laplace(), | ||
Prior_Cauchy(), | ||
Prior_TDist(), | ||
Prior_Uniform(), | ||
] | ||
|
||
for link in links | ||
CRRao.set_rng(StableRNG(123)) | ||
model = @fitmodel((Vote ~ Age + Race + Income + Educate), turnout, LogisticRegression(), link) | ||
@test sizeof(model) > 0 | ||
end | ||
|
||
for prior in priors | ||
for link in links | ||
CRRao.set_rng(StableRNG(123)) | ||
model = @fitmodel((Vote ~ Age + Race + Income + Educate), turnout, LogisticRegression(), link, prior) | ||
@test sizeof(model) > 0 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
sanction = dataset("Zelig", "sanction") | ||
|
||
priors = [ | ||
Prior_Ridge(), | ||
Prior_Laplace(), | ||
Prior_Cauchy(), | ||
Prior_TDist(), | ||
Prior_Uniform(), | ||
] | ||
|
||
CRRao.set_rng(StableRNG(123)) | ||
model = @fitmodel((Num ~ Target + Coop + NCost), sanction, NegBinomRegression()) | ||
@test sizeof(model) > 0 | ||
|
||
for prior in priors | ||
CRRao.set_rng(StableRNG(123)) | ||
model = @fitmodel((Num ~ Target + Coop + NCost), sanction, NegBinomRegression(), prior) | ||
@test sizeof(model) > 0 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
sanction = dataset("Zelig", "sanction") | ||
|
||
priors = [ | ||
Prior_Ridge(), | ||
Prior_Laplace(), | ||
Prior_Cauchy(), | ||
Prior_TDist(), | ||
Prior_Uniform(), | ||
] | ||
|
||
model = @fitmodel((Num ~ Target + Coop + NCost), sanction, PoissonRegression()) | ||
@test sizeof(model) > 0 | ||
|
||
for prior in priors | ||
model = @fitmodel((Num ~ Target + Coop + NCost), sanction, PoissonRegression(), prior) | ||
@test sizeof(model) > 0 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,26 @@ | ||
using CRRao | ||
using Test | ||
using CRRao, Test, StableRNGs, Logging, RDatasets | ||
|
||
Logging.disable_logging(Logging.Warn) | ||
|
||
CRRao.setprogress!(false) | ||
CRRao.set_rng(StableRNG(123)) | ||
|
||
@testset "CRRao.jl" begin | ||
# Write your tests here. | ||
@testset "Basic Tests" begin | ||
@testset "Linear Regression" begin | ||
include("basic/LinearRegression.jl") | ||
end | ||
|
||
@testset "Logistic Regression" begin | ||
include("basic/LogisticRegression.jl") | ||
end | ||
|
||
@testset "Poisson Regression" begin | ||
include("basic/PoissonRegression.jl") | ||
end | ||
|
||
@testset "Negative Binomial Regression" begin | ||
include("basic/NegBinomialRegression.jl") | ||
end | ||
end | ||
end |