Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Bootstrapping & clustered standard errors (-xtreg-)


From   [email protected] (Jeff Pitblado, StataCorp LP)
To   [email protected]
Subject   Re: st: Bootstrapping & clustered standard errors (-xtreg-)
Date   Tue, 06 Sep 2011 15:02:23 -0500

Tobias Pfaff <[email protected]> wants to use the  clustered
bootstrap with panel data estimator:

> I do the following fixed effects regression:
> 
> xtreg depvar indepvars, fe vce(cluster region) nonest dfadj
> 
> Individuals in the panel are identified by the variable "pid". The time
> variable is "svyyear". Data were previously declared as panel data with
> -xtset pid svyyear-.
> Since one of my independent variables is clustered at the regional level
> (not at the individual level), I use the option -vce(cluster region)-.
> 
> Now, I would like to do the same thing with bootstrapped standard errors.
> I tried several commands, however, none of them works so far. For example:
> 
> xtreg depvar indepvars, fe vce(bootstrap, reps(3) seed(1) cluster(region))
> nonest dfadj
> .where I get the error message "option cluster() not allowed".
> 
> None of the hints in the manual (e.g., -idcluster()-, -xtset, clear-, -i()-
> in the main command) were helpful so far.
> 
> How can I tell the bootstrapping command that the standard errors should be
> clustered at the regional level while using "pid" for panel individuals?

Tobias needs to pull the -cluster()- option outside the -vce()- option.

***** BEGIN:
xtreg depvar indepvars,			///
	fe nonest dfadj			///
	vce(bootstrap, reps(3) seed(1))	///
	cluster(region)
***** END:

Here is a simulated example showing that this works:

***** BEGIN:
* simulate a dataset
set seed 12345
set obs 20
gen clid = _n
gen ui = rnormal()
expand 10
sort clid
gen id = _n
gen uij = rnormal()
expand 30
gen x = ui + rnormal()
gen y =  1 - x + uij + rnormal()
xtset id

* clustered SEs
xtreg y x, fe vce(cluster clid)

* bootstrapped clustered SEs
xtreg y x, fe vce(bootstrap, seed(22)) cluster(clid)

* equivalent call to -bootstrap-
bootstrap, cluster(clid) idcluster(myclid) group(id) seed(22): xtreg y x, fe
***** END:

The last call uses -bootstrap- directly.  Here -bootstrap- needs to know the
name of the clustering variable, a name for its own copy of the cluster
variable, and the name of the panel variable.  This last part, the -group()-
option, allows -bootstrap- to ensure that each replicated panel gets a unique
id.

Passing -cluster()- as a suboption within the -vce(bootstrap)- option was
causing a syntax error because -xtreg, vce(bootstrap)- automatically produces
a -cluster()- option for the panel variable if the -cluster()- option is not
already specified.

We can see how this is very confusing, especially since the -cluster()- option
is no longer documented as an option of -xtreg, fe- (starting in Stata 10).

We will look into making -vce(bootstrap, cluster(...))- work with the panel
data models.

--Jeff
[email protected]
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index