StatsModels.jl icon indicating copy to clipboard operation
StatsModels.jl copied to clipboard

coefnames should always return a tuple no mattter the number of terms

Open oxinabox opened this issue 6 years ago • 2 comments
trafficstars

The number of terms should not change the type of coeffnames, it should always be a tuple of tuples

1 RHS term

df = (y=1:10, a = 1:10, b=1:10);
f = @formula(y ~ a);
f = apply_schema(f, schema(f, df));

gives:

julia> coefnames(f)
("y", "a")

2 RHS terms

df = (y=1:10, a = 1:10, b=1:10);
f = @formula(y ~ a + b);
f = apply_schema(f, schema(f, df));

gives

julia> coefnames(f)
("y", ["a", "b"])

oxinabox avatar Jun 13 '19 11:06 oxinabox

I agree with this. A related suggestion is that the RHS of the formula could always return a tuple of terms no matter the number of terms. The current situation makes it hard to iterate over the terms on the RHS of the formula for instance.

matthieugomez avatar Aug 11 '19 16:08 matthieugomez

I'm also coming around to this. Although I'd suggest it should be a Vector and that it also goes hand-in-hand with the question of whether you shoudl always return an AbstractMatrix from modelcols (then the coefnames correspond to the labels of the second dimension of whatever modelcols gives you.

kleinschmidt avatar Apr 19 '21 16:04 kleinschmidt