Download Homework 2 Solutions - Applied Linear Regression | 22S 152 and more Assignments Statistics in PDF only on Docsity! 22s:152 Homework 2: Solutions Assigned Wednesday, September 10 Due Wednesday, September 17 at classtime 1a) > library(car) > data(Angell) > names(Angell) [1] "moral" "hetero" "mobility" "region" > attach(Angell) ## hetero > y = hetero > par(mfrow = c(1, 2)) > hist(y) > boxplot(y) Histogram of y y F re q u e n c y 20 40 60 80 0 5 1 0 1 5 ! ! ! 2 0 4 0 6 0 8 0 1 > stem(y) The decimal point is 1 digit(s) to the right of the | 1 | 1122334666678899 2 | 01122444789 3 | 12378 4 | 069 5 | 078 6 | 5 7 | 14 8 | 35 The boxplot for hetero does show us that there are some outliers (unusual points) at high values, and that a large portion of the data falls between 0 and 24 (scrunched up toward 0). Also the mean is greater than the median, so this distribution is right-skewed, and is non-normal. It appears to have one mode. ## mobility > y = mobility > par(mfrow = c(1, 2)) > hist(y) > boxplot(y) Histogram of y y F re q u e n c y 10 20 30 40 50 0 2 4 6 8 2 0 3 0 4 0 5 0 2 > stem(y) The decimal point is 1 digit(s) to the right of the | 1 | 24 1 | 555688999 2 | 0022344 2 | 55567778 3 | 12234 3 | 5566789 4 | 23 4 | 57 5 | 0 > detach(Angell) The histogram and stem-n-leaf plot suggest the distribution has something of a bell-shape, but it has a slight right-skew (mean is greater than median). It might fall under a near- normality description depending on how closely the spread gets to a normal distribution. No unusual values. 1b) > data(Leinhardt) > names(Leinhardt) [1] "income" "infant" "region" "oil" > attach(Leinhardt) ## income > y = income > par(mfrow = c(1, 2)) > hist(y) > boxplot(y) 3 Histogram of y y F re q u e n c y 0 2000 4000 6000 0 1 0 2 0 3 0 4 0 5 0 6 0 !! ! ! ! ! ! ! ! ! ! 0 1 0 0 0 2 0 0 0 3 0 0 0 4 0 0 0 5 0 0 0 > stem(y) The decimal point is 3 digit(s) to the right of the | 0 | 11111111111111111111111111111111222222222223333333333333344444444 0 | 55666777788 1 | 0022333 1 | 58 2 | 03 2 | 55 3 | 00333444 3 | 7 4 | 11 4 | 8 5 | 00 5 | 56 The income variable is very right-skewed and is non-normal. The far right tail values may be considered unusual or outliers. 4