StatsModels.jl
StatsModels.jl copied to clipboard
coefnames should always return a tuple no mattter the number of terms
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"])
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.
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.