Announcement

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

  • Help on transforming negative variables for interaction analysis

    Dear Stata Forum,

    My problem deals with factor variables that contain negative values. Using regress, I am trying to analyse the interaction (using ##) of percentage point differences (some are negative) and treatment (vs control - i.e., 1 for TC, 0 for CG) on individual behaviour ( a factor variable that is 1 if certain behaviour occurs, if not, it is 0).

    I thought about transforming the percentage point differences to absolute values, but how will I then distinguish between positive and negative numbers, as they could impact my analysis significantly? Wouldn't duplicates skew my analysis as 2 and -2 would now be considered 2? If I then generate another variable that captures the initial sign, i.e., 1 for positive differences and 0 for negative differences, would it make sense to include this as another interaction term in my regression?


    Thank you very much in advance!
    Kind regards,
    Mary Burckhette

  • #2
    I do not see what the issue is here. The treatment variable is the categorical variable whereas percentage differences are continuous. Factor variables do not preclude the existence of an interaction between a categorical variable and a continuous variable with negative values. In any case, for categorical variables, the specific values you assign are arbitrary. Therefore, even if the original coding includes negative values, you can recode the variable, e.g., by adding a constant to each value to make all categories positive. But that is not what you have here from your description.

    Code:
    sysuse auto, clear
    set seed 05062023
    gen pdiff =runiformint(-20, 50)
    regress mpg weight i.foreign##c.pdiff
    Res.:

    Code:
    . regress mpg weight i.foreign##c.pdiff
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(4, 69)        =     33.92
           Model |  1619.69522         4  404.923806   Prob > F        =    0.0000
        Residual |  823.764235        69  11.9386121   R-squared       =    0.6629
    -------------+----------------------------------   Adj R-squared   =    0.6433
           Total |  2443.45946        73  33.4720474   Root MSE        =    3.4552
    
    ---------------------------------------------------------------------------------
                mpg | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    ----------------+----------------------------------------------------------------
             weight |   -.006574   .0006516   -10.09   0.000    -.0078739   -.0052741
                    |
            foreign |
           Foreign  |   -1.55662   1.204219    -1.29   0.200     -3.95897    .8457302
              pdiff |    .003159   .0218691     0.14   0.886    -.0404687    .0467868
                    |
    foreign#c.pdiff |
           Foreign  |  -.0066608   .0374062    -0.18   0.859    -.0812841    .0679624
                    |
              _cons |   41.59432   2.263968    18.37   0.000     37.07783    46.11081
    ---------------------------------------------------------------------------------
    Last edited by Andrew Musau; 06 May 2023, 02:40.

    Comment


    • #3
      Thank you so much, Andrew! The regression worked!

      Comment

      Working...
      X