Hi,

I have a dataset with a continous dependent variable VAR and two binary independent variables. The first is a group identifier (either GROUP = 0 or 1) for two different groups of individuals and the second is a certain signal which group members observe (either SIGNAL = 0 or 1). (The two binary variables are very unevenly distributed: GROUP == 0 observations outweight GROUP == 1 observations by a factor of about 10 and SIGNAL == 0 observations outweight SIGNAL == 1 observations by a factor of about 100.)

I tested for difference in means of VAR by SIGNAL within each group type:

Code:
ttest VAR if GROUP == 1,  by(SIGNAL)

Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 | 102,500     .128273    .0023413    .7495855     .123684    .1328619
       1 |   4,590    .1739551    .0112538    .7624423    .1518922    .1960181
---------+--------------------------------------------------------------------
combined | 107,090     .130231    .0022924    .7501945    .1257378    .1347241
---------+--------------------------------------------------------------------
    diff |           -.0456822    .0113175               -.0678642   -.0235001
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =  -4.0364
Ho: diff = 0                                     degrees of freedom =   107088

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 1.0000
and

Code:
 ttest VAR if GROUP == 0,  by(SIGNAL)

Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 | 1070503    .1266619    .0007386    .7641779    .1252143    .1281095
       1 |   6,347    .1206449    .0098781    .7869672    .1012806    .1400093
---------+--------------------------------------------------------------------
combined | 1076850    .1266264    .0007365     .764314    .1251828      .12807
---------+--------------------------------------------------------------------
    diff |            .0060169    .0096221               -.0128421     .024876
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =   0.6253
Ho: diff = 0                                     degrees of freedom =  1.1e+06

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.7341         Pr(|T| > |t|) = 0.5318          Pr(T > t) = 0.2659

Now, I want to test whether the difference between the two differences is statistically significant.

Can I do this using the ttest command or is there a better approach?

Thanks!