I am estimating an OLS regression without fixed effects and an OLS regression with fixed effects in R Studio. I have read, that it is common to use robust standard errors, when estimating a simple OLS model and to use clustered standard errors when estimating a fixed-effects model...however, I am not sure If I did it correctly! I thank you for your advice in advance!
my data is paneldatafinal, and I have a panel structure with IND and year.
This is the OLS model with robust standard error:
# MODEL EPS MARKET BASED:
model_mb_basic_ols <- lm(diff_log_VATFP_I ~ log_Impen_Mil + RuDintensity_vapc +
dummy_var*EPS_MKT_growth_MA3 + log_PRDK_growth_rate + GAP,
data = paneldatafinal)
# Compute robust standard errors:
robust_se <- vcovHC(model_mb_basic, type = "HC1")
# Display the results:
summary_result <- coeftest(model_mb_basic, vcov = robust_se)
# Print summary result with robust standard errors:
print(summary_result)
This is the Fixed effect model:
## Model with clustered Standard Errors & fixed effects EPS TOTAL:
model_basicfe <- plm(diff_log_VATFP_I ~ log_Impen_Mil + RuDintensity_vapc +
dummy_var*EPS_growth_MA3 + log_PRDK_growth_rate + GAP,
data = paneldatafinal, model = "within", index = c("IND", "year"))
# Calculate clustered standard errors:
vcov_clustered <- vcovHC(model_basicfe, type = "HC1", cluster = "group")
# Apply the clustered standard errors to the model:
coeftest(model_basicfe, vcov = vcov_clustered)
# Use stargazer to present the results:
stargazer(model_basicfe, type = "text", se = list(sqrt(diag(vcov_clustered))), header = FALSE)