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 "https://economictheoryblog.files.wordpress.com/2016/12/data.xls",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

### Like this:

Like Loading...

*Related*

Pingback: Clustered Standard Errors | Economic Theory Blog