Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Regression with only higher level DV and IVs


From   Stephen Cranney <[email protected]>
To   [email protected]
Subject   Re: st: Regression with only higher level DV and IVs
Date   Sat, 5 Jan 2013 08:02:33 -0500

That works. Thanks!

On Sat, Jan 5, 2013 at 7:23 AM, Nick Cox <[email protected]> wrote:
> You might get away with using -egen- to summarize by school and then
> -egen-'s -tag()- function to select precisely one observation for each
> school.
>
> Here is a silly example to show technique:
>
> . sysuse auto
> (1978 Automobile Data)
>
> . egen wt_mean = mean(weight), by(rep78)
>
> . egen mpg_mean = mean(mpg), by(rep78)
>
> . egen tag = tag(rep78)
>
> . regress mpg_mean wt_mean if tag
>
>       Source |       SS       df       MS              Number of obs =       5
> -------------+------------------------------           F(  1,     3) =  102.35
>        Model |  43.0722735     1  43.0722735           Prob > F      =  0.0021
>     Residual |  1.26244615     3  .420815385           R-squared     =  0.9715
> -------------+------------------------------           Adj R-squared =  0.9620
>        Total |  44.3347197     4  11.0836799           Root MSE      =   .6487
>
> ------------------------------------------------------------------------------
>     mpg_mean |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
>      wt_mean |  -.0078468   .0007756   -10.12   0.002    -.0103151   -.0053785
>        _cons |    45.1725   2.336426    19.33   0.000     37.73695    52.60805
> ------------------------------------------------------------------------------
>
> But getting an appropriate structure need not be as painful as you
> imply: see -collapse-, -contract-.
>
> Nick
>
> On Sat, Jan 5, 2013 at 11:59 AM, Stephen Cranney <[email protected]> wrote:
>
>> I have a dataset with my observations being individual students who
>> are then nested within schools. I am trying to do a regression of
>> school-level dependent variables on school-level indicators.  Is there
>> a quick and easy way to do this without resorting to painful data
>> shaping or tricking the multilevel modelling commands into doing it?
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index