-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to specify format of regression statistics in front end #161
base: master
Are you sure you want to change the base?
Conversation
In reply to the comment on #161
Overall, it seems like the feedback is to not go with
|
Probably you can add a lot of these options in a non-breaking way? Currently Separately, the options could accept missing and/or "" to signal acceptance of defaults. |
Honestly, right now I think the ideal would be: regression_statistics=(LogLikehood, R2; format = ["format1", "format2"], labels = ["Log Likelihood", "R2"]) or regression_statistics=(LogLikehood, R2; format = ("format1", "format2"), labels = ("Log Likelihood", "R2")) That is the most parsimonious, which is good for the user. It matches the Julia function call syntax. And it is parseable. But I guess it would require a macro for implementation. |
Unfortunately regression_statistics=(LogLikehood, R2; format = ["format1", "format2"], labels = ["Log Likelihood", "R2"]) Does not work with the Julia parser. For that to work, it would have to be written as a function: regtable(
...;
regression_statistics=statistics(LogLikehood, R2; format = ["format1", "format2"], labels = ["Log Likelihood", "R2"])
) That is certainly possible, but adds another set of inconsistent formatting since none of the other keyword arguments use that.
Finally, a note on the formula and StatsModels. I do plan on making StatsModels optional. However, I don't know if you were implementing an ordered probit/logit, but there is a Julia package OrderedMultinomialModels.jl that implements those using StatsModels (the R implementation uses formula as well). StatsModels is very extendable, as seen in FixedEffectModels.jl's implementation of IVs. StatsModels also deals with cuts (categorical variables) and interactions, which is why so many packages use it. |
Well that syntax does parse in the sense that if you pass it as a string to I think I tried to run julia> using OrdinalMultinomialModels, RegressionTables, RDatasets
julia> housing = dataset("MASS", "housing");
julia> house_po = polr(@formula(Sat ~ Infl + Type + Cont), housing)
StatsModels.TableRegressionModel{OrdinalMultinomialModel{Int64, Float64, LogitLink}, Matrix{Float64}}
Sat ~ Infl + Type + Cont
Coefficients:
──────────────────────────────────────────────────────────────────────
Estimate Std.Error t value Pr(>|t|)
──────────────────────────────────────────────────────────────────────
intercept Low|Medium -0.693193 0.586303 -1.18231 0.2415
intercept Medium|High 0.693013 0.5863 1.18201 0.2416
Infl: Medium -0.000158234 0.53033 -0.000298369 0.9998
Infl: High -0.000158234 0.53033 -0.000298369 0.9998
Type: Apartment 6.84978e-5 0.612372 0.000111856 0.9999
Type: Atrium 6.84978e-5 0.612372 0.000111856 0.9999
Type: Terrace 6.84978e-5 0.612372 0.000111856 0.9999
Cont: High -5.66775e-5 0.433013 -0.000130891 0.9999
──────────────────────────────────────────────────────────────────────
julia> regtable(house_po)
ERROR: MethodError: no method matching islinear(::StatsModels.TableRegressionModel{OrdinalMultinomialModel{Int64, Float64, LogitLink}, Matrix{Float64}})
Stacktrace:
[1] RegressionType(x::StatsModels.TableRegressionModel{OrdinalMultinomialModel{Int64, Float64, LogitLink}, Matrix{Float64}})
@ RegressionTables C:\Users\drood\.julia\packages\RegressionTables\iz9ba\src\regressionResults.jl:142
[2] _broadcast_getindex_evalf
@ .\broadcast.jl:709 [inlined]
[3] _broadcast_getindex
@ .\broadcast.jl:682 [inlined]
[4] (::Base.Broadcast.var"#31#32"{Base.Broadcast.Broadcasted{…}})(k::Int64)
@ Base.Broadcast .\broadcast.jl:1118
[5] ntuple
@ .\ntuple.jl:48 [inlined]
[6] copy
@ .\broadcast.jl:1118 [inlined]
[7] materialize
@ .\broadcast.jl:903 [inlined]
[8] default_print_estimator(render::AsciiTable, rrs::Tuple{StatsModels.TableRegressionModel{…}})
@ RegressionTables C:\Users\drood\.julia\packages\RegressionTables\iz9ba\src\regtable.jl:291
[9] regtable(rrs::StatsModels.TableRegressionModel{OrdinalMultinomialModel{Int64, Float64, LogitLink}, Matrix{Float64}})
@ RegressionTables C:\Users\drood\.julia\packages\RegressionTables\iz9ba\src\regtable.jl:373
[10] top-level scope
@ REPL[19]:1
Some type information was truncated. Use `show(err)` to see complete types. |
Following #160, allowing more formatting options on the front end would be useful and likely more intuitive. This request attempts to do this by creating anonymous functions in these cases. The result would be: