title: What is actually occurring in this multiple linear regression analysis done in R?
body: <p>I am working on a project with data analysis in R.</p>
  <p>What I am seeking to do is determine if a dataset can be described with a linear regression model, and then trying to test if certain subgroups of that dataset have a stronger correlation than the whole dataset. More specifically, I am comparing a dataset where students recorded their pulse and time estimations, and checking to see if there is a stronger correlation in a subgroup of the data where students were not found to have a daily rhythm to either variable vs. a subgroup where students were calculated to have a daily rhythm in both time estimation and heart rate. The values I am using are their daily averages for both time estimation and heart rate.</p>
  <p>I ran a linear model of the whole dataset:</p>
  <pre><code>&gt; summary(ptmod1)
  Call:
  lm(formula = avg.time ~ avg.pulse, data = pulsetime)
  
  Residuals:
       Min       1Q   Median       3Q      Max 
  -11.7310  -1.6725  -0.0162   2.0134   9.8548 
  
  Coefficients:
              Estimate Std. Error t value Pr(&gt;|t|)    
  (Intercept) 68.82047    2.99244  22.998   &lt;2e-16 ***
  avg.pulse   -0.10449    0.04115  -2.539   0.0125 *
  </code></pre>
  <p>and also attempted to run a linear regression of each subgroup</p>
  <pre><code>&gt; summary(ptmod2)
  
  Call:
  lm(formula = avg.time ~ avg.pulse + Group, data = pulsetime)
  
  Residuals:
       Min       1Q   Median       3Q      Max 
  -12.9884  -1.7723  -0.1873   2.4900   8.7424 
  
  Coefficients:
              Estimate Std. Error t value Pr(&gt;|t|)    
  (Intercept) 68.45350    2.92287  23.420  &lt; 2e-16 ***
  avg.pulse   -0.08566    0.03985  -2.149  0.03388 *  
  GroupOne    -1.22325    0.91444  -1.338  0.18386    
  GroupThree   0.11062    0.97666   0.113  0.91003    
  GroupTwo    -3.09096    0.95446  -3.238  0.00161 **
  </code></pre>
  <p>However, I wanted to make sure that what I was seeing was correct, because I did not really expect so many of the groups to have significant coefficients. So I cut the groups up into their own .csv files and generated linear models for each of them individually. Cutting them up into their own files also made it easier to run a Chow test as a post-hoc analysis. When I ran regressions on them again, I got quite different coefficients.
  For example, here is the summary for Group One:</p>
  <pre><code>&gt; summary(mod1)
  
  Call:
  lm(formula = avg.time ~ avg.pulse, data = group1)
  
  Residuals:
      Min      1Q  Median      3Q     Max 
  -7.1048 -1.6529 -0.7279  1.4063  5.6574 
  
  Coefficients:
              Estimate Std. Error t value Pr(&gt;|t|)    
  (Intercept) 67.41445    4.15917  16.209 8.99e-15 ***
  avg.pulse   -0.08916    0.05657  -1.576    0.128  
  </code></pre>
  <p>This makes me question what exactly my results from the summary of ptmod2 actually mean? I was uncertain of how to set up the R code for the linear model sorted by individual subgroups, so my code for it was</p>
  <pre><code>&gt; ptmod2&lt;-lm(avg.time~avg.pulse+Group, data=pulsetime)
  </code></pre>
  <p>In my spreadsheet file, I have three columns: avg.pulse, avg.time, and Group. &quot;Group&quot; is a column of the words &quot;One&quot;, &quot;Two&quot;, &quot;Three&quot;, and &quot;Four&quot; assigned based on subgroup.</p>
  <p>Did the summary for ptmod2 fit a linear regression across the whole dataset? I am really not sure what happened.</p>
  <p>Thankyou so much for any insight you can provide. Perhaps my code for comparing regressions by group was incorrect.</p>