GLM.jl
GLM.jl copied to clipboard
inexact error when computing aic on proportional dependent variable and Binomial()
In Julia 1.5.1 or 1.6.
Here py
is a vector of probabilities and y
are "samples" drawn from py. py
isn't really Binomial()
but glm
still fits the model. You can get the deviance of this model, modpy
, but the aic, bic, loglikelihood
all give inexact error
using GLM, StatsBase
begin
x = randn(100).*3
py = (1 ./ (1 .+ exp.(-0.5 .* x .+ 2.4 .+ rand(100))))
y = rand(100) .< py
mody = glm(@formula(y ~ x), Dict(:x=>x, :y=>y), Binomial())
modpy = glm(@formula(y ~ x), Dict(:x=>x, :y=>py), Binomial())
mody, modpy
aic(mody) # OK!
aic(modpy) # error
deviance.([modpy, mody]) # OK!
loglikelihood(modpy) # Error
end
I'm not sure we can do anything about this, as Binomial(1.5, 1)
throws an error. Contrary to us, R gives an AIC when estimating a binomial model with non-integer counts, but it prints a warning. So I'm not sure their AIC can be trusted. Do you have a reason to think that non-integer counts would make any statistical sense?