I need to do a 2SLS fixed effects regression in R on my panel data set, but I am really lost at the moment. I ran the model with fixest, but it returned a negative R squared. I also tried to run it with plm but I am not sure if I wrote the correct code for that or if 2SLS is possible at all with plm. The results I got from plm greatly differed from the ones using fixest. So I basically have two questions:
Do fixest and plm use different methods to estimate the same models in general and is that why they generate different results for the same regressions?
And is 2SLS even possible at all in the plm package?
This is the only info I could find on that matter, it is taken from https://cran.r-project.org/web/packages/plm/plm.pdf.
What is am not sure about exactly is the syntax of the instruments here:
## Instrumental variable estimations
# replicate Baltagi (2013/2021), p. 133/162, table 7.1
data("Crime", package = "plm")
FE2SLS <- plm(lcrmrte ~ lprbarr + lpolpc + lprbconv + lprbpris + lavgsen +
ldensity + lwcon + lwtuc + lwtrd + lwfir + lwser + lwmfg + lwfed +
lwsta + lwloc + lpctymle + lpctmin + region + smsa + factor(year)
| . - lprbarr - lpolpc + ltaxpc + lmix,
data = Crime, model = "within")
Does this code mean that lprbarr and lpolpc are instrumented by ltaxpc and lmix? And what if I only wanted lprbarr to be instrumented by ltaxpc and lmix.
Would the correct syntax after the pipe operator be
| . - lprbarr + ltaxpc + lmix