The goal of this package is to provide users the ability to easily replicate STATA regressions in R. Particularly, this package provides the reg
function, inspired by STATA's reg
command. This function allows users to quickly run regressions with robust or clustered standard errors and returns results which match those of STATA. This document demonstrates how to use regr
.
This example uses test data from Petersen (2006). Petersen performs the following analyses on this data:
reg y x
)reg y x, robust
)reg y x, cluster(firmid)
)reg y x, cluster(year)
)reg y x, cluster(firmid, year)
)Petersen provides the results to these analyses using STATA here. We will replicate these analyses in turn to demonstrate the use of regr
.
First, we load the data.
library(regr) data("panel_data")
Now, we can run the regressions.
reg(y ~ x, panel_data)
reg(y ~ x, panel_data, robust = TRUE)
reg(y ~ x, panel_data, cluster = "firmid")
reg(y ~ x, panel_data, cluster = "year")
reg(y ~ x, panel_data, cluster = c("firmid", "year"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.