Homework 10
Due Friday, June 7
p. 426
7.3, 5, 6, 7, 8, 9 (
see this link for the data
), 10, 17, 18, 20, 28 (
data
), 29 (data
)
Some useful R commands
Here's an example of how to deal with the anscombe data (problem 9)
>anscombe <- read.table("anscombe.dat", header=T)
> attach(anscombe)
> plot(X1, Y1)
> cor(X1, Y1)
[1] 0.8164205 # To compute the correlation coefficient
> output1 <- lm(Y1 ~ X1) # This computes the regression
line
> abline(output1) #This superimposes the regression
line on your scatterplot
> summary(output1) #Below is the output
Call:
lm(formula = Y1 ~ X1)
Residuals:
Min 1Q
Median 3Q
Max
-1.92127 -0.45577 -0.04136 0.70941 1.83882
Coefficients:
Estimate
Std. Error t value Pr(>|t|)
(Intercept) 3.0001 1.1247
2.667 0.02573 *
X1 0.5001
0.1179 4.241 0.00217 **
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
Residual standard error: 1.237 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
To help you read the output of the "summary" command:
The estimated intercept is given in the row marked "(Intercept)" and the
column marked "Estimate". The value is 3.0001. The estimated
slope is in the row marked "X1". It's value is .5001. Hence the
regression line, or "best fit" line is y = 3.0001 + 0.5501*X1