Sean Mackesey
Sean Mackesey

Reputation: 10939

How do I fit a GLM in Julia while altering the max number of iterations?

I am trying to fit a generalized linear model using Julia's GLM package. The fitting algorithm is failing because the max number of iterations, set by default to 30, is being exceeded. Examination of the source reveals that this parameter is stored as a named argument (maxIter) to the fit function, which is called at the end of the glm function if the dofit named argument to glm is true (which it is by default). So I should be able to adjust the max iterations by setting dofit to false, creating my glm, then calling fit manually on it with an altered maxIter:

myGlm = glm(formula, dataframe, Poisson(), dofit=false)
fit(myGlm, maxIter=50)

But the first line of this code fails with the error message:

no method glm(Array{Any,1},Expr,DataFrame,Poisson,LogLink)

When I look at the function signatures for glm in the source (glmfit.jl) or with help(glm), it's true that this signature isn't listed. But why is this the signature for my function call? Are named arguments automatically moved as an array to the beginning of the argument list, and do they need to be supported explicitly? The source in the context of This section of the Julia manual suggests my call should work.

Upvotes: 4

Views: 759

Answers (1)

jverzani
jverzani

Reputation: 5700

It looks like the keyword arguments aren't being passed along in https://github.com/JuliaStats/GLM.jl/blob/master/src/glmfit.jl#L134

If that is so, you should file and issue, and in the meantime pass in a link function to the call so that the main glm function is called, not the convenience constructor.

Upvotes: 1

Related Questions