Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Calculating Percent Change In Regression Coeffecients


From   "Tim Wade" <wadetj@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Calculating Percent Change In Regression Coeffecients
Date   Tue, 30 May 2006 10:10:50 -0400

Hi Raphael, I don't know how to do this in Mata, but here is a brute
force solution using macros and for loops:


. regress price headroom rep78 gear_ratio

     Source |       SS       df       MS              Number of obs =      69
-------------+------------------------------           F(  3,    65) =    4.68
      Model |   102521828     3  34173942.7           Prob > F      =  0.0051
   Residual |   474275131    65  7296540.47           R-squared     =  0.1777
-------------+------------------------------           Adj R-squared =  0.1398
      Total |   576796959    68  8482308.22           Root MSE      =  2701.2

------------------------------------------------------------------------------
      price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
   headroom |  -136.9778   414.9107    -0.33   0.742    -965.6117    691.6561
      rep78 |   576.2363   362.8717     1.59   0.117    -148.4686    1300.941
 gear_ratio |  -2995.126   829.7523    -3.61   0.001    -4652.256   -1337.996
      _cons |   13577.64   3025.567     4.49   0.000     7535.166    19620.12
------------------------------------------------------------------------------

/*only include coefficients you want to compare*/

. foreach var of varlist headroom rep78 {
 2. local `var'1=_b[`var']
 3. }

. regress price headroom rep78

     Source |       SS       df       MS              Number of obs =      69
-------------+------------------------------           F(  2,    66) =    0.43
      Model |  7450346.06     2  3725173.03           Prob > F      =  0.6511
   Residual |   569346613    66  8626463.83           R-squared     =  0.0129
-------------+------------------------------           Adj R-squared = -0.0170
      Total |   576796959    68  8482308.22           Root MSE      =  2937.1

------------------------------------------------------------------------------
      price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
   headroom |   391.6261   422.1074     0.93   0.357    -451.1385    1234.391
      rep78 |   69.23416   363.8024     0.19   0.850    -657.1208    795.5892
      _cons |   4735.368   1930.863     2.45   0.017      880.276    8590.459
------------------------------------------------------------------------------

. foreach var of varlist headroom rep78 {
 2. local `var'2=_b[`var']
 3. }

. foreach var of varlist headroom rep78 {
 2. di as result "percent change for `var'="((``var'2'-``var'1')/``var'1')*100
 3. }
percent change for headroom=-385.90483
percent change for rep78=-87.985109


Tim




On 5/26/06, Raphael Fraser <raphael.fraser@gmail.com> wrote:
I would like to calculate the percentage change in the regression
coeffecients of model 1 and model 2. Can any one help? I tried using
Mata but I did not know how to divide each element in a matrix with
different scalars.

sysuse auto, clear
stset mpg, failure(foreign)
stcox mpg price weight rep78, nohr nolog /*Model 1*/
stcox mpg weight rep78, nohr nolog /*Model 2*/

For example % change = (rep78_m2 - rep78_m1) / rep78_m1
*
*   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