title: NA values when regressing with dummy variable interaction term
body: <p>I'm trying to estimate factors that determine the difference in happiness level between people living in New York and Chicago.</p>
  
  <p>Data looks like below.</p>
  
  <pre><code>  Happiness     City Gender Employment   Worktype      Holiday
  1        60 New York      0        0     Unemployed   Unemployed
  2        80  Chicago      1        1     Whitecolor 1 day a week
  3        39  Chicago      0        0     Unemployed   Unemployed
  4        40 New York      1        0     Unemployed   Unemployed
  5        69  Chicago      1        1     Bluecolor  2 day a week
  6        90  Chicago      1        1     Bluecolor  2 day a week
  7       100 New York      0        1     Whitecolor 2 day a week
  8        30 New York      1        1     Whitecolor 1 day a week
  </code></pre>
  
  <p>Happiness level is dependent variable, and 'city' is where the person lives. 'Gender' is coded 0 = man 1 = woman. 'Employment' is 0 = Unemployed and 1 = Employed. 'Worktype' is three level factor: 'Unemployed', 'Whitecolor', 'Bluecolor'. 'Holiday' is how many days a person rest in a week. Here 'City', 'Gender', 'Worktype' and 'Holiday' variables are all factors. 'Happiness' and 'Employment' variable types are numerical.</p>
  
  <p>The Model I want to estimate is </p>
  
  <pre><code>lm(Happiness ~ City + Gender + Employment:(Worktype + Holiday))
  </code></pre>
  
  <p>I left 'Employment' value as numerical value so if 'Employment' is equal to 0(Unemployed), 0:(Worktype + Holiday) = 0, so the model is automatically reduced to</p>
  
  <pre><code>lm(Happiness ~ City + Gender)
  </code></pre>
  
  <p>for unemployed people.</p>
  
  <p>However, regression result returns NA values.</p>
  
  <pre><code>Coefficients: (2 not defined because of singularities)
                                 Estimate Std. Error t value Pr(&gt;|t|)
  (Intercept)                       56.75      23.56   2.408    0.138
  CityNew York                     -14.50      27.21  -0.533    0.647
  Gender1                           -2.25      35.99  -0.063    0.956
  Employment:WorktypeBluecolor      25.00      43.02   0.581    0.620
  Employment:WorktypeUnemployed        NA         NA      NA       NA
  Employment:WorktypeWhitecolor     57.75      35.99   1.604    0.250
  Employment:Holiday1 day a week   -50.00      54.42  -0.919    0.455
  Employment:Holiday2 day a week       NA         NA      NA       NA
  </code></pre>
  
  <p>this seems to be due to 'Unemployment' value in 'Worktype' and 'Holiday' variable. However, I am not sure why R is not treating Employment:WorktypeUnemployed which is obviously 0:Worktype = 0 as zero and not removing it from the model. Is this because R is setting Employment:HolidayUnemployed as a baseline and both are perfectly multicollinear?
  (I had to put 'Unemployed' value for 'Worktype' and 'Holiday' because I wanted to see the effect of 'Worktype' and 'Holiday' compared to 'Unemployed' people. If I remove 'Unemployed' value NA disappears, but baseline will be 'Whitecolor' and '1day a week' so I cannot see the effect compared to 'unemployed'.) </p>
  
  <p>If so, Why am I getting NA for coefficients for 'Employement:Holiday2 day a week'? It seems that it has nothing to do with 'Unemployed' value.</p>
  
  <p>Can I rely on this result while just removing NA coefficients?</p>
  
  <p>below are reproducible code.</p>
  
  <pre><code>Happiness &lt;- c(60, 80, 39, 40, 69, 90, 100, 30)
  
  City &lt;- as.factor(c("New York", "Chicago", "Chicago", "New York", "Chicago",         
                    "Chicago", "New York", "New York"))
  Gender &lt;- as.factor(c(0, 1, 0, 1, 1, 1, 0, 1)) # 0 = man, 1 = woman.
  Employment &lt;- c(0,1, 0, 0, 1 ,1 , 1 , 1) # 0 = unemployed, 1 = employed.
  Worktype &lt;- as.factor(c("Unemployed", "Whitecolor", "Unemployed",     
            "Unemployed", "Bluecolor", "Bluecolor", "Whitecolor","Whitecolor"))
  Holiday &lt;- as.factor(c(0, 1, 0, 0, 2, 2, 2, 1))
  levels(Holiday) &lt;- c("Unemployed", "1 day a week", "2 day a week")
  
  data &lt;- data.frame(Happiness, City, Gender, Employment, Worktype, Holiday)
  
  head(data,8)
  str(data)
  
  reg &lt;- lm(Happiness ~ City + Gender + Employment:(Worktype + Holiday))
  summary(reg)
  </code></pre>