I am trying to run a series of models in r based on the same structure but a slightly shifted set of variables. I am using an felm model from the lfe package with multiple covariates, fixed effects and a clustered variable.
My basic model is the following:
model <- felm(formula = outcome1 ~ mainx + cov1 + cov2 + cov3 | fe |0| clustercov, data = df)
This works, and allows me to plot the residuals just fine. However, I now need to run this for a series of alternative outcome variables: outcome1, outcome2, outcome3, etc. These are all similarly constructed variables (numeric, etc.) but their values are different. All of the other variables remain the same, with the exception of this outcome variable.
I have some experience using lapply and function() but I am unable to determine how to insert the felm model into this formatting so that I can make the model repeat for different outcome variables. Is this possible with felm, and how should I go about structuring this?