Data on the body weight and height of house cats
cats <- read.csv('https://raw.githubusercontent.com/ntlrs/citibikedata/master/catsM.csv?token=APwdEzOEHVzRfz7R9eBA2_iBed7NS8heks5a4TdAwA%3D%3D', header = TRUE)
head(cats)
## X Sex Bwt Hwt
## 1 1 M 2.0 6.5
## 2 2 M 2.0 6.5
## 3 3 M 2.1 10.1
## 4 4 M 2.2 7.2
## 5 5 M 2.2 7.6
## 6 6 M 2.2 7.9
Filter the data to only include arable land from 1961 and 2015.
cats <- cats[c(2:4)]
colnames(cats) <- c("sex", "body weight", "height")
head(cats)
## sex body weight height
## 1 M 2.0 6.5
## 2 M 2.0 6.5
## 3 M 2.1 10.1
## 4 M 2.2 7.2
## 5 M 2.2 7.6
## 6 M 2.2 7.9
plot(cats$`body weight`, cats$height, xlab = "body weight of male house cats", ylab = "height of male house cats")
catsaverage <- lm(cats$height~cats$`body weight`)
abline(catsaverage)
summary(catsaverage)
##
## Call:
## lm(formula = cats$height ~ cats$`body weight`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.7728 -1.0478 -0.2976 0.9835 4.8646
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.1841 0.9983 -1.186 0.239
## cats$`body weight` 4.3127 0.3399 12.688 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.557 on 95 degrees of freedom
## Multiple R-squared: 0.6289, Adjusted R-squared: 0.625
## F-statistic: 161 on 1 and 95 DF, p-value: < 2.2e-16
The value is very small, indicating that there is a correlation between a house cats height and weight.
plot(fitted(catsaverage), resid(catsaverage))
qqnorm(resid(catsaverage))
qqline(resid(catsaverage))