load("cereal.Rdata")
lm1 <- lm(Maize ~ Barley, data = cereal)
lm2 <- lm(Maize ~ Wheat, data = cereal)
lm3 <- lm(Maize ~ Barley + Wheat, data = cereal)
lm1$coefficients
## (Intercept) Barley
## -9.484660 1.085748
lm2$coefficients
## (Intercept) Wheat
## -30.8254882 0.9491281
lm3$coefficients
## (Intercept) Barley Wheat
## -25.6646279 -0.5095537 1.3207563
summary(lm1)
##
## Call:
## lm(formula = Maize ~ Barley, data = cereal)
##
## Residuals:
## Min 1Q Median 3Q Max
## -106.401 -21.731 -5.482 21.282 89.921
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -9.4847 32.2742 -0.294 0.772
## Barley 1.0857 0.1919 5.657 1.88e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 45.22 on 19 degrees of freedom
## Multiple R-squared: 0.6274, Adjusted R-squared: 0.6078
## F-statistic: 32 on 1 and 19 DF, p-value: 1.875e-05