Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ fit
```

## Model methods

```@docs
cooksdistance
StatsBase.deviance
Expand All @@ -68,6 +69,9 @@ GLM.ftest
StatsBase.nobs
StatsBase.nulldeviance
StatsBase.predict
GLM.coef
GLM.confint
StatsBase.coeftable
```

## Links and methods applied to them
Expand Down
2 changes: 0 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ Many of the methods provided by this package have names similar to those in [R](
- `dof`: number of degrees of freedom consumed in the model
- `dof_residual`: degrees of freedom for residuals, when meaningful
- `fitted`: fitted values of the model
- `glm`: fit a generalized linear model (an alias for `fit(GeneralizedLinearModel, ...)`)
- `lm`: fit a linear model (an alias for `fit(LinearModel, ...)`)
- `loglikelihood`: log-likelihood of the model
- `modelmatrix`: design matrix
- `nobs`: number of rows, or sum of the weights when prior weights are specified
Expand Down
16 changes: 16 additions & 0 deletions src/glmfit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ function GeneralizedLinearModel(rr::GlmResp, pp::LinPred,
NaN, NaN)
end

"""
coeftable(mm::AbstractGLM; level::Real=0.95)
coeftable(mm::LinearModel; level::Real=0.95)

Returns formatted table of coefficients.
Each row shows the estimate, standard error, z statstics, p-value, lower- and upper confidence interval
for each paramter in the model
"""
function coeftable(mm::AbstractGLM; level::Real=0.95)
cc = coef(mm)
se = stderror(mm)
Expand All @@ -259,6 +267,14 @@ function coeftable(mm::AbstractGLM; level::Real=0.95)
cn, 4, 3)
end

"""
confint(obj::AbstractGLM; level::Real=0.95)
confint(obj::LinearModel; level::Real=0.95)

Computes and returns the confidence interval for the coefficients as p × 2 matrix
where p is the number of parameters in the model.
Each row corresponds to the confidence interval for a parameter.
"""
function confint(obj::AbstractGLM; level::Real=0.95)
return hcat(coef(obj), coef(obj)) +
stderror(obj)*quantile(Normal(), (1.0 - level)/2.0)*[1.0 -1.0]
Expand Down
7 changes: 7 additions & 0 deletions src/linpred.jl
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,13 @@ function nobs(obj::LinPredModel)
end

coef(x::LinPred) = x.beta0

"""
coef(obj::LinearModel)
coef(obj::GLM)

Returns the coefficient estimates as a vector
"""
coef(obj::LinPredModel) = coef(obj.pp)
function coefnames(x::LinPredModel)
return x.formula === nothing ? ["x$i" for i in 1:length(coef(x))] :
Expand Down
Loading