Announcement

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

  • Comparing data with similar characteristics.

    Hi everyone. I am new to Stata and would need help. For my thesis, I am trying to compare green and social bonds that differs only from their yield to maturity(YTM). To do so, I matched bonds two by two with similar characteristics (social with its twin green). I couldn't find the right command that compares both types of bonds.
    Example:

    Goup 1
    Social bond issuer A Rating A+ YTM 3%

    Green Bond issuer A Rating A+ YTM 2%

    Group 2:
    Social bond issuer B Rating A YTM 2%

    Green Bond issuer B Rating A YTM 2,5%

    The idea is to calculate the difference in YTM between twin bonds, and then use a command that will compare green vs social bonds as a whole.

    I hope I am clear and thank you very much for your help.

  • #2
    Emna:
    welcome to this forum.
    You may want to consider -regress-, as in the following toy-example:
    Code:
    . set obs 10
    . g Return=10*runiform()
    . gen Group=0
    . expand 2
    . replace Return=10*runiform()+2 in 11/20
    . replace Group=1 in 11/20
    . expand 2
    . replace Return=10*runiform()+5 in 21/30
    . replace Group=2 in 21/30
    . replace Return=10*runiform()+10 in 31/40
    . replace Group=3 in 31/40
    . label define Group 0 "Group_1_Social" 1 "Group_1_Green" 2 "Group_2_Social" 3 "Group_2_Green"
    . label val Group Group
    . regress Return i.Group
    
          Source |       SS           df       MS      Number of obs   =        40
    -------------+----------------------------------   F(3, 36)        =     16.29
           Model |  430.770739         3  143.590246   Prob > F        =    0.0000
        Residual |  317.249603        36  8.81248898   R-squared       =    0.5759
    -------------+----------------------------------   Adj R-squared   =    0.5405
           Total |  748.020342        39  19.1800088   Root MSE        =    2.9686
    
    ---------------------------------------------------------------------------------
             Return | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    ----------------+----------------------------------------------------------------
              Group |
     Group_1_Green  |   2.392001   1.327591     1.80   0.080    -.3004784     5.08448
    Group_2_Social  |   4.133255   1.327591     3.11   0.004     1.440776    6.825735
     Group_2_Green  |   8.953934   1.327591     6.74   0.000     6.261455    11.64641
                    |
              _cons |   5.991451   .9387486     6.38   0.000     4.087581    7.895322
    ---------------------------------------------------------------------------------
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      First, thank you very much for your return! In fact, it is the case.
      But after checking for the function of the command "expand", I am not sure to understand what it actually return?

      Comment


      • #4
        Emna:
        it simply add observations in the very same variable (see -help expand-).
        For instance, if the variabl -A- contains 10 obseravations, -expand 2- will add 10 more observations to -A-.
        It is useful when you create toy-examples.
        You can skip it as I assume you already have a dataset to analyse.
        Just a seidelight to my previous reply: if you have 30-50 observations per each level of -i.Group-, I would consider clustering the standard errors on -Group- variable:
        Code:
         
         regress Return i.Group, vce(cluster Group)
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          It is clear yes and in fact I have 66 Groups of 2 observations each. (66 twins) so it is better to use clustering as you suggested.

          Thank you very much for your reply!
          Last edited by Emna Mezghani; 18 Oct 2022, 03:12.

          Comment

          Working...
          X