Skip to content

Commit

Permalink
more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
palday committed Sep 2, 2023
1 parent 6d727f4 commit 3fef311
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/statsmodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,48 @@ formula(m::TableRegressionModel) = m.mf.f
Return the names of terms used in the formula of `model`.
For regression models with only continuous predictors, this is the same as
This is a convenience method for `termnames(formula(model))`.
For `RegressionModel`s with only continuous predictors, this is the same as
`(responsename(model), coefnames(model))`.
For models with categorical predictors, the returned names reflect
the variable name and not the coefficients resulting from
the choice of contrast coding.
"""
termnames(model::StatisticalModel) = termnames(formula(model))
"""
termnames(t::FormulaTerm)
Return a two-tuple of `termnames` applied to the left and
right hand sides of the formula.
Note that until `apply_schema` has been called, literal `1` in formulae
is interpreted as `ConstantTerm(1)` and will thus appear as `"1"` in the
returned term names.
```jldoctest
julia> termnames(@formula(y ~ 1 + x * y + (1+x|g)))
("y", ["1", "x", "y", "x & y", "(1 + x) | g"])
```
Similarly, formulae with an implicit intercept will not have a `"1"`
in their term names, because the implicit intercept does not exist until
`apply_schema` is called (and may not exist for certain model contexts).
```jldoctest
julia> termnames(@formula(y ~ x * y + (1+x|g)))
("y", ["x", "y", "x & y", "(1 + x) | g"])
```
"""
termnames(model::StatisticalModel) = termnames(formula(model))
termnames(t::FormulaTerm) = (termnames(t.lhs), termnames(t.rhs))

"""
termnames(term::AbstractTerm)
Return the name(s) of column(s) generated by a term. Return value is either a
`String` or an iterable of `String`s.
"""
termnames(t::FormulaTerm) = (termnames(t.lhs), termnames(t.rhs))
termnames(::InterceptTerm{H}) where {H} = H ? "(Intercept)" : nothing
termnames(t::ContinuousTerm) = string(t.sym)
termnames(t::CategoricalTerm) = string(t.sym)
Expand Down

0 comments on commit 3fef311

Please sign in to comment.