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{GLM.LmResp{Array{Float64,1}},GLM.DensePredChol{Float64,LinearAlgebra.Cholesky{Float64,Array{Float64,2}}}}:
Coefficients:
────────────────────────────────────────────────────────────────
Coef. Std. Error t Pr(>|t|) Lower 95% Upper 95%
────────────────────────────────────────────────────────────────
x1 0.717436 0.775175 0.93 0.3818 -1.07012 2.50499
x2 -0.152062 0.124931 -1.22 0.2582 -0.440153 0.136029
────────────────────────────────────────────────────────────────
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:
────────────────────────────────────────────────────────────────
Coef. Std. Error t Pr(>|t|) Lower 95% Upper 95%
────────────────────────────────────────────────────────────────
x1 0.717436 0.775175 0.93 0.3818 -1.07012 2.50499
x2 -0.152062 0.124931 -1.22 0.2582 -0.440153 0.136029
────────────────────────────────────────────────────────────────
GLM.glm
— Function.glm(F, D, args...; kwargs...)
Fit a generalized linear model to data. Alias for fit(GeneralizedLinearModel, ...)
. See fit
for documentation.
StatsBase.fit
— Function.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 fitwts::Vector=similar(y,0)
: Prior frequency (a.k.a. case) weights of observations.
Such weights are equivalent to repeating each observation a number of times equal to its weight. Do note that this interpretation gives equal point estimates but different standard errors from analytical (a.k.a. inverse variance) weights and from probability (a.k.a. sampling) weights which are the default in some other software. Can be length 0 to indicate no weighting (default).
offset::Vector=similar(y,0)
: offset added toXβ
to formeta
. Can be of
length 0
verbose::Bool=false
: Display convergence information for each iterationmaxiter::Integer=30
: Maximum number of iterations allowed to achieve convergenceatol::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.
GLM.lm
— Function.lm(X, y, allowrankdeficient::Bool=false; wts=similar(y, 0))
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
.
The keyword argument wts
can be a Vector
specifying frequency weights for observations. Such weights are equivalent to repeating each observation a number of times equal to its weight. Do note that this interpretation gives equal point estimates but different standard errors from analytical (a.k.a. inverse variance) weights and from probability (a.k.a. sampling) weights which are the default in some other software.
GLM.negbin
— Function.negbin(formula,
data,
link;
initialθ::Real=Inf,
maxiter::Integer=30,
atol::Real=1e-6,
rtol::Real=1.e-6,
verbose::Bool=false,
kwargs...)
Fit a negative binomial generalized linear model to data, while simultaneously estimating the shape parameter θ. Extra arguments and keyword arguments will be passed to glm
.
Keyword Arguments
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