Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Saving slope and y-intercept from "by" regression


From   "Nick Winter" <nwinter@policystudies.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Saving slope and y-intercept from "by" regression
Date   Mon, 22 Jul 2002 12:33:13 -0400

The -statsby- command should do the trick for you.

Nick Winter

> -----Original Message-----
> From: Dale Steele [mailto:Dale_Steele@brown.EDU] 
> Sent: Monday, July 22, 2002 12:29 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: Saving slope and y-intercept from "by" regression
> 
> 
> Given the dataset below, for each idnum, I would like to 
> create two new
> variables which summarize the least squares relationship 
> between lcresponse
> and lresistnc.   Ie. newvar1=slope, newvar2 = y-intercept.
> 
> The following command using "by" generates regression output 
> for each idnum:
>     by idnum: regress lcresponse lresistnc
> 
> However, I'm stuck on how to  save the slope '_b[lresistnc]'
> and yint '-b[_cons]' as new variables for each idnum.
> 
>     Thanks...
> 
> 
>          idnum  lcresponse    lresistnc
>   1.       401          .          .
>   2.       401   .3579348     .39794
>   3.       401   .5587085     .69897
>   4.       401   .6627578          1
>   5.       401    .888741    1.30103
>   6.       401    .923244   1.477121
>   7.       402          .          .
>   8.       402   .0253059     .39794
>   9.       402    .071882     .69897
>  10.       402   .5658478          1
>  11.       402    .748188    1.30103
>  12.       402   .9314579   1.477121
>  13.       500          .          .
>  14.       500    -.39794     .39794
>  15.       500   .2741579     .69897
>  16.       500   .4183013          1
>  17.       500   .7041505    1.30103
>  18.       500   .7512791   1.47712
> ...
> 
> . by idnum: regress lcresponse lresistnc
> 
> ______________________________________________________________
> ______________
> ___
> -> idnum = 401
> 
>       Source |       SS       df       MS              Number of obs =
> 5
> -------------+------------------------------           F(  1,     3) =
> 180.84
>        Model |  .217846518     1  .217846518           Prob > F      =
> 0.0009
>     Residual |  .003613953     3  .001204651           R-squared     =
> 0.9837
> -------------+------------------------------           Adj R-squared =
> 0.9782
>        Total |  .221460472     4  .055365118           Root MSE      =
> .03471
> 
> --------------------------------------------------------------
> --------------
> --
>   lcresponse |      Coef.   Std. Err.      t    P>|t|     [95% Conf.
> Interval]
> -------------+------------------------------------------------
> --------------
> --
>    lresistnc |   .5325099   .0395989    13.45   0.001     .4064885
> .6585312
>        _cons |   .1590736   .0416127     3.82   0.032     .0266434
> .2915037
> --------------------------------------------------------------
> --------------
> --
> ...
> 
> 
> 
> 
> *
> *   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/
> 
*
*   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/



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