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

Non covariate variables being detected as covariates #797

Closed
tomicapretto opened this issue Apr 7, 2024 · 2 comments · Fixed by #801
Closed

Non covariate variables being detected as covariates #797

tomicapretto opened this issue Apr 7, 2024 · 2 comments · Fixed by #801
Labels

Comments

@tomicapretto
Copy link
Collaborator

Thanks to #796 I found that the get_model_covariates() function is returning non-covariate variables as covariates.

Example:

import bambi as bmb
import numpy as np
import pandas as pd

from bambi.interpret.utils import get_model_covariates

df = pd.read_csv("https://raw.githubusercontent.com/m-clark/generalized-additive-models/master/data/pisasci2006.csv")

knots_income = np.linspace(np.min(df['Income']), np.max(df['Income']), 5+2)[1:-1]
formula = "Overall ~ 1 + bs(Income, degree=3, knots=knots_income)"
model = bmb.Model(formula, df, dropna=True)
get_model_covariates(model)
array(['Income', 'knots_income'], dtype='<U12')

The non covariate variable is knots_income. The variable is not looked up into the data frame. It comes from the outer environment.

@GStechschulte
Copy link
Collaborator

GStechschulte commented Apr 8, 2024

Hey @tomicapretto I was going to assign this to myself, but realized you already have a hotfix branch to resolve this. Do you want me to take this over, or are you fine completing it?

P.S. You indeed found the correct issue 😄

@tomicapretto
Copy link
Collaborator Author

Ha, thanks! I'm completing it right now ;)

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

Successfully merging a pull request may close this issue.

2 participants