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

Don't get "no covariates" in fixed effects regression #30

Closed
maswiebe opened this issue Sep 28, 2022 · 1 comment
Closed

Don't get "no covariates" in fixed effects regression #30

maswiebe opened this issue Sep 28, 2022 · 1 comment

Comments

@maswiebe
Copy link

I'm using fixest::feols to run a fixed effects regression, but the "no covariates" row doesn't show up.

library(dplyr)
library(fixest)
library(specr)

test_formula <- function(formula,data) {
  formula <-as.formula(paste0(formula, "|group1")) # fixed effects for group1
  feols(formula,data)
}
results <- run_specs(
  df = example_data,
  y = c("y1", "y2"),
  x = c("x1", "x2"),
  model = 'test_formula',
  controls = c("c1", "c2")
)

plot_specs(results)

image

I notice that it works if the regression formula includes a variable before the fixed effects section:

test_formula2 <- function(formula,data) {
  formula <-as.formula(paste0(formula, "+ c3 |group1")) # control for c3 in all specifications
  feols(formula,data)
}
results2 <- run_specs(
  df = dplyr::mutate(example_data, c3 = runif(dplyr::n())),
  y = c("y1", "y2"),
  x = c("x1", "x2"),
  model = 'test_formula2',
  controls = c("c1", "c2")
)

plot_specs(results2)

image

@masurp
Copy link
Owner

masurp commented Jan 16, 2023

I cannot recreate the error using the newest development version of specr (v1.0.0)

library(dplyr)
library(fixest)
library(specr)

test_formula <- function(formula,data) {
  formula <-as.formula(paste0(formula, "|group1")) # fixed effects for group1
  feols(formula,data)
}
results <- run_specs(
  df = example_data,
  y = c("y1", "y2"),
  x = c("x1", "x2"),
  model = 'test_formula',
  controls = c("c1", "c2")
)

plot_specs(results)

Rplot

Also using the new framework, it produces an appropriate plot:

specs <- setup(
  data = example_data,
  y = c("y1", "y2"),
  x = c("x1", "x2"),
  model = 'test_formula',
  controls = c("c1", "c2")
)


results <- specr(specs)

plot(results)

Rplot02

@masurp masurp closed this as completed Jan 23, 2023
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

2 participants