Statalist


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

Re: st: Logit and the Clustered Bootstrap


From   Austin Nichols <[email protected]>
To   [email protected]
Subject   Re: st: Logit and the Clustered Bootstrap
Date   Sun, 30 Aug 2009 06:06:38 -0400

Jeff--
But if you choose to ignore any incidental parameters problem with
-logit-, and you want to resample clusters and include dummies for
clusters, you can generate new dummy variables for each distinct value
of the idcluster variable, right?  (A better approach is possible in
Stata11, but the below works in pre-11 and 11, I think.)

clear all
prog lfe, eclass
if replay() {
 syntax [anything] [, EForm(string) Level(real 95) ]
 eret di, eform(`eform') level(`level')
 }
else {
 syntax [varlist] [, EForm(string) Level(real 95) ]
 tempvar s
 qui tab i, g(_d)
 drop _d1
 qui logit `varlist' _d*
 g `s'=e(sample)
 drop _d*
 mat b=e(b)
 mat B=b[1,1..2]
 mat  v=e(V)
 mat V=v[1..2,1..2]
 eret post B V, e(`s')
 eret local cmd "lfe"
 eret local properties "b V"
 eret di, eform(`eform') level(`level')
}
end

webuse psidextract, clear
keep if id<51
tsset, clear
set seed 123
bs, rep(20) cluster(id) idcluster(i): lfe union exp wks


Not that this is a good idea...  just that it is feasible.


On Fri, Aug 28, 2009 at 6:23 PM, Jeff Pitblado, StataCorp
LP<[email protected]> wrote:
> L S <[email protected]> is -bootstrap- with -logit-, while clustering on a
> state variable whose level-indicators are also in the list of independent
> variables:
>
>> I am trying to perform a clustered bootstrap in which I also include
>> fixed effects for the variable serving as the cluster identifier.  For
>> cross-sectional data on individuals in different states, I would like
>> to do a bootstrap that clusters by state, but also includes state
>> fixed effects.
>>
>> A difficulty with doing this is that this often doesn’t seem to work
>> with logit.  Here is some code that illustrates the point:
>>
>> clear
>> set more off
>> sysuse citytemp
>>
>> forvalues i = 2/9{
>>       gen z`i'=(division==`i')
>> }
>>
>> gen round_heatdd = round(heatdd)
>>
>> gen odd = mod(round_heatdd,2)
>> drop if odd==.
>>
>> reg odd tempjan z2-z9, cluster(division)
>> logit odd tempjan z2-z9, cluster(division)
>> bootstrap, cluster(division) reps(200) seed(1234): reg odd tempjan z2-z9
>> bootstrap, cluster(division) reps(200) seed(1234): logit odd tempjan z2-z9
>>
>> Reg and Logit each run fine with clustered standard errors in
>> non-bootstrapped form, as does the Reg bootstrap.  For the logit
>> bootstrap, the following error arises:
>>
>> “insufficient observations to compute bootstrap standard errors
>> no results will be saved”
>>
>> In other examples with logit and cluster-level fixed effects, STATA
>> will actually run through completely, but with the bootstrap working
>> on a small number of replications (instead of on zero).  For example,
>> if one includes only some of the fixed effects, this will occur:
>>
>> bootstrap, cluster(division) reps(200) seed(1234): logit odd tempjan z2-z5
>>
>> Does anyone know what is causing the bootstrap to fail to run normally
>> here?  Is there anything I can do so that the logit with a clustered
>> bootstrap will run?
>
> Austin Nichols <[email protected]> replied with the URL for an old
> Statalist post that mentions -bootstrap-'s -idcluster()- option.
>
> There is a fundamental reason why -bootstrap- cannot be used this way.
>
> The clustered bootstrap samples the clusters randomly, so the fixed-effects
> dummies are not identified in all draws.  Here is an example.  Suppose you
> have 50 states, your first bootstrap sample might only include two versions of
> the even numbered states, in which case none of the fixed effects for the odd
> numbered states are identified.
>
> In Stata 11, all the replication methods now check for indep vars that are
> 'omitted' because of collinearity (indicator variables that are all 0 will be
> dropped because of collinearity), so the above examples of -bootstrap- will
> behave consistently across all estimation commands.
>
> --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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index