Anscombe’s Quartet

Dario DeBlasis

2022-03-23

> fourdata <- read.table("C:/Users/Dario/Downloads/fourData.csv", header=TRUE,
+    stringsAsFactors=TRUE, sep=",", na.strings="NA", dec=".", strip.white=TRUE)
> summary(fourdata)
      x123            y1               y2              y3              x4    
 Min.   : 4.0   Min.   : 4.260   Min.   :3.100   Min.   : 5.39   Min.   : 8  
 1st Qu.: 6.5   1st Qu.: 6.315   1st Qu.:6.695   1st Qu.: 6.25   1st Qu.: 8  
 Median : 9.0   Median : 7.580   Median :8.140   Median : 7.11   Median : 8  
 Mean   : 9.0   Mean   : 7.501   Mean   :7.501   Mean   : 7.50   Mean   : 9  
 3rd Qu.:11.5   3rd Qu.: 8.570   3rd Qu.:8.950   3rd Qu.: 7.98   3rd Qu.: 8  
 Max.   :14.0   Max.   :10.840   Max.   :9.260   Max.   :12.74   Max.   :19  
       y4        
 Min.   : 5.250  
 1st Qu.: 6.170  
 Median : 7.040  
 Mean   : 7.501  
 3rd Qu.: 8.190  
 Max.   :12.500  

Linear Regression

> RegModel.1 <- lm(y1~x4+x123, data=fourdata)
> summary(RegModel.1)

Call:
lm(formula = y1 ~ x4 + x123, data = fourdata)

Residuals:
     Min       1Q   Median       3Q      Max 
-1.87818 -0.18500 -0.01036  0.54964  1.88818 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)  
(Intercept)  4.33291    2.21774   1.954   0.0865 .
x4          -0.09873    0.14012  -0.705   0.5011  
x123         0.45073    0.14012   3.217   0.0123 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 1.273 on 8 degrees of freedom
Multiple R-squared:  0.686, Adjusted R-squared:  0.6075 
F-statistic:  8.74 on 2 and 8 DF,  p-value: 0.009718

x123 is significant given by the * for an alpha of 0.05. The adjusted R-squared value is 0.607 which is a strong positve correlation between the variables. x123 is a good estimator of y1.

> RegModel.2 <- lm(y2~x4+x123, data=fourdata)
> summary(RegModel.2)

Call:
lm(formula = y2 ~ x4 + x123, data = fourdata)

Residuals:
    Min      1Q  Median      3Q     Max 
-1.5213 -0.5060  0.2522  0.7590  1.0156 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)   
(Intercept)   6.4225     1.7937   3.581  0.00718 **
x4           -0.2535     0.1133  -2.236  0.05573 . 
x123          0.3733     0.1133   3.294  0.01096 * 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 1.029 on 8 degrees of freedom
Multiple R-squared:  0.7946,    Adjusted R-squared:  0.7433 
F-statistic: 15.48 on 2 and 8 DF,  p-value: 0.001779

x123 is significant given by the * for an alpha of 0.05. The adjusted R-squared value is 0.743 which is a strong positve correlation between the variables. x123 is a good estimator of y2.

> RegModel.3 <- lm(y3~x4+x123, data=fourdata)
> summary(RegModel.3)

Call:
lm(formula = y3 ~ x4 + x123, data = fourdata)

Residuals:
    Min      1Q  Median      3Q     Max 
-1.2364 -0.6016 -0.1525  0.1159  3.1893 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)   
(Intercept)  2.30291    2.26650   1.016   0.3393   
x4           0.05182    0.14320   0.362   0.7268   
x123         0.52564    0.14320   3.671   0.0063 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 1.301 on 8 degrees of freedom
Multiple R-squared:  0.6717,    Adjusted R-squared:  0.5896 
F-statistic: 8.184 on 2 and 8 DF,  p-value: 0.01162

x123 is significant given by the ** for an alpha of 0.01. The adjusted R-squared value is 0.589 which is a strong positve correlation between the variables. x123 is a good estimator of y3.

> RegModel.4 <- lm(y4~x4+x123, data=fourdata)
> summary(RegModel.4)

Call:
lm(formula = y4 ~ x4 + x123, data = fourdata)

Residuals:
    Min      1Q  Median      3Q     Max 
-1.6333 -0.7925  0.0000  0.7705  1.8775 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)   
(Intercept)  1.96345    2.24292   0.875  0.40687   
x4           0.53836    0.14171   3.799  0.00524 **
x123         0.07691    0.14171   0.543  0.60212   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 1.287 on 8 degrees of freedom
Multiple R-squared:  0.6785,    Adjusted R-squared:  0.5982 
F-statistic: 8.443 on 2 and 8 DF,  p-value: 0.01068

x4 is significant given by the ** for an alpha of 0.01. The adjusted R-squared value is 0.598 which is a strong positve correlation between the variables. x4 is a good estimator of y4.

Scatterplots

> scatterplot(y1~x123, regLine=FALSE, smooth=FALSE, boxplots=FALSE, 
+   data=fourdata)

Linear regression is suitable for this relationship

> scatterplot(y2~x123, regLine=FALSE, smooth=FALSE, boxplots=FALSE, 
+   data=fourdata)

Linear regression is not suitable for this relationship as the data seems to be exponentially distributed.

> scatterplot(y3~x123, regLine=FALSE, smooth=FALSE, boxplots=FALSE, 
+   data=fourdata)

Linear regression could be suited but there is a major outlier in line 3.

> scatterplot(y4~x4, regLine=FALSE, smooth=FALSE, boxplots=FALSE,
+ data=fourdata)

Linear regression is not suitable and the line of best fit would run straight along the x axis if it were not for the outlier in line 8.

Boxplots

> Boxplot( ~ y1, data=fourdata, id=list(method="y"))

y1 is normally distributed. Even lengths on the whiskers and mean line split in the middle

> Boxplot( ~ y2, data=fourdata, id=list(method="y"))

[1] "8"

y2 is not normally distributed. The bottom whisker is longer than the top whisker and there is an outlier at line 8.

> Boxplot( ~ y3, data=fourdata, id=list(method="y"))

[1] "3"

y3 is normally distributed. The box has even width and the whiskers are evenly spread from eachother. However there is a large outlier at line 3.

> Boxplot( ~ y4, data=fourdata, id=list(method="y"))

[1] "8"

y4 is normally distributed. The box has even width and whiskers are venely spread from eachother. However, there is a large outlier at line 8.

Conclusion

My conclusion from the Anscombe’s Quartet dataset is that further analysis must be conducted to fully undersatand how these variables are correlated. After looking at the linear regression it seemed that x123 was a good estimator of y1, y2, y3 and linear regression would be appropriate for all. However, further analysis was completed and by looking at the scatterplots and boxplots we examined many outliers and different relationships among the variables which wouldn’t make linear regression suitable. Therefore, it is important to not rely soley on linear regression and R-squared values and conduct further analysis and visualize the data to confirm your hypothesis.