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: 1 addition & 3 deletions src/schema.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,7 @@ concrete_term(t, d, hint) = t

concrete_term(t::Term, xs::AbstractVector{<:Number}, ::Nothing) = concrete_term(t, xs, ContinuousTerm)
function concrete_term(t::Term, xs::AbstractVector, ::Type{ContinuousTerm})
μ, σ2 = StatsBase.mean_and_var(xs)
min, max = extrema(xs)
ContinuousTerm(t.sym, promote(μ, σ2, min, max)...)
ContinuousTerm(t.sym)
end
# default contrasts: dummy coding
concrete_term(t::Term, xs::AbstractVector, ::Nothing) = concrete_term(t, xs, CategoricalTerm)
Expand Down
10 changes: 1 addition & 9 deletions src/terms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,9 @@ Represents a continuous variable, with a name and summary statistics.
# Fields

* `sym::Symbol`: The name of the variable
* `mean::T`: Mean
* `var::T`: Variance
* `min::T`: Minimum value
* `max::T`: Maximum value
"""
struct ContinuousTerm{T} <: AbstractTerm
struct ContinuousTerm <: AbstractTerm
sym::Symbol
mean::T
var::T
min::T
max::T
end
width(::ContinuousTerm) = 1

Expand Down
4 changes: 0 additions & 4 deletions test/terms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ StatsModels.apply_schema(mt::MultiTerm, sch::StatsModels.Schema, Mod::Type) =
t0 = concrete_term(t, [3, 2, 1])
@test string(t0) == "aaa"
@test mimestring(t0) == "aaa(continuous)"
@test t0.mean == 2.0
@test t0.var == var([1,2,3])
@test t0.min == 1.0
@test t0.max == 3.0

t1 = concrete_term(t, [:a, :b, :c])
@test t1.contrasts isa StatsModels.ContrastsMatrix{DummyCoding}
Expand Down