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 calculate clustered standard errors in STATA. The tutorial is based on an simulated data that I generate here and which you can download here.

* start with an empty workspace
clear all

*import data into your STATA session
import excel using "",first

*OLS without clustered standard errors
regress id_score class_size

*OLS with clustered standard errors
regress id_score class_size, cluster(class_id)

* Note, the standard errors are much 
* larger with clustered standard errors
This entry was posted in Computing and Others, Econometrics and tagged , , , . Bookmark the permalink.

One Response to Clustered Standard Errors in STATA

  1. Pingback: Clustered Standard Errors | Economic Theory Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.