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

Collinearity diagnostics with fixed effects and more than two predictor variables #412

Closed
grlju opened this issue Apr 27, 2023 · 5 comments

Comments

@grlju
Copy link

grlju commented Apr 27, 2023

Hi Laurent,

Thanks for the great package. I am getting an error message when trying to run collinearity diagnostics with fixed effects and more than two predictor variables.

See this example:

library(fixest)
data(trade)

gravity_pois = fepois(Euros ~ log(dist_km) + Origin + Destination | Product + Year, trade)
collinearity(gravity_pois)

I get the following error:

Checking Collinearity: simple with fixed-effects:..OK,  multiple:.............................OK, multiple with cluster.Error in feols(fml2estimate, linbase, fixef = new_dum_names[id_cluster],  : 
  Error in str2lang(value_raw) : <text>:1:2: unexpected input
1: __
     ^
This error was unforeseen by the author of the function feols. If you think your call to the function is legitimate, could you report?

I tried to look at the source code, but it looks a bit too complicated for me.

Thanks,
Greg

@Sualk3
Copy link

Sualk3 commented Jul 12, 2023

I have the exact same problem! I am using three-way fixed effects - error occurs for fepois and feols. I thought it might be connected to clustering, but so far nothing worked out. Anyone any idea what to try?

@lrberge
Copy link
Owner

lrberge commented Feb 7, 2024

Hello and thanks for the kind words :-)

The problem is fixed, sorry for the long delay!!

@lrberge lrberge closed this as completed Feb 7, 2024
@ozgur-ozer
Copy link

Hello, thank you for making this package available. Today, while running a model, I encountered this error. I also tested the code provided by @grlju and received the same error. Thanks.

data(trade)
gravity_pois = fepois(Euros ~ log(dist_km) + Origin + Destination | Product + Year, trade)
collinearity(gravity_pois)

Checking Collinearity: simple with fixed-effects:..OK,  multiple:.............................OK, multiple with cluster.Error in feols(fml2estimate, linbase, fixef = new_dum_names[id_cluster],  : 
  Error in str2lang(value_raw) : <text>:1:2: unexpected input
1: __
     ^
This error was unforeseen by the author of the function feols. If you think your call to the function is legitimate, could you report?```

@lrberge
Copy link
Owner

lrberge commented Feb 15, 2024

Hi, you need to update to the current github version.

Here are the current results:

gravity_pois = fepois(Euros ~ log(dist_km) + Origin + Destination | Product + Year, trade)
collinearity(gravity_pois)
#> Checking Collinearity: 
#> - simple with fixed-effects:..OK
#> - multiple:.............................OK
#> - multiple with fixed-effects.............................OK
#> [1] "No visible collinearity problem. (Doesn't mean there's none!)"

# example with collinear variable
data(base_did)
est = feols(y ~ x1 + treat | id + period, base_did)
collinearity(est)
#> [1] "Variable 'treat' is collinear with the fixed-effects `id`."

@ozgur-ozer
Copy link

Thanks! It worked.

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

No branches or pull requests

4 participants