title: R - DiD (Difference in DIfference) Model
body: <p>I'm trying to set up a DiD model with R. I have a baseline phase and a treatment group. I'm trying to consider baseline and age fluence in the model. So I created two dummy variables. </p>
  
  <pre><code>young &lt;- Shower_data$Age %in% c("20-29", "30-39")
  old &lt;- Shower_data$Age %in% c("40-49", "50-64", "65+")
  
  Shower_data$young_pos &lt;- ifelse(Shower_data$young&gt;0, 1, 0)
  Shower_data$young_neg &lt;- ifelse(Shower_data$young&lt;=0, 1, 0)
  
  Shower_data$young_pos &lt;- 1
  Shower_data$young_pos [ old ] &lt;- 0
  Shower_data$young_neg &lt;- 0
  Shower_data$young_neg [ old ] &lt;- 1
  
  #Create a model that considers the baseline and age
  model4 &lt;- lm(Volume ~ (Shower + dummy_phase * dummy_exp_group) * (young_pos + young_neg), data = Shower_data)
  summary(model4)
  </code></pre>
  
  <p>Without the age everything went as expected, but when I add the age I only get results for <code>young_pos</code> variable but not for the <code>young_neg</code>. As you can see here:</p>
  
  <pre><code>#Coefficients: (5 not defined because of singularities)
  #                                               Estimate Std. Error t value Pr(&gt;|t|)    
  #(Intercept)                                    45.07006    1.65499  27.233  &lt; 2e-16 ***
  #Shower                                         -0.04725    0.00819  -5.769 8.09e-09 ***
  #dummy_phase                                    -5.35647    1.72401  -3.107  0.00189 ** 
  #dummy_exp_grouptreatment                       -9.33660    1.95433  -4.777 1.79e-06 ***
  #young_pos                                       8.11264    2.78459   2.913  0.00358 ** 
  #young_neg                                            NA         NA      NA       NA    
  #dummy_phase:dummy_exp_grouptreatment            6.23700    2.06968   3.014  0.00259 ** 
  #Shower:young_pos                                0.07690    0.01361   5.652 1.61e-08 ***
  #Shower:young_neg                                     NA         NA      NA       NA    
  #dummy_phase:young_pos                          -1.38223    2.87629  -0.481  0.63084    
  #dummy_phase:young_neg                                NA         NA      NA       NA    
  #dummy_exp_grouptreatment:young_pos              1.94658    3.19773   0.609  0.54271    
  #dummy_exp_grouptreatment:young_neg                   NA         NA      NA       NA    
  #dummy_phase:dummy_exp_grouptreatment:young_pos  2.56634    3.39298   0.756  0.44944    
  #dummy_phase:dummy_exp_grouptreatment:young_neg       NA         NA      NA       NA  
  </code></pre>
  
  <p>As you can see only <code>NA</code> within this variable. Thanks</p>