GLM.jl icon indicating copy to clipboard operation
GLM.jl copied to clipboard

inexact error when computing aic on proportional dependent variable and Binomial()

Open jerlich opened this issue 4 years ago • 1 comments

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

jerlich avatar Feb 04 '21 07:02 jerlich

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?

nalimilan avatar Feb 14 '21 16:02 nalimilan