I am trying to run a pooled regression using the mice package.
I have created data using multiple imputation through the following.
library(tidyverse)
library(fixest)
library(mice)
data_mice = mice(data = df,m = 5, maxit = 100,method = "pmm")
#Create large dataset with all imputations in it
data_mice_combined = complete(data_mice,"long")
And I now try to run the pooled regression using a fixed effects model from the fixest package:
reg.fit.mi = with(data = data_mice_combined, exp= fixest::feols(outcome ~ control + control + x1*x2 |fe ))
But I receive the following error
Error in feols(outcome ~ control + x1*x2 |fe ) :
You must provide the argument 'data' (currently it is missing).
I obviously don't specify data here, but I thought that was not necessary with the with function. But when I try specifying data, that runs the model, however all of my observations are included in the same model, not different models for the separate imputations. I want to run the models separately and then pool them using the following code:
pool.fit = pool(reg.fit.mi)
How can I make the fixest package work with the with function and create this pooled regression model?