Statalist


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

Re: st: Block bootstrapping in quantile regression


From   Austin Nichols <[email protected]>
To   [email protected]
Subject   Re: st: Block bootstrapping in quantile regression
Date   Tue, 17 Nov 2009 07:04:31 -0500

Then try:

clear all
program iqr, eclass
version 10.1
 if replay() {
 syntax [anything] [, Level(real 95) ]
 eret di, level(`level')
 }
 else {
 qui {
syntax [varlist] [, Q1(real .25) Q2(real 0.75) Level(real 95) *]
tab i, gen(_d)
drop _d1
gettoken depv vl:varlist
tempname b1 b2 beta
qreg `depv' `vl' _d*, quantile(`q1') `options'
matrix `b1'=e(b)
tempvar e1 e2
g `e1'=e(sample)
qreg `depv' `vl' _d*, quantile(`q2') `options'
g `e2'=e(sample)&`e1'
count if `e2'
loc N=r(N)
matrix `b2'=e(b)
matrix `beta'=`b2'-`b1'
ereturn post `beta', dep(`depv') e(`e2') obs(`N')
eret local cmd="iqr"
drop _d*
 }
eret di, level(`level')
 }
end
sysuse nlsw88
egen c=group(ind occ), label
drop if mi(c)
bs, rep(20) cl(c) id(i) seed(4):iqr wage age grade


2009/11/16 Jorge Eduardo Pérez Pérez <[email protected]>:
> Thanks for the prompt response. Although the program works for the
> case you posted, it doesn't work for my particular application,
> because I have to include cluster-specific dummies (fixed effects)
>
> sysuse nlsw88, clear
> egen c=group(ind occ), label
> drop if mi(c)
> xi: bs, rep(20) cl(c) seed(4):iqr wage age grade i.c
> Bootstrap replications (20)
> ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
> xxxxxxxxxxxxxxxxxxxx
> insufficient observations to compute bootstrap standard errors
> no results will be saved
> r(2000);
>
> I tried generating the dummy set before instead of using xi in the
> estimation command, and It didn't work either
>
> xi i.c
> bs, rep(20) cl(c) seed(4):iqr wage age grade _I*
>
> Finally, i thought it was because some incompatibilty between the
> cluster() option in bootstrap and including the dummy set, but it is
> not the case either
>
> bs, rep(20) seed(4):iqr wage age grade _I*
>
> Yet using the command without bootstrapping works fine
>
>  xi: iqr wage age grade i.c
>
> I looked at the trace of the command but it is not particularly
> helpful. Could this be due to insufficient iterations for each
> quantile regression in each step of the bootstrap? I tried adding a
> wlsiter(100) option, but  it didn't work either.
>
> Thank you !
> _______________________
> Jorge Eduardo Pérez Pérez
> Joven Investigador
> Facultad de Economía
> Universidad del Rosario
> Calle 14 #4-69 Bogotá, Colombia.
> Tel: (571) 2970200 ext 7836
>
>
>
> On Mon, Nov 16, 2009 at 9:13 PM, Austin Nichols <[email protected]> wrote:
>> clear all
>> program iqr, eclass
>> version 10.1
>>  if replay() {
>>  syntax [anything] [, Level(real 95) ]
>>  eret di, level(`level')
>>  }
>>  else {
>>  qui {
>> syntax [varlist] [, Q1(real .25) Q2(real 0.75) Level(real 95) *]
>> gettoken depv vl:varlist
>> tempname b1 b2 beta
>> qreg `depv' `vl', quantile(`q1') `options'
>> matrix `b1'=e(b)
>> tempvar e1 e2
>> g `e1'=e(sample)
>> qreg `depv' `vl', quantile(`q2') `options'
>> g `e2'=e(sample)&`e1'
>> count if `e2'
>> loc N=r(N)
>> matrix `b2'=e(b)
>> matrix `beta'=`b2'-`b1'
>> ereturn post `beta', dep(`depv') e(`e2') obs(`N')
>> eret local cmd="iqr"
>>  }
>> eret di, level(`level')
>>  }
>> end
>> sysuse nlsw88
>> egen c=group(ind occ), label
>> drop if mi(c)
>> bs, rep(20) cl(c) seed(4):iqr wage age grade
>>
>>
>> 2009/11/16 Jorge Eduardo Pérez Pérez <[email protected]>:
>>> Hi everybody
>>>
>>> I'm trying to estimate an interquantile range regression with
>>> block-bootstrapped standard errors. I've a dataset of cities and
>>> months and i'm trying to estimate a differences in differences model,
>>> so i need the bootstraped s.e's to take into account the
>>> within-cluster correlation. Computation of the regressions using iqreg
>>> is VERY slow, so I tried something like
>>>
>>> program myqreg, eclass
>>> version 11
>>> syntax varlist  [, `options' Q1(real .25) Q2(real 0.75)]
>>> gettoken depv vl : varlist
>>> tempname b1 b2 beta
>>> qui qreg `depv' `vl', quantile(`q1')
>>> matrix `b1'=e(b)
>>> qui qreg `depv' `vl', quantile(`q2')
>>> matrix `b2'=e(b)
>>> matrix `beta'=`b2'-`b1'
>>> ereturn post `beta'
>>> end
>>>
>>> glo seed=4020
>>> bootstrap _b , rep(200) cluster(city) idcluster(icity) seed($seed):
>>> myqreg lwage _Iciudad* _Iañomes* treatment
>>>
>>> However, it doesn't seem to work. Every bootstrap replication fails.
>>>
>>> Any suggestions? Thank you !

*
*   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