Skip to content

move statsmodels.jl types and function stubs from StatsBase #4

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

Merged
merged 5 commits into from
Nov 20, 2021

Conversation

rafaqz
Copy link
Contributor

@rafaqz rafaqz commented Nov 6, 2021

This PR moves StatisticalModel and RegressionModel types, and most function stubs from statsmodels.jl in StatsBase to StatsAPI.

  • bic, aic and aicc are included here as undocumented stubs in statisticalmodels.jl, the implementation and its specific documentation should probably remain in StatsBase.jl. with the full implementation, as its so small and generic
  • params has been put in the main file as it was not defined for a specific type.

I'm wondering if we should export all of these types and methods? The existing methods were not exported.

See JuliaStats/StatsBase.jl#726

@nalimilan
Copy link
Member

Thanks. I just have a doubt about:

bic, aic and aicc are included here as undocumented stubs in statisticalmodels.jl, the implementation and its specific documentation should probably remain in StatsBase.jl.

Given that the implementations are very simple and based only on other methods defined in StatsAPI it may be OK to include them here (we also do this for some simple fallback implementations in DataAPI). Requiring a model to depend on StatsBase just to get aic or r2 to work would be weird. Note that crossmodelmatrix also has a default implementation in the current state of this PR.

@kleinschmidt Any opinion?

I'm wondering if we should export all of these types and methods? The existing methods were not exported.

I think the idea is that packages should export functions that they actually use rather than blindly reexport the whole of StatsAPI. That's what we do with DataAPI.

@st--
Copy link

st-- commented Nov 20, 2021

What's the motivation behind all the stub implementations that call error? It seems a bit redundant with the Julia base error for when you've not defined a method for your type... And in case of functions like predict! that clearly require further arguments to be passed in, defining the single-argument error seems not particularly helpful 🤔 Would it not be enough to simply define function predict! end to provide the API docstring?

@rafaqz
Copy link
Contributor Author

rafaqz commented Nov 20, 2021

There was no motivation, it's just the code from StatsBase.jl as-is. So this is a question of if we want to clean up the code during this PR.

But yes it seems redundant, and function methodname end stubs might be fine if others are ok with that.

@rafaqz
Copy link
Contributor Author

rafaqz commented Nov 20, 2021

@nalimilan aic, aicc and bic are restored with basic definitions here.

I was looking to move the tests here too, but there don't seem to be any tests for those methods in StatsBase.jl?

@nalimilan
Copy link
Member

Yes we can drop all these error(...) definitions.

@nalimilan aic, aicc and bic are restored with basic definitions here.

I was looking to move the tests here too, but there don't seem to be any tests for those methods in StatsBase.jl?

Right, the methods that we define should probably be tested. It doesn't have to happen in this PR, but if you feel like doing it that would be nice.

@rafaqz
Copy link
Contributor Author

rafaqz commented Nov 20, 2021

Testing fundamental statistical methods probably isn't something you should entrust to me ;)

I'll get the PR together minus errors, someone else can do a tests PR later.

@rafaqz
Copy link
Contributor Author

rafaqz commented Nov 20, 2021

This should be ready to merge. I have the reciprocal PR to StatsBase.jl ready whenever this is registered.

@nalimilan
Copy link
Member

Testing fundamental statistical methods probably isn't something you should entrust to me ;)

Well, given how simple the definitions are the risks of getting these wrong are limited. :-) We have correctness tests again R in GLM anyway, in StatsAPI we should just ensure that we don't introduce regressions in the future.

@codecov-commenter
Copy link

Codecov Report

Merging #4 (116e1a5) into main (e3e696a) will not change coverage.
The diff coverage is 0.00%.

Impacted file tree graph

@@         Coverage Diff          @@
##           main      #4   +/-   ##
====================================
  Coverage      0   0.00%           
====================================
  Files         0       2    +2     
  Lines         0       7    +7     
====================================
- Misses        0       7    +7     
Impacted Files Coverage Δ
src/regressionmodel.jl 0.00% <0.00%> (ø)
src/statisticalmodel.jl 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e3e696a...116e1a5. Read the comment docs.

@nalimilan nalimilan merged commit cc611fb into JuliaStats:main Nov 20, 2021
@nalimilan
Copy link
Member

Thanks! See JuliaRegistries/General#49094.

@rafaqz rafaqz deleted the move_statsmodels branch November 20, 2021 22:20
@nalimilan nalimilan mentioned this pull request Nov 26, 2021
@nalimilan
Copy link
Member

Do you still plan to make PRs against StatsBase and StatsModels to import functions from StatsAPI?

@rafaqz
Copy link
Contributor Author

rafaqz commented Dec 4, 2021

I had already updated and tested StatsBase.jl, just forgot to PR. But I haven't looked at StatsModels.jl, so if someone else wants to who knows the codebase that may be easier.

@nalimilan
Copy link
Member

Woops, we missed the definition of stderror: #9

@rafaqz
Copy link
Contributor Author

rafaqz commented Feb 15, 2022

Oops...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants