Announcement

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

  • Standard error of differences of the mean - Stata

    Hello Forum,

    I have data on prices and I am trying to pull off a difference coefficient. So, I have the mean price for product X for Nov 13, Dec 13, Jan 14 and Feb 14.
    I wanted to see the difference between mean prices of 2013 and 2014.

    So, in order to get the difference in means I get the price means of Jan 14 and Feb 14 and divided by two and subtract with the means price of Nov 13 and Dec 13 divided by two as well.

    I see this in a paper.
    However, they also reported standard error of this transformation.

    Does anyone know how to get the sd. error?

    You help is very much appreciated.
    Thank you!

    Lena




  • #2
    See the example below with some made up data. Hope it helps.
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float prod_x byte(year month)
    5.2 1 1
    5.4 1 2
    6.3 2 1
    6.5 2 2
    end
    
    . mean prod_x, over(year)
    
    Mean estimation                   Number of obs   =          4
    
                1: year = 1
                2: year = 2
    
    --------------------------------------------------------------
            Over |       Mean   Std. Err.     [95% Conf. Interval]
    -------------+------------------------------------------------
    prod_x       |
               1 |        5.3   .1000001      4.981755    5.618245
               2 |        6.4   .0999999      6.081756    6.718244
    --------------------------------------------------------------
    
    . lincom [prod_x]2 - [prod_x]1
    
     ( 1)  - [prod_x]1 + [prod_x]2 = 0
    
    ------------------------------------------------------------------------------
            Mean |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             (1) |        1.1   .1414214     7.78   0.004     .6499342    1.550066
    ------------------------------------------------------------------------------
    Last edited by Wouter Wakker; 20 Jul 2019, 10:06.

    Comment


    • #3
      Lena:
      elaborating on Wouter's helpful example:
      Code:
      . regress prod_x i.year, vce(cluster month )
      
      Linear regression                               Number of obs     =          4
                                                      F(0, 1)           =          .
                                                      Prob > F          =          .
                                                      R-squared         =     0.9680
                                                      Root MSE          =     .14142
      
                                        (Std. Err. adjusted for 2 clusters in month)
      ------------------------------------------------------------------------------
                   |               Robust
            prod_x |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
            2.year |        1.1   2.92e-07  3.8e+06   0.000     1.099996    1.100004
             _cons |        5.3   .1224747    43.27   0.015     3.743812    6.856188
      ------------------------------------------------------------------------------
      
      . mat list e(b)
      
      e(b)[1,3]
                 1b.         2.          
               year       year      _cons
      y1          0  1.1000001        5.3
      
      . test _cons+2.year=0
      
       ( 1)  2.year + _cons = 0
      
             F(  1,     1) = 2730.67
                  Prob > F =    0.0122
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        Thank you both! Very helpful

        Comment

        Working...
        X