Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: Regression with subject-level means and aweights VS full regression


From   J Taylor <jwtayl@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Regression with subject-level means and aweights VS full regression
Date   Sun, 9 Sep 2012 22:32:21 -0400

If I have multiple observations per person, shouldnt it be the case
that running a regression on subject-level means weighted by
observations per person gives the same result as running a regression
on the full dataset?  Unfortunately, in the below, it seems that I am
getting different answers.

Any thoughts on why this is occurring?  I believe that I am using the
aweights correctly, weighting by the number of observations per
person?

Thank you,
JT

-------------------------

clear
set more off
set seed 1234

set obs 100

gen sid = _n
gen truex = uniform()
gen truey = .2 + .4*truex

gen obspersub = ceil(10*uniform())
expand obspersub

gen x = truex + uniform()
gen y = truey + uniform()

reg y x, cluster(sid)

preserve
	collapse y x obspersub, by(sid)
	reg y x [aw=obspersub]
restore

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