-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@fitmodel
errors on sanction dataset with seed 123.
#3
Comments
@fitmodel
fails on sanction dataset with seed 123.
@fitmodel
fails on sanction dataset with seed 123. @fitmodel
errors on sanction dataset with seed 123.
This warning is not due to seed choice. This warning is due to the MCMC chain exploring some possible values and getting some illegal values at the initial stage. This warning is coming from Turing. Can't tell why it stops due to seed 123. Can you please share the error message from seed 123? |
This is the error when we use |
This is very odd. This issue is supposed to be mathematically taken care of in the modeling. What is the probability that |
We should file this issue in Turing.jl |
Let me prepare a note with code easy to understand for the Turing developer. |
This is the underlying code: using Turing, Random, RDatasets, StatsModels
Random.seed!(123)
data = dataset("Zelig", "sanction")
formula = @formula(Num ~ Target + Coop + NCost)
formula = apply_schema(formula, schema(formula, data));
y, X = modelcols(formula, data);
@model NegBinomReg(X, y) = begin
p = size(X, 2);
n = size(X, 1);
#priors
λ~InverseGamma(1.0,1.0)
ν~InverseGamma(1.0,1.0)
α ~ TDist(ν)*λ
β ~ filldist(TDist(ν)*λ, p)
## link
z = α .+ X * β
mu = exp.(z)
#likelihood
for i = 1:n
y[i] ~ NegativeBinomial(λ, (1 / (1 + mu[i]/ λ)))
end
end
NegBinomReg_model=NegBinomReg(X,y);
chain = sample(NegBinomReg_model, NUTS(), 10000)
summaries, quantiles = describe(chain) @sourish-cmi it is running perfectly. We aren't able to isolate the bug to report it on Turing. |
@sourish-cmi can you make a small code reproducible code for this for the Turing folks. |
Ran the code successfully on my end. I believe the bug is fixed now. Shall we close this issue? |
Shall we close this issue? You thought? |
Hello @sourish-cmi. I will try to run this code again, by generating a few hundred random seeds (this was how I discovered this error in the first place). I believe this error still exists, and I'll let you know once I run the tests. In fact, I think the error mentioned in #13 is also similar, and can be discovered like this. I'll try this out, and comment here. |
@codetalker7 okay great idea. |
Hi @sourish-cmi. I ran the following test for different priors for linear regression. using CRRao, Test, StableRNGs, Logging, RDatasets, Random
Logging.disable_logging(Logging.Warn)
CRRao.setprogress!(false)
mtcars = dataset("datasets", "mtcars")
priors = [
Prior_Ridge(),
Prior_Laplace(),
Prior_Cauchy(),
Prior_TDist(),
Prior_Uniform(),
]
for prior in priors
for i in 1:1000
seed = rand(1:1000)
try
CRRao.set_rng(StableRNG(seed))
model = @fitmodel(MPG ~ HP + WT + Gear, mtcars, LinearRegression(), prior)
catch e
println(e)
println(seed)
break
end
end
end For using CRRao, StableRNGs, RDatasets
mtcars = dataset("datasets", "mtcars")
CRRao.set_rng(StableRNG(707))
model = @fitmodel(MPG ~ HP + WT + Gear, mtcars, LinearRegression(), Prior_TDist()) I'm sure that for other regression models as well, we can recover similar erroneous cases. The only problem is that these tests take a long time to run. |
I tried running the same test for
I think either this is an issue in Turing.jl, or some problem with the model definitions (or could be something else too). |
Okay, nice work. If it is a problem with Turing, I have to reproduce the error in Turing. Let me do this, and then we have to file an issue with them. |
On a different thought - it might be the issue with the parameter |
Consider the following code.
The above code returns an error (the error message is too long to print here).
Running the same code with a different seed (42) runs successfully, but with a warning (the image of the warning is attached).
The text was updated successfully, but these errors were encountered: