# Prepared by: Aziz
# Homework_lesson 4
# http://csis.pace.edu/~ctappert/cs816-15fall/hw/hw04.pdf
# Anscombe dataset#3
X3 <- c(4,5,6,7,8,9,10,11,12,13,14)
y3 <- c(5.39,5.73,6.08,6.42,6.77,7.11,7.46,7.81,8.15,12.74,8.84)
plot(X3,y3, main='Anscombe Dataset 3')
result3 <- lm(y3~X3)
result3
##
## Call:
## lm(formula = y3 ~ X3)
##
## Coefficients:
## (Intercept)           X3
##      3.0025       0.4997
abline(result3)

summary(result3)
##
## Call:
## lm(formula = y3 ~ X3)
##
## Residuals:
##     Min      1Q  Median      3Q     Max
## -1.1586 -0.6146 -0.2303  0.1540  3.2411
##
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)   3.0025     1.1245   2.670  0.02562 *
## X3            0.4997     0.1179   4.239  0.00218 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.236 on 9 degrees of freedom
## Multiple R-squared:  0.6663, Adjusted R-squared:  0.6292
## F-statistic: 17.97 on 1 and 9 DF,  p-value: 0.002176
# Anscombe dataset#1
X1 <- c(4,5,6,7,8,9,10,11,12,13,14)
y1<- c(4.26,5.68,7.24,4.82,6.95,8.81,8.04,8.33,10.84,7.58,9.96)
plot(X1,y1, main='Anscombe Dataset 1')
result1 <-lm(y1~X1)
result1
##
## Call:
## lm(formula = y1 ~ X1)
##
## Coefficients:
## (Intercept)           X1
##      3.0001       0.5001
abline(result1)

summary(result1)
##
## Call:
## lm(formula = y1 ~ X1)
##
## Residuals:
##      Min       1Q   Median       3Q      Max
## -1.92127 -0.45577 -0.04136  0.70941  1.83882
##
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)   3.0001     1.1247   2.667  0.02573 *
## X1            0.5001     0.1179   4.241  0.00217 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.237 on 9 degrees of freedom
## Multiple R-squared:  0.6665, Adjusted R-squared:  0.6295
## F-statistic: 17.99 on 1 and 9 DF,  p-value: 0.00217
# Anscombe dataset#2
x2 <- c(4,5,6,7,8,9,10,11,12,13,14)
y2 <- c(3.10,4.74,6.13,7.26,8.14,8.77,9.14,9.26,9.13,8.74,8.10)
plot(x2,y2, main='Anscombe Dataset 2')
result2 <-lm(y2~x2)
result2
##
## Call:
## lm(formula = y2 ~ x2)
##
## Coefficients:
## (Intercept)           x2
##       3.001        0.500
abline(result2)

summary(result2)
##
## Call:
## lm(formula = y2 ~ x2)
##
## Residuals:
##     Min      1Q  Median      3Q     Max
## -1.9009 -0.7609  0.1291  0.9491  1.2691
##
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)    3.001      1.125   2.667  0.02576 *
## x2             0.500      0.118   4.239  0.00218 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.237 on 9 degrees of freedom
## Multiple R-squared:  0.6662, Adjusted R-squared:  0.6292
## F-statistic: 17.97 on 1 and 9 DF,  p-value: 0.002179
# Anscombe dataset#4
x4 <- c(8,8,8,8,8,8,8,19,8,8,8)
y4 <- c(6.58,5.76,7.71,8.84,8.47,7.04,5.25,12.50,5.56,7.91,6.89)
plot(x4,y4, main='Anscombe Dataset 4')
result4 <-lm(y4~x4)
result4
##
## Call:
## lm(formula = y4 ~ x4)
##
## Coefficients:
## (Intercept)           x4
##      3.0017       0.4999
abline(result4)

summary(result4)
##
## Call:
## lm(formula = y4 ~ x4)
##
## Residuals:
##    Min     1Q Median     3Q    Max
## -1.751 -0.831  0.000  0.809  1.839
##
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)   3.0017     1.1239   2.671  0.02559 *
## x4            0.4999     0.1178   4.243  0.00216 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.236 on 9 degrees of freedom
## Multiple R-squared:  0.6667, Adjusted R-squared:  0.6297
## F-statistic:    18 on 1 and 9 DF,  p-value: 0.002165