API

API

Types defined in the package

DensePredChol
DensePredQR
GlmResp
LinearModel
LmResp
LinPred
GLM.ModResp

Constructors for models

The most general approach to fitting a model is with the fit function, as in

julia> using Random;

julia> fit(LinearModel, hcat(ones(10), 1:10), randn(MersenneTwister(12321), 10))
LinearModel{LmResp{Array{Float64,1}},DensePredChol{Float64,LinearAlgebra.Cholesky{Float64,Array{Float64,2}}}}:

Coefficients:
      Estimate Std.Error  t value Pr(>|t|)
x1    0.717436  0.775175 0.925515   0.3818
x2   -0.152062  0.124931 -1.21717   0.2582

This model can also be fit as

julia> using Random;

julia> lm(hcat(ones(10), 1:10), randn(MersenneTwister(12321), 10))
LinearModel{LmResp{Array{Float64,1}},DensePredChol{Float64,LinearAlgebra.Cholesky{Float64,Array{Float64,2}}}}:

Coefficients:
      Estimate Std.Error  t value Pr(>|t|)
x1    0.717436  0.775175 0.925515   0.3818
x2   -0.152062  0.124931 -1.21717   0.2582
GLM.glmFunction.
glm(F, D, args...; kwargs...)

Fit a generalized linear model to data. Alias for fit(GeneralizedLinearModel, ...). See fit for documentation.

source
StatsBase.fitFunction.
fit(GeneralizedLinearModel, X, y, d, [l = canonicallink(d)]; <keyword arguments>)

Fit a generalized linear model to data. X and y can either be a matrix and a vector, respectively, or a formula and a data frame. d must be a UnivariateDistribution, and l must be a Link, if supplied.

Keyword Arguments

  • dofit::Bool=true: Determines whether model will be fit
  • wts::Vector=similar(y,0): prior case weights. Can be length 0.
  • offset::Vector=similar(y,0): offset added to to form eta. Can be of

length 0

  • verbose::Bool=false: Display convergence information for each iteration
  • maxiter::Integer=30: Maximum number of iterations allowed to achieve convergence
  • atol::Real=1e-6: Convergence is achieved when the relative change in

deviance is less than max(rtol*dev, atol).

  • rtol::Real=1e-6: Convergence is achieved when the relative change in

deviance is less than max(rtol*dev, atol).

  • minstepfac::Real=0.001: Minimum line step fraction. Must be between 0 and 1.
  • start::AbstractVector=nothing: Starting values for beta. Should have the

same length as the number of columns in the model matrix.

source
GLM.lmFunction.
lm(X, y, allowrankdeficient::Bool=false)

An alias for fit(LinearModel, X, y, allowrankdeficient)

The arguments X and y can be a Matrix and a Vector or a Formula and a DataFrame.

source

Model methods

GLM.cancancel
delbeta!
StatsBase.deviance
GLM.dispersion
GLM.installbeta!
GLM.issubmodel
linpred!
linpred
StatsBase.nobs
StatsBase.nulldeviance
StatsBase.predict
updateμ!
wrkresp
GLM.wrkresp!

Links and methods applied to them

Link
GLM.Link01
CauchitLink
CloglogLink
IdentityLink
InverseLink
InverseSquareLink
LogitLink
LogLink
NegativeBinomialLink
ProbitLink
SqrtLink
linkfun
linkinv
mueta
inverselink
canonicallink
glmvar
mustart
devresid
GLM.dispersion_parameter
GLM.loglik_obs