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

Issue computing fixed effects #753

Open
ijohnsson-chwy opened this issue Dec 17, 2024 · 5 comments
Open

Issue computing fixed effects #753

ijohnsson-chwy opened this issue Dec 17, 2024 · 5 comments
Labels
can't reproduce If a maintainer did not manage to reproduce a reported bug

Comments

@ijohnsson-chwy
Copy link

`import pyfixest as pf

data = pf.get_data()
mod = pf.feols("Y ~ X1 | f1 + f2", data=data)
mod.summary()
mod.fixef()`

gives the error

`---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[114], line 6
4 mod = pf.feols("Y ~ X1 | f1 + f2", data=data)
5 mod.summary()
----> 6 mod.fixef()

File /opt/conda/lib/python3.11/site-packages/pyfixest/estimation/feols_.py:1740, in Feols.fixef(self, atol, btol)
1738 res: dict[str, dict[str, float]] = {}
1739 for i, col in enumerate(cols):
-> 1740 variable, level = _extract_variable_level(col)
1741 # check if res already has a key variable
1742 if variable not in res:

File /opt/conda/lib/python3.11/site-packages/pyfixest/utils/dev_utils.py:191, in _extract_variable_level(fe_string)
188 t_match = re.search(t_pattern, fe_string, re.DOTALL)
190 if not c_match or not t_match:
--> 191 raise ValueError(
192 f"feols() failed after regex encountered the following value as a fixed effect:\n {fe_string}."
193 + "\nThis may due to the presence of line separation and/or escape sequences within the string."
194 + " If so, consider recoding the underlying string. Otherwise, please open a PR in the github repo!"
195 )
197 variable = c_match.group(1)
198 level = t_match.group(1)

ValueError: feols() failed after regex encountered the following value as a fixed effect:
C(f1)[0.0].
This may due to the presence of line separation and/or escape sequences within the string. If so, consider recoding the underlying string. Otherwise, please open a PR in the github repo!`

@s3alfisc
Copy link
Member

Hi @ijohnsson-chwy , thanks for reporting this!

I cannot reproduce this under pyfixest 0.27:

%load_ext autoreload
%autoreload 2

import pyfixest as pf

data = pf.get_data()
mod = pf.feols("Y ~ X1 | f1 + f2", data=data)
mod.summary()
mod.fixef()

Which version of the package are you running? You can check this by running pip show pyfixest in the command line.

@s3alfisc s3alfisc added the can't reproduce If a maintainer did not manage to reproduce a reported bug label Dec 22, 2024
@kassemdana
Copy link

I get the same error with pyfixest 0.27

@s3alfisc
Copy link
Member

s3alfisc commented Jan 7, 2025

Hi, can you manually downgrade to formulaic < 1.1.0? Ie 1.0.2? This should solve your issue, it's related to a change in formulaic 1.1.0.

@s3alfisc
Copy link
Member

s3alfisc commented Jan 7, 2025

I finally managed to reproduce this, btw @ijohnsson-chwy 😅

@kassemdana
Copy link

perfect! it worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can't reproduce If a maintainer did not manage to reproduce a reported bug
Projects
None yet
Development

No branches or pull requests

3 participants