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

st: Odd iweights + regress behavior

From   "Schaffer, Mark E" <>
To   <>
Subject   st: Odd iweights + regress behavior
Date   Thu, 10 Dec 2009 14:29:08 -0000

Hi all.  I have a question about the behavior of -regress- with
iweights.  It  seems peculiar to me, and isn't documented anywhere I can
find, and I wonder if anyone can see any logic to it.

The behavior is the treatment of the sample size.  Iweights are not
normalized, and in principle the sample size N can take non-integer

If I recall correctly, Stata allows only integer values of N to be
posted with the obs() option of -ereturn-.  If iweights generates a
non-integer N, -regress- rounds down before posting.  That makes sense
to me.

But what I don't understand is why -regress- seems to use the same
rounded-down N for calculations of things like the var-cov matrix and
the error variance.  Wouldn't it make sense to use the more precise,
unrounded N when calculating them?

In practice, iweights are, I think, used mostly by programmers, so this
is probably relevant only to those who are using -regress- to produce
these things.

An example using the toy auto dataset is below.

I am using Stata 11 but this behavior of -regress- appears in earlier
versions of Stata as well.


Prof. Mark E. Schaffer FRSE
Department of Economics
School of Management & Languages
Heriot-Watt University
Edinburgh EH14 4AS  UK
44-131-451-3494 direct
44-131-451-3296 fax

*********** EXAMPLE **************

. sysuse auto, clear
(1978 Automobile Data)

. qui reg mpg weight [iweight=headroom]

. predict double e, resid

. gen double e2=e^2

. qui sum e2 [iweight=headroom], meanonly

. di r(sum_w)

. di e(N)

. scalar s2unrounded=r(sum)/(221.5-2)

. scalar s2rounded  =r(sum)/(221-2)

. di sqrt(s2unrounded)

. di sqrt(s2rounded)

. di e(rmse)

. mat accum XX = weight [iweight=headroom]

. mat XXinv=syminv(XX)

. mat Vunrounded = XXinv*s2unrounded

. mat list Vunrounded

symmetric Vunrounded[2,2]
            weight       _cons
weight   8.109e-08
 _cons  -.00025336   .83926154

. mat Vrounded = XXinv*s2rounded

. mat list Vrounded

symmetric Vrounded[2,2]
            weight       _cons
weight   8.128e-08
 _cons  -.00025394   .84117766

. mat list e(V)

symmetric e(V)[2,2]
            weight       _cons
weight   8.128e-08
 _cons  -.00025394   .84117766

Heriot-Watt University is a Scottish charity
registered under charity number SC000278.

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index