Skip to content
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 hasintercept #17

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

matthieugomez
Copy link

This is useful to compute the correct degrees of freedoms to be used in t-test

This is useful to compute the correct degrees of freedoms to be used in t-test
@codecov-commenter
Copy link

codecov-commenter commented Jun 27, 2022

Codecov Report

Patch coverage is 100.00% of modified lines.

Files Changed Coverage
src/regressionmodel.jl 100.00%

📢 Thoughts on this report? Let us know!.

Copy link
Member

@nalimilan nalimilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Maybe this should be defined only for RegressionModel instead?

I also wonder whether we should even define a fallback definition X = modelmatrix(model); any(i -> all(==(1), view(X , :, i)), 1:size(X, 2)) like in GLM.jl.

src/statisticalmodel.jl Outdated Show resolved Hide resolved
src/statisticalmodel.jl Outdated Show resolved Hide resolved
src/statisticalmodel.jl Outdated Show resolved Hide resolved
src/statisticalmodel.jl Outdated Show resolved Hide resolved
@nalimilan
Copy link
Member

Bump.

matthieugomez and others added 6 commits September 6, 2023 08:27
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
@matthieugomez
Copy link
Author

Moved it to RegressionModel

@matthieugomez
Copy link
Author

Btw, note that StatsModels started exporting hasintercept after I wrote this PR. Not sure if this makes it better or not to define it in StatsAPI

@nalimilan
Copy link
Member

How about adding a fallback definition as I proposed above?

@nalimilan
Copy link
Member

Btw, note that StatsModels started exporting hasintercept after I wrote this PR. Not sure if this makes it better or not to define it in StatsAPI

Ah, good point, that's JuliaStats/StatsModels.jl#281. I guess it makes sense to define it in StatsAPI too like the rest of the RegressionModel API, but we will have to import it in StatsModels after tagging a release. AFAICT StatsModels doesn't define any method for RegressionModel, only for terms/formulas.

@nalimilan
Copy link
Member

nalimilan commented Sep 6, 2023

Thinking about it, it could be better to only have an empty definition here, so that we can define a fallback in StatsModels like this:

function StatsModels.hasintercept(m::RegressionModel)
    if formula(m) !== nothing
        return hasintercept(formula(m))
    else
        X = modelmatrix(model)
        return any(i -> all(==(1), view(X , :, i)), 1:size(X, 2))
    end
end

EDIT: a third possibility would be to add a fallback formula(m::StatisticalModel) = nothing in StatsAPI so that we can have the method above in StatsAPI.

CC: @kleinschmidt @palday

@palday
Copy link
Member

palday commented Sep 6, 2023

@nalimilan you need requires_one_based_indexing for yours or change it to use axes.

I like the idea of defining a formula stub here. Then downstream packages can do things like define RegressionModels that have a reasonable default formula definition without depending on StatsModels and still optionally supporting the whole Terms interface in extensions.

@nalimilan
Copy link
Member

@kleinschmidt What do you think? I find it relatively unlikely that a package would want to provide an alternative formula implementation. Now that we've decided to put vif and gvif in StatsModels, maybe we should be consistent and put the fallback hasintercept definition there...

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