Joel_M
March 26, 2023, 12:17pm
1
Hi, everyone. I'm new here
I'm trying to switch from Stata to r, by recreating the regressions from my bachelors thesis.
This is a difference-in-difference (kind of) regression, but with paneldata (fixed effect), and I would like to get robust standard errors
In Stata it would look like this;
xtset firm year
xtreg debt_to_equity2019 recession##involved i.year, fe robust
This is how I'm trying to do it in r;
summary(robis <- rlm(debt_to_equity2019 ~ involved*recession + factor(firm) + factor(year) - 1, data = super))
Now, this works without the factor variables in the rlm regression and with the factors in a an lm-regression, but trying to get both xt and robust standard errors, returns the following...
summary(robis <- rlm(debt_to_equity2019 ~ involved*recession + factor(firm) + factor(year) - 1, data = super))
Error in rlm.default(x, y, weights, method = method, wt.method = wt.method, :
'x' is singular: singular fits are not implemented in 'rlm'
How should I write instead of "+ factor(firm) + factor(year) - 1" to make it work?
Thanks in advance!
//Joel
Joel_M
March 26, 2023, 7:07pm
2
Update... It seems I got it working by using plm instead of rlm.
install.packages("plm")
library(plm)
library(lmtest)
ferobcontr <- plm(debt_to_equity2019 ~ recession*involved + log_revenue + capital_intensity + net_profit_margin + equity_finance_to_equity2019, data=super, index=c("firm","year"), model="within")
coeftest(ferobcontr, vcov.=vcovHC(ferobcontr))
Gave me;
coeftest(ferobcontr, vcov.=vcovHC(ferobcontr))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
recession -0.0516705 0.0515073 -1.0032 0.317275
log_revenue 0.8473585 0.2820325 3.0045 0.003084 **
capital_intensity -0.0027395 0.0751641 -0.0364 0.970971
net_profit_margin -0.2057401 0.3199005 -0.6431 0.521044
equity_finance_to_equity2019 1.2384546 0.6103812 2.0290 0.044097 *
recession:involved 0.2622649 0.1468239 1.7863 0.075928 .
Signif. codes: 0 ‘’ 0.001 ‘ ’ 0.01 ‘ ’ 0.05 ‘.’ 0.1 ‘ ’ 1
system
Closed
April 16, 2023, 7:07pm
3
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.