Skip to content

Commit

Permalink
add modelmatrix method for TableRegressionModel (#211)
Browse files Browse the repository at this point in the history
* add modelmatrix method for TableRegressionModel

* do it via @DeleGate
  • Loading branch information
palday authored Feb 3, 2021
1 parent da94d2b commit 5444c5e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "StatsModels"
uuid = "3eaba693-59b7-5ba5-a881-562e759f1c8d"
version = "0.6.19"
version = "0.6.20"

[deps]
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
Expand Down
11 changes: 6 additions & 5 deletions src/statsmodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ end

"""
Wrapper for a `StatisticalModel` that has been fit from a `@formula` and tabular
data.
data.
Most functions from the StatsBase API are simply delegated to the wrapped model,
with the exception of functions like `fit`, `predict`, and `coefnames` where the
Expand All @@ -54,7 +54,7 @@ end

"""
Wrapper for a `RegressionModel` that has been fit from a `@formula` and tabular
data.
data.
Most functions from the StatsBase API are simply delegated to the wrapped model,
with the exception of functions like `fit`, `predict`, and `coefnames` where the
Expand All @@ -78,7 +78,7 @@ for (modeltype, dfmodeltype) in ((:StatisticalModel, TableStatisticalModel),
function StatsBase.fit(::Type{T}, f::FormulaTerm, data, args...;
contrasts::Dict{Symbol,<:Any} = Dict{Symbol,Any}(),
kwargs...) where T<:$modeltype

Tables.istable(data) || throw(ArgumentError("expected data in a Table, got $(typeof(data))"))
cols = columntable(data)

Expand All @@ -97,7 +97,7 @@ for (modeltype, dfmodeltype) in ((:StatisticalModel, TableStatisticalModel),
end

@doc """
fit(Mod::Type{<:StatisticalModel}, f::FormulaTerm, data, args...;
fit(Mod::Type{<:StatisticalModel}, f::FormulaTerm, data, args...;
contrasts::Dict{Symbol}, kwargs...)
Convert tabular data into a numeric response vector and predictor matrix using
Expand All @@ -120,7 +120,8 @@ const TableModels = Union{TableStatisticalModel, TableRegressionModel}
StatsBase.loglikelihood, StatsBase.nullloglikelihood,
StatsBase.dof, StatsBase.dof_residual, StatsBase.nobs,
StatsBase.stderror, StatsBase.vcov]
@delegate TableRegressionModel.model [StatsBase.residuals, StatsBase.response,
@delegate TableRegressionModel.model [StatsBase.modelmatrix,
StatsBase.residuals, StatsBase.response,
StatsBase.predict, StatsBase.predict!]
StatsBase.predict(m::TableRegressionModel, new_x::AbstractMatrix; kwargs...) =
predict(m.model, new_x; kwargs...)
Expand Down

2 comments on commit 5444c5e

@kleinschmidt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/29293

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.20 -m "<description of version>" 5444c5e3021ec854e1464818597a463df5a4020a
git push origin v0.6.20

Please sign in to comment.