#linear regression with & with out interception #1 WITH interception
agey <- c(1, 4, 8, 10, 15, 18, 20, 25)
sizex1 <- c(10, 20, 25, 28, 30, 40, 60, 100)
foodx2 <- c(1, 1, 2, 4, 5, 2, 4, 7)
lm(agey ~ sizex1 + foodx2)
##
## Call:
## lm(formula = agey ~ sizex1 + foodx2)
##
## Coefficients:
## (Intercept) sizex1 foodx2
## 1.7081 0.2049 0.8929
summary(lm(agey ~ sizex1 + foodx2))
##
## Call:
## lm(formula = agey ~ sizex1 + foodx2)
##
## Residuals:
## 1 2 3 4 5 6 7 8
## -3.6496 -2.6981 -0.6153 -1.0157 2.6817 6.3119 2.4290 -3.4439
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.70814 2.84632 0.600 0.5746
## sizex1 0.20485 0.09341 2.193 0.0798 .
## foodx2 0.89292 1.26340 0.707 0.5113
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.167 on 5 degrees of freedom
## Multiple R-squared: 0.8191, Adjusted R-squared: 0.7468
## F-statistic: 11.32 on 2 and 5 DF, p-value: 0.01392
head(agey)
## [1] 1 4 8 10 15 18
tail(foodx2)
## [1] 2 4 5 2 4 7
plot(x = agey, y = foodx2 + sizex1, col="red")
#2 linear regression WITHOUT intercept
summary(lm(agey ~ sizex1 + foodx2 - 1))
##
## Call:
## lm(formula = agey ~ sizex1 + foodx2 - 1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.5322 -1.6484 -0.1989 2.5562 7.1463
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## sizex1 0.21139 0.08768 2.411 0.0525 .
## foodx2 1.19899 1.09252 1.097 0.3145
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.938 on 6 degrees of freedom
## Multiple R-squared: 0.947, Adjusted R-squared: 0.9293
## F-statistic: 53.58 on 2 and 6 DF, p-value: 0.0001491
summary(lm(formula = agey ~ 0 + sizex1 + foodx2))
##
## Call:
## lm(formula = agey ~ 0 + sizex1 + foodx2)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.5322 -1.6484 -0.1989 2.5562 7.1463
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## sizex1 0.21139 0.08768 2.411 0.0525 .
## foodx2 1.19899 1.09252 1.097 0.3145
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.938 on 6 degrees of freedom
## Multiple R-squared: 0.947, Adjusted R-squared: 0.9293
## F-statistic: 53.58 on 2 and 6 DF, p-value: 0.0001491
lm(formula = agey ~ sizex1 + foodx2 + 0)
##
## Call:
## lm(formula = agey ~ sizex1 + foodx2 + 0)
##
## Coefficients:
## sizex1 foodx2
## 0.2114 1.1990