title: Linear Regression for different sample selection
body: <p>I have edited the following reproducible data frame (DF) which  is taken from stackoverflow user G. Grothendieck.</p>
  
  <pre><code>Lines &lt;- "Ctry  year   Carx   Brx
  A    2000    13     12
  A    2001     8     16
  A    2002    12     20
  A    2003    16     18
  A    2004    10     25
  A    2005    13     12
  B    2000    20     22
  B    2001    24     20
  B    2002    32     14
  B    2003    32     24
  B    2004    30     18
  B    2005    36     14   
  C    2000    42     36
  C    2001    46     25
  C    2002    45     32
  C    2003    56     38
  C    2004    56     15
  C    2005    58     60
  "
  DF &lt;- read.table(text = Lines, header = TRUE)
  </code></pre>
  
  <p>I want to make a regression estimation based on the samples selected by the codes indicated below.</p>
  
  <pre><code>subset(DF, (Carx &lt; 15 &amp; year==2005), select=c(Ctry, year, Carx))
  
  DF$class &lt;- "low"
  
  for(i in seq(15,25, by=5)) {
  
  for( j in seq(35,45, by=5)) {
  
  test &lt;- subset(DF, (Carx &lt; i &amp; year==2005), select=c(Ctry, year, Carx))
  for (k in unique(test$Ctry)) DF[DF$Ctry==k,"class"]&lt;-"low"
  
  test &lt;- subset(DF, (Carx &lt; j &amp; Carx &gt; i &amp; year==2005), select=c(Ctry,year, Carx))
  for (k in unique(test$Ctry)) DF[DF$Ctry==k,"class"]&lt;-"middle"
  
  test &lt;- subset(DF, (Carx &gt; j &amp; year==2005), select=c(Ctry, year, Carx))
  for (k in unique(test$Ctry)) DF[DF$Ctry==k,"class"]&lt;-"high"
   }
  }
  </code></pre>
  
  <p>The regression equation that I want to estimate is;</p>
  
  <pre><code>require(lme4)
  est.1 &lt;- lmer(Carx~1+year+(1+year|Ctry), data=DF,REML=F)
  </code></pre>
  
  <p>My problem is that, I want to input the sample selections that is produced by the above codes into the regression equation. If I correctly write the codes, for each i and j, I will obtain a different sample of data. I want to get regression result for each sample.</p>
  
  <p>thanks for help... </p>