Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Display regression coefficient on line of best fit.

    Hello, I have the following data

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(year isic4 share_emp_vtcs dtariff4)
    2009 1511  .5985916   .05106649
    2009 1512  .2600069  .023178134
    2009 1513  .3360547   .19660795
    2009 1514  .8467643   .08152557
    2009 1520  .5075594   .13006496
    2009 1531 .15860215   .11215407
    2009 1532  .4802343   .10493138
    2009 1533  .6416783   .10042753
    2009 1541  .7655449   .24840233
    2009 1542  .8489155   .03273991
    2009 1543   .301171   .23178187
    2009 1549  .3287467    .1279562
    2009 1551  .6753731   .24869986
    2009 1552  .1594203  .070031784
    2009 1553  .7993433   .12984474
    2009 1554  .3933179    .0456299
    2009 1711 .26305842    .3050913
    2009 1721  .3106218    .3489234
    2009 1722  .9541125    .3764797
    2009 1723 .14457014    .4277458
    2009 1729  .4253579    .4671949
    2009 1730  .4069225    .3525653
    2009 1810 .51055425     .410145
    2009 1820  .3697479    .3599134
    2009 1911 .51023394    .1762842
    2009 1912  .6159144    .2691891
    2009 1920 .38532805   .13966522
    2009 2010  .6839024  .017837364
    2009 2021   .561219   .29634312
    2009 2022  .4940767   .21841544
    2009 2029  .5060908    .2408129
    2009 2101  .4452524    .1211229
    2009 2102  .6041553    .2883826
    2009 2109  .3530499    .2644232
    2009 2221  .3569602   .13789955
    2009 2222 .27885863   .28815684
    2009 2320 .07052897  .006567274
    2009 2411 .23058447   .25861531
    2009 2412   .278481 .0005139682
    2009 2413 .07714561    .2928381
    2009 2421   .494063   .21235652
    2009 2422 .26256752   .18847226
    2009 2423  .5321179   .25465032
    2009 2424     .6886     .486782
    2009 2429  .3775196    .3208537
    2009 2430 .51666665   .29757562
    2009 2511  .6446245   .06587052
    2009 2519  .4455462   .26776266
    2009 2520   .612443    .4104963
    2009 2610 .29254642    .3327981
    2009 2691  .3326858    .3925884
    2009 2692 .03540587   .23777688
    2009 2693  .4552125    .3219824
    2009 2694  .5290272  .034118775
    2009 2695  .6233824   .26435065
    2009 2696  .6816038    .3469207
    2009 2699 .13819286   .22690512
    2009 2710  .4246446   .16239545
    2009 2720 .21868916   .08147526
    2009 2811 .47071415   .29102266
    2009 2812  .6321363    .3087507
    2009 2893  .4898161    .3490838
    2009 2899 .53150415   .28258237
    2009 2911  .6012987   .26550204
    2009 2912  .3102372   .29521146
    2009 2913 .29859155    .3290708
    2009 2919  .6239316   .29378206
    2009 2922 .03899083   .25714236
    2009 2924  .6981402   .29095593
    2009 2926  .6887661    .3019706
    2009 2929  .6629109   .26882306
    2009 2930  .6946635    .3006125
    2009 3000   .992492    .2997462
    2009 3110   .316074   .27915344
    2009 3120   .496732   .27672306
    2009 3130  .5770864    .3221084
    2009 3140  .7474435   .29849935
    2009 3150 .15015975   .26678118
    2009 3190  .7448456   .25384173
    2009 3210   .612806   .29773667
    2009 3220  .0870937    .2986172
    2009 3230  .3424184   .28012133
    2009 3311  .5420916    .3375147
    2009 3313  .8881279    .3173564
    2009 3320  .2477372    .3197464
    2009 3330 .25581396    .4763788
    2009 3410  .3883412   .07587308
    2009 3420  .7344877   .27756408
    2009 3430 .28889427   .20499577
    2009 3511  .8413575   .09678186
    2009 3591  .4920107   .10832929
    2009 3592   .788696   .18719135
    2009 3599  .5852941    .3210694
    2009 3610  .4172966    .3291711
    2009 3691  .6315863    .2690481
    2009 3692  .4601911   .29539734
    2009 3693  .6658833   .29733405
    2009 3694  .6113389    .4451739
    2009 3699  .6050909   .38744685
    end

    and the following code :

    Code:
    reg share_emp_vtcs dtariff4
    scatter share_emp_vtcs dtariff4, mcolor(navy) || lfit share_emp_vtcs dtariff4, ///
        ytitle("Share") ///
        xtitle("ln(1+col2_ave) - ln(1+mfn_ave)") ///
        title("2009") ///
        legend(off) graphregion(color(white))
    I would like to display only the regression coefficient on dtariff4 nicely on the line of best fit in the graph. Please let me know how I can implement this.

    Thanks,
    Jad

  • #2
    Use the text option. You need to fiddle with the positions if you need a hat on top of beta.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(year isic4 share_emp_vtcs dtariff4)
    2009 1511  .5985916   .05106649
    2009 1512  .2600069  .023178134
    2009 1513  .3360547   .19660795
    2009 1514  .8467643   .08152557
    2009 1520  .5075594   .13006496
    2009 1531 .15860215   .11215407
    2009 1532  .4802343   .10493138
    2009 1533  .6416783   .10042753
    2009 1541  .7655449   .24840233
    2009 1542  .8489155   .03273991
    2009 1543   .301171   .23178187
    2009 1549  .3287467    .1279562
    2009 1551  .6753731   .24869986
    2009 1552  .1594203  .070031784
    2009 1553  .7993433   .12984474
    2009 1554  .3933179    .0456299
    2009 1711 .26305842    .3050913
    2009 1721  .3106218    .3489234
    2009 1722  .9541125    .3764797
    2009 1723 .14457014    .4277458
    2009 1729  .4253579    .4671949
    2009 1730  .4069225    .3525653
    2009 1810 .51055425     .410145
    2009 1820  .3697479    .3599134
    2009 1911 .51023394    .1762842
    2009 1912  .6159144    .2691891
    2009 1920 .38532805   .13966522
    2009 2010  .6839024  .017837364
    2009 2021   .561219   .29634312
    2009 2022  .4940767   .21841544
    2009 2029  .5060908    .2408129
    2009 2101  .4452524    .1211229
    2009 2102  .6041553    .2883826
    2009 2109  .3530499    .2644232
    2009 2221  .3569602   .13789955
    2009 2222 .27885863   .28815684
    2009 2320 .07052897  .006567274
    2009 2411 .23058447   .25861531
    2009 2412   .278481 .0005139682
    2009 2413 .07714561    .2928381
    2009 2421   .494063   .21235652
    2009 2422 .26256752   .18847226
    2009 2423  .5321179   .25465032
    2009 2424     .6886     .486782
    2009 2429  .3775196    .3208537
    2009 2430 .51666665   .29757562
    2009 2511  .6446245   .06587052
    2009 2519  .4455462   .26776266
    2009 2520   .612443    .4104963
    2009 2610 .29254642    .3327981
    2009 2691  .3326858    .3925884
    2009 2692 .03540587   .23777688
    2009 2693  .4552125    .3219824
    2009 2694  .5290272  .034118775
    2009 2695  .6233824   .26435065
    2009 2696  .6816038    .3469207
    2009 2699 .13819286   .22690512
    2009 2710  .4246446   .16239545
    2009 2720 .21868916   .08147526
    2009 2811 .47071415   .29102266
    2009 2812  .6321363    .3087507
    2009 2893  .4898161    .3490838
    2009 2899 .53150415   .28258237
    2009 2911  .6012987   .26550204
    2009 2912  .3102372   .29521146
    2009 2913 .29859155    .3290708
    2009 2919  .6239316   .29378206
    2009 2922 .03899083   .25714236
    2009 2924  .6981402   .29095593
    2009 2926  .6887661    .3019706
    2009 2929  .6629109   .26882306
    2009 2930  .6946635    .3006125
    2009 3000   .992492    .2997462
    2009 3110   .316074   .27915344
    2009 3120   .496732   .27672306
    2009 3130  .5770864    .3221084
    2009 3140  .7474435   .29849935
    2009 3150 .15015975   .26678118
    2009 3190  .7448456   .25384173
    2009 3210   .612806   .29773667
    2009 3220  .0870937    .2986172
    2009 3230  .3424184   .28012133
    2009 3311  .5420916    .3375147
    2009 3313  .8881279    .3173564
    2009 3320  .2477372    .3197464
    2009 3330 .25581396    .4763788
    2009 3410  .3883412   .07587308
    2009 3420  .7344877   .27756408
    2009 3430 .28889427   .20499577
    2009 3511  .8413575   .09678186
    2009 3591  .4920107   .10832929
    2009 3592   .788696   .18719135
    2009 3599  .5852941    .3210694
    2009 3610  .4172966    .3291711
    2009 3691  .6315863    .2690481
    2009 3692  .4601911   .29539734
    2009 3693  .6658833   .29733405
    2009 3694  .6113389    .4451739
    2009 3699  .6050909   .38744685
    end
    
    reg share_emp_vtcs dtariff4
    scatter share_emp_vtcs dtariff4, mcolor(navy) || lfit share_emp_vtcs dtariff4, ///
        ytitle("Share") ///
        xtitle("ln(1+col2_ave) - ln(1+mfn_ave)") ///
        title("2009") xsc(range(. .55)) text(.5 .525 "{it:`=ustrunescape("\u03b2")'} = `:di %4.3f _b[dtariff4]'") text(.51 .5005 "{it:`=ustrunescape("\u0302")'}")  ///
        legend(off) graphregion(color(white))

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	34.7 KB
ID:	1753784

    Comment


    • #3
      Thanks!

      Comment

      Working...
      X