anscombe data that is part of the library(datasets) in R. And assign that data to a new object called data.library(datasets)
data <- anscombe
fBasics() package!)#summary of data
library(fBasics)
## Loading required package: timeDate
## Loading required package: timeSeries
basicStats(data)
## x1 x2 x3 x4 y1 y2
## nobs 11.000000 11.000000 11.000000 11.000000 11.000000 11.000000
## NAs 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
## Minimum 4.000000 4.000000 4.000000 8.000000 4.260000 3.100000
## Maximum 14.000000 14.000000 14.000000 19.000000 10.840000 9.260000
## 1. Quartile 6.500000 6.500000 6.500000 8.000000 6.315000 6.695000
## 3. Quartile 11.500000 11.500000 11.500000 8.000000 8.570000 8.950000
## Mean 9.000000 9.000000 9.000000 9.000000 7.500909 7.500909
## Median 9.000000 9.000000 9.000000 8.000000 7.580000 8.140000
## Sum 99.000000 99.000000 99.000000 99.000000 82.510000 82.510000
## SE Mean 1.000000 1.000000 1.000000 1.000000 0.612541 0.612568
## LCL Mean 6.771861 6.771861 6.771861 6.771861 6.136083 6.136024
## UCL Mean 11.228139 11.228139 11.228139 11.228139 8.865735 8.865795
## Variance 11.000000 11.000000 11.000000 11.000000 4.127269 4.127629
## Stdev 3.316625 3.316625 3.316625 3.316625 2.031568 2.031657
## Skewness 0.000000 0.000000 0.000000 2.466911 -0.048374 -0.978693
## Kurtosis -1.528926 -1.528926 -1.528926 4.520661 -1.199123 -0.514319
## y3 y4
## nobs 11.000000 11.000000
## NAs 0.000000 0.000000
## Minimum 5.390000 5.250000
## Maximum 12.740000 12.500000
## 1. Quartile 6.250000 6.170000
## 3. Quartile 7.980000 8.190000
## Mean 7.500000 7.500909
## Median 7.110000 7.040000
## Sum 82.500000 82.510000
## SE Mean 0.612196 0.612242
## LCL Mean 6.135943 6.136748
## UCL Mean 8.864057 8.865070
## Variance 4.122620 4.123249
## Stdev 2.030424 2.030579
## Skewness 1.380120 1.120774
## Kurtosis 1.240044 0.628751
# Co-relation between columns
cor(data, use = "complete.obs",method = "kendall")
## x1 x2 x3 x4 y1 y2
## x1 1.00000000 1.00000000 1.00000000 -0.4264014 0.6363636 0.56363636
## x2 1.00000000 1.00000000 1.00000000 -0.4264014 0.6363636 0.56363636
## x3 1.00000000 1.00000000 1.00000000 -0.4264014 0.6363636 0.56363636
## x4 -0.42640143 -0.42640143 -0.42640143 1.0000000 -0.4264014 -0.42640143
## y1 0.63636364 0.63636364 0.63636364 -0.4264014 1.0000000 0.56363636
## y2 0.56363636 0.56363636 0.56363636 -0.4264014 0.5636364 1.00000000
## y3 0.96363636 0.96363636 0.96363636 -0.4264014 0.6000000 0.60000000
## y4 -0.09090909 -0.09090909 -0.09090909 0.4264014 -0.1636364 -0.01818182
## y3 y4
## x1 0.96363636 -0.09090909
## x2 0.96363636 -0.09090909
## x3 0.96363636 -0.09090909
## x4 -0.42640143 0.42640143
## y1 0.60000000 -0.16363636
## y2 0.60000000 -0.01818182
## y3 1.00000000 -0.05454545
## y4 -0.05454545 1.00000000
attach(data)
plot(x1, y1, main="Scatter Plot - (x1, y1)", xlab="x1", ylab="y1")
plot(x2, y2, main="Scatter Plot - (x2, y2)", xlab="x2", ylab="y2")
plot(x3, y3, main="Scatter Plot - (x3, y3)", xlab="x3", ylab="y3")
plot(x4, y4, main="Scatter Plot - (x4, y4)", xlab="x4", ylab="y4")
par(mfrow = c(2,2))
plot(x1, y1, main="Scatter Plot - (x1, y1)", xlab="x1", ylab="y1", pch=19)
plot(x2, y2, main="Scatter Plot - (x2, y2)", xlab="x2", ylab="y2", pch=19)
plot(x3, y3, main="Scatter Plot - (x3, y3)", xlab="x3", ylab="y3", pch=19)
plot(x4, y4, main="Scatter Plot - (x4, y4)", xlab="x4", ylab="y4", pch=19)
lm() function.xy1 <- lm(x1 ~ y1, data)
summary(xy1)
##
## Call:
## lm(formula = x1 ~ y1, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.6522 -1.5117 -0.2657 1.2341 3.8946
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.9975 2.4344 -0.410 0.69156
## y1 1.3328 0.3142 4.241 0.00217 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.019 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
xy2 <- lm(x2 ~ y2, data)
summary(xy2)
##
## Call:
## lm(formula = x2 ~ y2, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.8516 -1.4315 -0.3440 0.8467 4.2017
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.9948 2.4354 -0.408 0.69246
## y2 1.3325 0.3144 4.239 0.00218 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.02 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
xy3 <- lm(x3 ~ y3, data)
summary(xy3)
##
## Call:
## lm(formula = x3 ~ y3, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.9869 -1.3733 -0.0266 1.3200 3.2133
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.0003 2.4362 -0.411 0.69097
## y3 1.3334 0.3145 4.239 0.00218 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.019 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
xy4 <- lm(x4 ~ y4, data)
summary(xy4)
##
## Call:
## lm(formula = x4 ~ y4, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.7859 -1.4122 -0.1853 1.4551 3.3329
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.0036 2.4349 -0.412 0.68985
## y4 1.3337 0.3143 4.243 0.00216 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.018 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
par(mfrow=c(2,2))
plot(xy1)
par(mfrow=c(2,2))
plot(xy2)
par(mfrow=c(2,2))
plot(xy3)
par(mfrow=c(2,2))
plot(xy4)
anova(xy1, test="ChiSq")
Analysis of Variance Table
Response: x1 Df Sum Sq Mean Sq F value Pr(>F)
y1 1 73.32 73.320 17.99 0.00217 ** Residuals 9 36.68 4.076
— Signif. codes: 0 ‘’ 0.001 ’’ 0.01 ’’ 0.05 ‘.’ 0.1 ’ ’ 1
anova(xy2, test="ChiSq")
## Analysis of Variance Table
##
## Response: x2
## Df Sum Sq Mean Sq F value Pr(>F)
## y2 1 73.287 73.287 17.966 0.002179 **
## Residuals 9 36.713 4.079
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(xy3, test="ChiSq")
## Analysis of Variance Table
##
## Response: x3
## Df Sum Sq Mean Sq F value Pr(>F)
## y3 1 73.296 73.296 17.972 0.002176 **
## Residuals 9 36.704 4.078
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(xy4, test="ChiSq")
## Analysis of Variance Table
##
## Response: x4
## Df Sum Sq Mean Sq F value Pr(>F)
## y4 1 73.338 73.338 18.003 0.002165 **
## Residuals 9 36.662 4.074
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1