Strength and Distance Data
library(readr)
StrengthandDistanceData <- read_csv("/Users/juliaye/Downloads/StrengthandDistanceData.csv")
## Parsed with column specification:
## cols(
## weightlifted = col_double(),
## distancethrown = col_double()
## )
cor.test(StrengthandDistanceData$weightlifted,StrengthandDistanceData$distancethrown,method = "pearson", conf.level = 0.99)
##
## Pearson's product-moment correlation
##
## data: StrengthandDistanceData$weightlifted and StrengthandDistanceData$distancethrown
## t = 10.117, df = 26, p-value = 1.663e-10
## alternative hypothesis: true correlation is not equal to 0
## 99 percent confidence interval:
## 0.7265302 0.9604491
## sample estimates:
## cor
## 0.8929919
library(car)
## Loading required package: carData
scatterplot(StrengthandDistanceData$weightlifted,StrengthandDistanceData$distancethrown)

plot(density(StrengthandDistanceData$weightlifted))

plot(density(StrengthandDistanceData$distancethrown))

model <- lm(distancethrown~weightlifted,StrengthandDistanceData)
par(mfrow=c(2,2))
plot(model)

ncvTest(model)
## Non-constant Variance Score Test
## Variance formula: ~ fitted.values
## Chisquare = 1.822118 Df = 1 p = 0.1770614
qqnorm(model$residuals)
qqline(model$residuals)
shapiro.test(model$residuals)
##
## Shapiro-Wilk normality test
##
## data: model$residuals
## W = 0.95813, p-value = 0.3146

Sugar Chewy Data
library(readxl)
SugarChewyData <- read_excel("/Users/juliaye/Downloads/SugarChewyData.xlsx")
cor.test(SugarChewyData$sugar, SugarChewyData$chewiness, method = "pearson", conf.level = 0.99)
##
## Pearson's product-moment correlation
##
## data: SugarChewyData$sugar and SugarChewyData$chewiness
## t = -6.6025, df = 88, p-value = 2.951e-09
## alternative hypothesis: true correlation is not equal to 0
## 99 percent confidence interval:
## -0.7315074 -0.3624002
## sample estimates:
## cor
## -0.5755643
scatterplot(SugarChewyData$sugar, SugarChewyData$chewiness)

plot(density(SugarChewyData$sugar))

plot(density(SugarChewyData$chewiness))

Model <- lm(chewiness~sugar, SugarChewyData)
summary(Model)
##
## Call:
## lm(formula = chewiness ~ sugar, data = SugarChewyData)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.4557 -0.5604 0.1045 0.5249 1.9559
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.662878 0.756610 10.128 < 2e-16 ***
## sugar -0.022797 0.003453 -6.603 2.95e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.9178 on 88 degrees of freedom
## Multiple R-squared: 0.3313, Adjusted R-squared: 0.3237
## F-statistic: 43.59 on 1 and 88 DF, p-value: 2.951e-09
par(mfrow=c(2,2))
plot(Model)

ncvTest(Model)
## Non-constant Variance Score Test
## Variance formula: ~ fitted.values
## Chisquare = 5.403637 Df = 1 p = 0.02009483
qqnorm(Model$residuals)
qqline(Model$residuals)
shapiro.test(Model$residuals)
##
## Shapiro-Wilk normality test
##
## data: Model$residuals
## W = 0.98668, p-value = 0.4935
##
