title: Compare coefficients across different regressions
body: <p>I am trying to compare the coefficients of two linear regressions with the same variables, but run for different subgroups. I want to check if the coefficients in my model 1 are equal to my coefficients in my model 2. I need to know for each coefficient.</p>
  
  <p>My reproducible data :</p>
  
  <pre><code>Data &lt;- data.frame(
  gender = sample (c("men", "women"), 2000, replace = TRUE),
  var1 = sample (c("value1", "value2"), 2000, replace = TRUE),
  var2 = sample (c("valueA", "valueB"), 2000, replace = TRUE),
  y = sample(0:10, 2000, replace = TRUE)
  )
  </code></pre>
  
  <p>I run the two regressions :</p>
  
  <pre><code>men &lt;- subset(Data, gender =="men")
  women &lt;- subset(Data, gender =="women")
  
  lm.men &lt;- lm(y~var1+var2, data = men)
  summary(lm.men)
  lm.women &lt;- lm(y~var1+var2, data = women)
  summary(lm.women)
  </code></pre>
  
  <p>Basically, I want to test if:</p>
  
  <ul>
  <li>coefficient <code>var1</code> in <code>lm.men</code> = coefficient <code>var1</code> in <code>lm.women</code></li>
  <li>coefficient <code>var2</code> in <code>lm.men</code> = coefficient <code>var2</code> in <code>lm.women</code></li>
  </ul>
  
  <p>I can't use the <code>anova()</code> function, because my two samples are different. I think I should apply an F-test but I can't find a function for this test.</p>
  
  <p>Does anyone know how to solve my problem ?</p>