Announcement

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

  • Hypothesis testing - combined coefficients

    Dear statalisters,

    I have the following regression model with two dummy variables and their interactions.
    Dummy 1: female
    Dummy 2: overweight


    Code:
    Y = female_dum + overweight_dum+ female_dum* overweight_dum
    I will label regression coefficients for the above three regressors as alpha, beta, and gamma. What command should I use to check if the (alpha + gamma) is significantly different from zero?

    Thanks in advance,
    Rochelle

  • #2
    You can use lincom to find the linear combination of the main effects for sex and the sex × overweight interaction term. See below; start at the "Begin here" comment.

    .ÿ
    .ÿversionÿ14.1

    .ÿ
    .ÿclearÿ*

    .ÿsetÿmoreÿoff

    .ÿsetÿseedÿ`=date("2016-01-20",ÿ"YMD")'

    .ÿquietlyÿsetÿobsÿ24

    .ÿ
    .ÿgenerateÿdoubleÿyÿ=ÿrnormal()

    .ÿgenerateÿbyteÿfemaleÿ=ÿmod(_n,ÿ2)

    .ÿgenerateÿbyteÿoverweightÿ=ÿ_nÿ>ÿ_Nÿ/ÿ2

    .ÿ
    .ÿregressÿyÿi.female##i.overweight

    ÿÿÿÿÿÿSourceÿ|ÿÿÿÿÿÿÿSSÿÿÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿMSÿÿÿÿÿÿNumberÿofÿobsÿÿÿ=ÿÿÿÿÿÿÿÿ24
    -------------+----------------------------------ÿÿÿF(3,ÿ20)ÿÿÿÿÿÿÿÿ=ÿÿÿÿÿÿ1.05
    ÿÿÿÿÿÿÿModelÿ|ÿÿ1.54846392ÿÿÿÿÿÿÿÿÿ3ÿÿ.516154639ÿÿÿProbÿ>ÿFÿÿÿÿÿÿÿÿ=ÿÿÿÿ0.3921
    ÿÿÿÿResidualÿ|ÿÿ9.82861008ÿÿÿÿÿÿÿÿ20ÿÿ.491430504ÿÿÿR-squaredÿÿÿÿÿÿÿ=ÿÿÿÿ0.1361
    -------------+----------------------------------ÿÿÿAdjÿR-squaredÿÿÿ=ÿÿÿÿ0.0065
    ÿÿÿÿÿÿÿTotalÿ|ÿÿÿ11.377074ÿÿÿÿÿÿÿÿ23ÿÿ.494655391ÿÿÿRootÿMSEÿÿÿÿÿÿÿÿ=ÿÿÿÿ.70102

    -----------------------------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿyÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿtÿÿÿÿP>|t|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
    ------------------+----------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿ1.femaleÿ|ÿÿÿ.4878984ÿÿÿ.4047347ÿÿÿÿÿ1.21ÿÿÿ0.242ÿÿÿÿ-.3563633ÿÿÿÿÿ1.33216
    ÿÿÿÿÿ1.overweightÿ|ÿÿÿ.7004801ÿÿÿ.4047347ÿÿÿÿÿ1.73ÿÿÿ0.099ÿÿÿÿ-.1437817ÿÿÿÿ1.544742
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    female#overweightÿ|
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ1ÿ1ÿÿ|ÿÿ-.8042479ÿÿÿ.5723813ÿÿÿÿ-1.41ÿÿÿ0.175ÿÿÿÿ-1.998214ÿÿÿÿ.3897185
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿÿÿÿ_consÿ|ÿÿ-.4269302ÿÿÿ.2861906ÿÿÿÿ-1.49ÿÿÿ0.151ÿÿÿÿ-1.023913ÿÿÿÿ.1700531
    -----------------------------------------------------------------------------------

    .ÿ
    .ÿ*
    .ÿ*ÿBeginÿhere
    .ÿ*
    .ÿlincomÿ1.femaleÿ+ÿ1.female#1.overweight

    ÿ(ÿ1)ÿÿ1.femaleÿ+ÿ1.female#1.overweightÿ=ÿ0

    ------------------------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿyÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿtÿÿÿÿP>|t|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
    -------------+----------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿ(1)ÿ|ÿÿ-.3163495ÿÿÿ.4047347ÿÿÿÿ-0.78ÿÿÿ0.444ÿÿÿÿ-1.160611ÿÿÿÿ.5279123
    ------------------------------------------------------------------------------

    .ÿ
    .ÿexit

    endÿofÿdo-file


    .

    Comment


    • #3
      A likely reason you are interested in this particular sum of coefficients is that it represents the marginal effect of female conditional on overweight. If so, another way to get this is

      Code:
      margins, dydx(female) at (overweight = 1)
      The -lincom- approach is more direct, but the -margins- approach is more directly related to how you are thinking about this sum and is easy to generalize to other similar situations.

      Comment


      • #4
        @Joseph, Thank you for your detailed example !!!! this is the first time I saw the use of lincom. Your solution works great !

        @ Clyde: Thank you for helping out again !!! I read up on margins command. Your solution is what I am looking for.


        Sincerely,
        Rochelle

        Comment


        • #5
          @Joseph, sorry to trouble you again:

          Code:
          regress y i.female##i.overweight
          I got the same output as yours

          then,
          Code:
          lincom l.female+l.female#l.overweight
          i have an error

          Code:
          regressor � not found

          Comment


          • #6
            Change
            Code:
            lincom l.female+l.female#l.overweight
            to
            Code:
            lincom 1.female+1.female#l.overweight
            That is, use ones and not ells.

            Comment


            • #7
              And you also need a one, not an ell, for the interaction term.

              Comment


              • #8
                Thank you Joseph and Clyde for pointing out my error !

                I very much appreciated it.

                Rochelle

                Comment

                Working...
                X