Adjusting for Biased Standard Errors
With heteroscedastic or clustered standard errors, the estimated effect will be unbiased; however, standard errors will be inconsistent meaning that the associated p-values will be wrong, and any conclusion from the significance of the effect may be misleading.
While clustering of standard errors should be evident from the study design (“Are the observations clustered, either within groups or over time?”), homoscedasticity can be checked with a Breusch-Pagan test for heteroskedasticity using the olsrr package in R (https://cran.r-project.org/web/packages/olsrr/index.html) or the estat hettest command in Stata (https://www.stata.com/manuals/rregresspostestimation.pdf). If the test is significant, it means that heteroscedasticity is present in the data (i.e., the variance of the errors from the regression is dependent on the values of the independent variables). Thus, the normal standard errors reported in the regression output may be biased.
If heteroscedasticity is present in the data, robust standard errors should be used. These can be obtained using the rms package in R (https://cran.r-project.org/web/packages/rms/index.html) or the vce() option in Stata (https://www.stata.com/manuals/rvce_option.pdf#rvce_option). If the data is clustered, the cluster option can be used in the robcov command of the rms package in R or the vce(cluster) option in Stata. Another approach to adjust for heteroscedastic or clustered standard errors is bootstrapping, which can be implemented using the boot package in R (https://cran.r-project.org/web/packages/boot/) or the vce(bootstrap) option in Stata.