Comparing beta coefficient of same variable from two different models in R Let assume I have a data with 100 rows and 3 variables (y,x1,x2). 
Now, I fit a regression model with the FIRST 70 observations & get the coefficients as b11 & b12 respectively for x1 & x2.
Then I fit another regression model with the remaining 30 observations & get b21 & b22 as the coefficient for x1 & x2 respectively.
What I want to be assist is ... how can I compare b11 & b21(or b12 & b22) using R.
There is "anova" option in R but that compares different model techniques with same data. 
 A: The example below shows how to fit 2 groups of data with a single linear model using the factor set. You can then do statistical tests (see summary and anova) to check if there is a significant difference in their coefficients. In this case, the generated data groups have the same y-intercept, but different slopes with respect to x. 
# generate synthetic dataset ----------------------------------------------
set.seed(1)
n <- 140
df <- data.frame(x = seq(n), set = factor(rep(c("a","b"), each=n/2)))

# same intercept, but different slope coefs for the sets (plus error added)
df$y <- c(10, 10)[df$set] + df$x*c(1.3, 1.6)[df$set] + rnorm(n, sd = 10)

plot(y ~ x, df, col = df$set)


# fit models --------------------------------------------------------------

# model including different intercepts and slopes for both sets
fit0 <- lm(y ~ x + set + x:set, data = df)
summary(fit0)

# one could remove the intercept shift for setb
fit1 <- lm(y ~ x + x:set, data = df)
summary(fit1)

anova(fit0, fit1) # not significantly different, so take the simpler fit1 model

