Tag Archives: standard errors

Clustered Standard Errors in STATA

In STATA clustered standard errors are obtained by adding the option cluster(variable_name) to your regression, where variable_name specifies the variable that defines the group / cluster in your data. The summary output will return clustered standard errors. Here is the syntax:

 regress x y, cluster(variable_name)

Below you will find a tutorial that demonstrates how to Continue reading Clustered Standard Errors in STATA

Clustered Standard Errors in R

The easiest way to compute clustered standard errors in R is the modified summary(). I added an additional parameter, called cluster, to the conventional  summary() function. This parameter allows to specify a variable that defines the group / cluster in your data. The summary output will return clustered standard errors. Here is the syntax:

summary(lm.object, cluster=c("variable")) Continue reading Clustered Standard Errors in R

Example data – Clustered Standard Errors

The following R script creates an example dataset to illustrate the application of clustered standard errors. You can download the dataset here.

The script creates a dataset with a specific number of student test results. Individual students are identified via the variable student_id . The variable id_score comprises a student’s test score. In the test, students can score from 1 to 10 with 10 being the highest score possible. Continue reading Example data – Clustered Standard Errors