Statalist


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

Re: st: AW: Weighted Least Squares - wls0


From   Eva Poen <eva.poen@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: AW: Weighted Least Squares - wls0
Date   Fri, 20 Feb 2009 13:55:17 +0000

There is no need to check the temporary variables. The weights are
calculated as w=1/x, where x is the linear prediction. If x is
negative, so is w. -wls0- generates two new variables, one of which
holds the weights. -sum _wls_wgt- after estimation shows for which
observations the weights are negative.

Eva


2009/2/20 Martin Weiss <martin.weiss1@gmx.de>:
>
> <>
>
> If you add a -pause- before line 76 and look up the temps via -edit- you see
> that the last temp "__000000  float  %9.0g  Fitted values" has a couple of
> negative values - at least for my earlier example- If you
>
> *************
> cou if  __000000<0
> *************
>
> at that moment you see that those are the ones Stata omits later on...
>
>
> HTH
> Martin
>
>
> -----Ursprüngliche Nachricht-----
> Von: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Eva Poen
> Gesendet: Freitag, 20. Februar 2009 14:30
> An: statalist@hsphsun2.harvard.edu
> Betreff: Re: st: AW: Weighted Least Squares - wls0
>
> Further on this:
>
> The crucial line in the ado appears to be
>
> generate _wls_wgt = 1/(`p1')
>
> where `p1' is the linear prediction from an auxiliary linear
> regression (which may, of course, be negative, depending on the data).
> This applies to weight types abse and e2. I don't know if this
> calculation corresponds to what one can find in textbooks (I haven't
> checked).
>
> In addition to this, it seems that -wls0- is a little sloppy with
> handling [if] and [in] conditions (they are not applied to predictions
> and auxiliary regressions in the code).
>
> It is of course possible that there is an enhanced version of -wls0-
> out there, but invisible to -findit-.
>
> Eva
>
>
> 2009/2/20  <Phil1899@gmx.de>:
>> Hi,
>>
>> thanks for your answers.
>>
>> Nick - the reason why you cannot find it might be that I mixed up two
> letters in my first mail; it is wls0, and not wsl0. There should be no
> problem in finding it.
>>
>> Martin - it is exactly the same in my case, STATA drops observations when
> I use "e2" or "abse". But if you say that I should not be concerned about
> the "restriction", I am a little reliefed as I get quite nice results with
> respect to the fitted values vs. residual plot in case of e2.
>>
>> If someone knows the reason behind this restriction, I would still be very
> interested in learning about it.
>>
>> Best
>>
>> Phil
>>
>>
>> -------- Original-Nachricht --------
>>> Datum: Fri, 20 Feb 2009 13:48:06 +0100
>>> Von: "Martin Weiss" <martin.weiss1@gmx.de>
>>> An: statalist@hsphsun2.harvard.edu
>>> Betreff: st: AW: Weighted Least Squares - wls0
>>
>>>
>>> <>
>>>
>>> Phil, although I do have a hard time telling why Stata uses less
> variables
>>> for certain wls types here, you should not say that they have been
>>> dropped.
>>> That would be cause for concern indeed. Instead, Stata simply restricts
>>> the
>>> estimation sample, just as it would if you passed it the -if- qualifier.
>>> It
>>> does that for "abse" and "e2" in my example...
>>>
>>>
>>> *****
>>> use http://www.ats.ucla.edu/stat/stata/ado/analysis/hetdata, clear
>>> foreach type in abse absen e2 loge2 xb2{
>>> wls0 exp age ownrent income incomesq, wvar(income incomesq) type(`type')
>>> }
>>> *****
>>>
>>>
>>>
>>> HTH
>>> Martin
>>>
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: owner-statalist@hsphsun2.harvard.edu
>>> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von
>>> Phil1899@gmx.de
>>> Gesendet: Freitag, 20. Februar 2009 12:30
>>> An: statalist@hsphsun2.harvard.edu
>>> Betreff: st: Weighted Least Squares - wls0
>>>
>>> Dear Statlist,
>>>
>>> I have a problem with weighted least squares where I cannot find a
>>> solution
>>> to. I use the wsl0 command to obtain the results; however, there are two
>>> things I am confused about:
>>>
>>> First, for some reason STATA drops observations when I use certain weight
>>> types. STATA does not give any documentation about this; however, the
>>> number
>>> of observations is significantly lower according to the output table.
> Does
>>> anybody has an idea why STATA does that?
>>>
>>> Second, when I use squared fitted values (xb2) as weighting type, I get
>>> the
>>> same fitted value vs. residual plot independent of the variable(s) I
>>> weight
>>> proportionally to. Is this normal?
>>>
>>> I would appreciate any help,
>>>
>>> Best regards
>>>
>>> Phil

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index