Hello, what is the code to compare between two regression coefficients using t-test
-
Login or Register
- Log in with
. sysuse auto.dta (1978 automobile data) . regress price mpg trunk Source | SS df MS Number of obs = 74 -------------+---------------------------------- F(2, 71) = 10.14 Model | 141126459 2 70563229.4 Prob > F = 0.0001 Residual | 493938937 71 6956886.44 R-squared = 0.2222 -------------+---------------------------------- Adj R-squared = 0.2003 Total | 635065396 73 8699525.97 Root MSE = 2637.6 ------------------------------------------------------------------------------ price | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- mpg | -220.1649 65.59262 -3.36 0.001 -350.9529 -89.3769 trunk | 43.55851 88.71884 0.49 0.625 -133.3418 220.4589 _cons | 10254.95 2349.084 4.37 0.000 5571.01 14938.89 ------------------------------------------------------------------------------ . test mpg=trunk ( 1) mpg - trunk = 0 F( 1, 71) = 12.87 Prob > F = 0.0006 . lincom mpg - trunk ( 1) mpg - trunk = 0 ------------------------------------------------------------------------------ price | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- (1) | -263.7234 73.5159 -3.59 0.001 -410.3099 -117.1368 ------------------------------------------------------------------------------ .
sysuse auto.dta . reg price c.mpg##i.foreign Source | SS df MS Number of obs = 74 -------------+---------------------------------- F(3, 70) = 9.48 Model | 183435281 3 61145093.6 Prob > F = 0.0000 Residual | 451630115 70 6451858.79 R-squared = 0.2888 -------------+---------------------------------- Adj R-squared = 0.2584 Total | 635065396 73 8699525.97 Root MSE = 2540.1 ------------------------------------------------------------------------------- price | Coefficient Std. err. t P>|t| [95% conf. interval] --------------+---------------------------------------------------------------- mpg | -329.2551 74.98545 -4.39 0.000 -478.8088 -179.7013 | foreign | Foreign | -13.58741 2634.664 -0.01 0.996 -5268.258 5241.084 | foreign#c.mpg | Foreign | 78.88826 112.4812 0.70 0.485 -145.4485 303.225 | _cons | 12600.54 1527.888 8.25 0.000 9553.261 15647.81 ------------------------------------------------------------------------------- . mat list e(b) e(b)[1,6] 0b. 1. 0b.foreign# 1.foreign# mpg foreign foreign co.mpg c.mpg _cons y1 -329.25507 0 -13.587408 0 78.888255 12600.538 . lincom (0b.foreign+0b.foreign#co.mpg)-(1.foreign+1.foreign#co.mpg) ( 1) 0b.foreign - 1.foreign + 0b.foreign#co.mpg - 1.foreign#c.mpg = 0 ------------------------------------------------------------------------------ price | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- (1) | -65.30085 2526.435 -0.03 0.979 -5104.116 4973.514 ------------------------------------------------------------------------------ .
* Example generated by -dataex-. To install: ssc install dataex clear input float(Quality green brown SIZE) -.023498783 . . 13.259064 -.04692965 . -.2446 13.569432 -.04860371 . -.3123 15.105076 . . . . -.02689968 . -.1947 16.305819 -.10176031 . . 13.618954 -.0828585 . . 14.658607 . . . . -.015844844 .2016 . 18.38984 . . . . -.012508074 . -.22 15.67468 -.06576106 . -.4193 15.28486 -.10900471 . . 13.461156 -.04421114 . -.2358 16.230042 -.06064047 . . 12.04105 -.0840023 . -.0765 13.60215 -.09142987 .1034 . 12.72466 -.02763558 . . 14.44713 -.06822613 . . . -.07659444 . . 13.439718 -.02508457 . . 11.168207 -.10666119 . -.4175 15.79195 -.06840717 . -.1121 14.878547 -.011925415 . -.3017 14.86093 -.10588618 . . 14.823525 -.04781695 . -.1684 14.893375 -.04020242 . -.2402 17.383379 -.020710016 . . 16.073341 -.10175898 . . 13.751846 -.09382027 . . 15.056574 -.05675267 .1838 . 16.072336 -.06355513 .1967 . 16.058983 -.09535021 . -.332 15.86111 . . . . -.07131862 . -.2379 15.943108 -.05375332 . . 12.790956 -.13221191 . . 13.98439 -.1091644 . . 14.5308 -.12223452 .0658 . 18.38984 -.034990136 . . 10.951087 . . . . -.09104384 . . 13.654697 -.0537772 . -.2774 17.266705 . . . . -.13631308 . . 12.994676 -.02458645 .2012 . 18.38984 -.035449382 . -.3014 14.73208 -.08436283 . -.3456 13.689683 . . . . -.05060596 . . 18.38984 -.19048506 . . 13.128886 -.08916418 . . 13.336082 -.14970775 . . 14.118113 -.05141915 . -.0407 17.211285 -.13723621 . -.1248 13.560867 -.10945213 . -.1814 13.60244 -.0797871 . . 14.359032 -.033043083 . . 13.967512 -.06982245 . . 13.56478 -.014638564 . -.2011 17.244064 -.018109797 . . 15.453828 -.04712491 . . 12.940494 -.07557642 . -.2246 14.75085 . . . . -.04852199 . . 13.014318 -.04596049 . . 11.283085 -.06070792 .0861 . 15.679855 -.05885315 . . 12.741495 -.04884082 . . 14.349708 -.065595314 . . 12.88035 -.06822452 . -.043 14.8816 -.018667955 . . 12.53987 -.05273695 . -.0861 14.634684 -.11064856 . -.3254 12.936993 -.04161104 . . 14.200109 -.04297802 . . 15.278043 -.02390868 . -.2583 16.257566 -.1600706 . . 14.006145 . . . 11.133435 -.063129105 . . 11.755165 -.1822904 . . 10.510886 -.04943193 .0653 . 17.63981 -.04682806 . -.3785 15.085893 -.07877155 . -.0658 14.462242 -.02141324 . . 13.635972 -.02927202 . . 15.84666 -.12802325 . . 11.962395 . . . . -.10383837 . -.2313 15.46607 -.03622859 . -.0418 16.531675 -.02274577 . -.1936 14.094083 -.030762667 . . 12.615934 . . . 13.589437 -.0384847 . -.1754 12.645885 -.017075129 . -.2707 14.179723 -.08459768 . -.3994 15.067476 -.02081717 . . 14.31284 -.014353865 .1628 . 15.09948 -.03222968 . -.1756 14.639038 -.021212853 . -.338 17.669416 end
. gen green_brown=green if green!=. . replace green_brown=brown if brown!=. . g indicator=0 if green!=. . replace indicator=1 if brown!=. . regress Quality c.green_brown##i.indicator SIZE . regress Quality c.green_brown##i.indicator SIZE, allbase Source | SS df MS Number of obs = 45 -------------+---------------------------------- F(4, 40) = 2.22 Model | .008460312 4 .002115078 Prob > F = 0.0835 Residual | .038024205 40 .000950605 R-squared = 0.1820 -------------+---------------------------------- Adj R-squared = 0.1002 Total | .046484517 44 .001056466 Root MSE = .03083 ----------------------------------------------------------------------------------------- Quality | Coefficient Std. err. t P>|t| [95% conf. interval] ------------------------+---------------------------------------------------------------- green_brown | .3528698 .1830436 1.93 0.061 -.0170751 .7228147 | indicator | 0 | 0 (base) 1 | .060665 .0303915 2.00 0.053 -.0007584 .1220885 | indicator#c.green_brown | 0 | 0 (base) 1 | -.3361346 .1895475 -1.77 0.084 -.7192244 .0469552 | SIZE | .0069765 .0032989 2.11 0.041 .0003092 .0136437 _cons | -.2201662 .0594042 -3.71 0.001 -.3402265 -.1001059 ----------------------------------------------------------------------------------------- . mat list e(b) e(b)[1,7] 0b. 1. 0b.indicator# 1.indicator# green_brown indicator indicator co.green_b~n c.green_br~n SIZE _cons y1 .35286979 0 .06066501 0 -.3361346 .00697646 -.22016619 . lincom(green_brown)-(green_brown+1.indicator#c.green_brown) ( 1) - 1.indicator#c.green_brown = 0 ------------------------------------------------------------------------------ Quality | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- (1) | .3361346 .1895475 1.77 0.084 -.0469552 .7192244 ------------------------------------------------------------------------------ .
Comment