This is an R Markdown document showing the linear regression of inches of rain to wheat production by billion bushels.
Rain <- c(31.4,30.1,27.5,31.1,30.9,34.6,31.4,32.3,34.7,34.8,30.4)
# inches of rain per year 2010-2020
Wheat <- c(2.1,1.9,2.2,2.1,2.0,2.0,2.3,1.7,1.9,1.9,1.8)
# billions of bushels wheat per year 2010-2020
BL <- lm(Rain ~ Wheat)
summary (BL)
##
## Call:
## lm(formula = Rain ~ Wheat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.3082 -1.4288 -0.1565 1.7935 2.8953
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 40.669 7.966 5.106 0.00064 ***
## Wheat -4.482 3.987 -1.124 0.28998
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.217 on 9 degrees of freedom
## Multiple R-squared: 0.1231, Adjusted R-squared: 0.02572
## F-statistic: 1.264 on 1 and 9 DF, p-value: 0.29
plot(Wheat, Rain, main="Linear Regression: Rain to Wheat Production",
xlab= "Wheat Production bn/yr", ylab="Rain (in/yr)",
xlim = c(1.5,2.5),ylim=c(25.0,35.0))
abline (BL, col="red")
relation <- lm(Rain~Wheat)
res <- residuals(relation)
res
## 1 2 3 4 5 6 7
## 0.1435294 -2.0529412 -3.3082353 -0.1564706 -0.8047059 2.8952941 1.0400000
## 8 9 10 11
## -0.7494118 2.5470588 2.6470588 -2.2011765
plot(Wheat,res, main="Residual Plot")
abline (a=0, b=0)