Michael Ash
>
> A colleague is trying to compute a locally-weighted
> regression with bootstrapped standard errors or confidence
> intervals.
>
> We are following ex3-8.do and ex4-1.do in Deaton's excellent
> Analysis of Household Surveys. See
> http://www.worldbank.org/lsms/tools/deaton/ for more about
> the book and the programs.
>
> I have two questions:
>
> 1) Is there a canned way to to compute a locally-weighted
> regression with bootstrapped standard errors or confidence
> intervals in Stata, for example, with ksm and bstrap.
>
> 2) Does anyone familiar with Deaton's book know if there is
> a typo in the code for the lowrex program (the core of the
> locally-weighted regression estimation), in particular, at
> line 12,
> reg `1' `2' =kz if kz ~= .; SHOULD PERHAPS READ
> reg `1' `2' [weight=kz] if kz ~= .;
>
> cap program drop lowrex;
> program def lowrex;
> local ic=1;
> gen `3'=.;
> gen `4'=.;
> while `ic' <= $gsize {;
> dis `ic';
> quietly {;
> local xx=`6'[`ic'];
> gen z=abs((`2'-`xx')/`5');
> gen kz=(15/16)*(1-z^2)^2 if z <= 1;
> reg `1' `2' =kz if kz ~= .;
> replace `4'=_b[`2'] in `ic';
> * replace `3'=_b[_cons]+_b[`2']*`xx' in `ic';
> drop z kz;
> };
> local ic=`ic'+1;
> };
> end;
>
It is not so much a typo as an instance of
a syntax change. The syntax for weights
changed a way back from what Deaton
uses here to what you use.
Note also that this program does not
use a -version- statement, and that
the inequality
~= .
will not yield what you
want in Stata 8 if you also make use
of the missing values .a ... .z. The
inequality
< .
is now officially recommended -- and incidentally
has long been recommended by Tony Lachenbruch
and myself as a keystroke saver.
(The program could also be modernised in other
ways, but unless it is very slow for you, that
it is not a issue. Finally, I don't see any case
for using ; as a delimiter here, but that's pure
prejudice.)
Nick
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/