Announcement

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

  • How to save slope/beta coefficients from one regression and use after second regression?

    Hey all,

    I have to compare a beta coefficient from one regression with interaction terms (factor-variables) to a beta coefficient from another regression with interaction terms. How can I save the beta coefficients from the first regression?

    My do-file look as follows:
    clear all
    set more off
    import excel "\\studfiles.campus.uvt.nl\files\home\home07\u 1246 790\Master\THESIS\Data\TOTAL REGRESSION DATA.xlsx", sheet("Sheet1") firstrow

    fvset base none ETF Market

    /* Option 1: Per ETF */
    regress TE5 i.ETF##c.VOL i.ETF##c.SKEW i.ETF##c.KURT i.ETF##c.DIV i.ETF##c.PD
    save "\\studfiles.campus.uvt.nl\files\home\home07\u 1246 790\Master\THESIS\Performance Measurement\voorbeeld.dta"
    regress TE5 i.Market##c.VOL i.Market##c.SKEW i.Market##c.KURT i.Market##c.DIV i.Market##c.PD
    append using "\\studfiles.campus.uvt.nl\files\home\home07\u 1246 790\Master\THESIS\Performance Measurement\voorbeeld.dta"
    test i28.ETF#c.PD == i2.Market#c.PD

    And the error is as follows:
    . test i28.ETF#c.PD == i2.Market#c.PD
    variable ETF not found
    r(111);


    Is there a way I can save my slope coefficient from the first regression (i.e. regress TE5 i.ETF##c.VOL i.ETF##c.SKEW i.ETF##c.KURT i.ETF##c.DIV i.ETF##c.PD)

    Thank you in advance



  • #2
    Run -help estimates- and read about -estimates store- and -estimates restore-. -test- will only work with currently posted estimates, so you have to restore the first estimates if you want to -test- something from there.

    Comment


    • #3
      Welcome to the Stata Forum/Statalist.

      Please make sure the command and output are easily readable.

      For this, you may use the CODE delimiters or install the SSC dataex, as recommended in the FAQ.

      Thanks.
      Best regards,

      Marcos

      Comment


      • #4
        Marcos Almeida Thank you, I will!

        Clyde Schechter Thank you. I have tried "estimates", but the problem is that -test- does not work with interaction terms in my case, but -test- does work without interaction terms. How can I solve this problem?

        Comment


        • #5
          Hello Nouschka,

          I wonder whether you have tried to create an interaction variable, instead.
          Best regards,

          Marcos

          Comment


          • #6
            Marcos Almeida Can you explain in more detail what you mean by interaction variables? I have created interaction terms by multiplying a categorical variable by a continuous variable. But those interaction terms are referred to as virtual variables, which mean they act like variables, but do not exist in the dataset. Which is basically my whole problem, because I want those variable in the dataset... How can I solve that?

            Comment


            • #7
              Hello, Noushcka,

              Please see the example below:

              Code:
              . sysuse auto
              (1978 Automobile Data)
              
              . regress mpg i.foreign##c.price
              
                    Source |       SS           df       MS      Number of obs   =        74
              -------------+----------------------------------   F(3, 70)        =     17.17
                     Model |  1035.73441         3  345.244804   Prob > F        =    0.0000
                  Residual |  1407.72505        70  20.1103578   R-squared       =    0.4239
              -------------+----------------------------------   Adj R-squared   =    0.3992
                     Total |  2443.45946        73  33.4720474   Root MSE        =    4.4845
              
              ---------------------------------------------------------------------------------
                          mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
              ----------------+----------------------------------------------------------------
                      foreign |
                     Foreign  |   10.41949   2.914673     3.57   0.001     4.606356    16.23262
                        price |  -.0007723   .0002028    -3.81   0.000    -.0011767   -.0003679
                              |
              foreign#c.price |
                     Foreign  |  -.0008195   .0004248    -1.93   0.058    -.0016667    .0000276
                              |
                        _cons |   24.51661   1.379351    17.77   0.000     21.76558    27.26763
              ---------------------------------------------------------------------------------
              
              . gen for_price = foreign*price
              
              . regress mpg i.foreign c.price for_price
              
                    Source |       SS           df       MS      Number of obs   =        74
              -------------+----------------------------------   F(3, 70)        =     17.17
                     Model |  1035.73441         3  345.244804   Prob > F        =    0.0000
                  Residual |  1407.72505        70  20.1103578   R-squared       =    0.4239
              -------------+----------------------------------   Adj R-squared   =    0.3992
                     Total |  2443.45946        73  33.4720474   Root MSE        =    4.4845
              
              ------------------------------------------------------------------------------
                       mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                   foreign |
                  Foreign  |   10.41949   2.914673     3.57   0.001     4.606356    16.23262
                     price |  -.0007723   .0002028    -3.81   0.000    -.0011767   -.0003679
                 for_price |  -.0008195   .0004248    -1.93   0.058    -.0016667    .0000276
                     _cons |   24.51661   1.379351    17.77   0.000     21.76558    27.26763
              ------------------------------------------------------------------------------
              Hopefully that helps.
              Best regards,

              Marcos

              Comment


              • #8
                Marcos Almeida Yes, it worked!! Thank you very much!

                Comment


                • #9
                  I'm glad it worked well. Please keep in mind that factor notation is preferable to handle interaction terms. With margins, for example, this is a crucial point IMHO, seldom do we need to create an interaction variable, and your case seems to be on of them.
                  Best regards,

                  Marcos

                  Comment

                  Working...
                  X