Description Usage Format Source References See Also Examples
Hubble's initial data on 24 nebulae outside the Milky Way.
1 |
A data frame with 24 observations on the following 2 variables.
recession velocity (in kilometres per second)
distance from earth (in magaparsec)
Ramsey, F.L. and Schafer, D.W. (2013). The Statistical Sleuth: A Course in Methods of Data Analysis (3rd ed), Cengage Learning.
Hubble, E. (1929). A Relation Between Distance and Radial Velocity Among Extragalactic Nebulae, Proceedings of the National Academy of Science 15: 168–173.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | str(case0701)
attach(case0701)
## EXPLORATION
plot(Distance ~ Velocity)
myLm <- lm(Distance ~ Velocity)
abline(myLm)
myResiduals <- myLm$res
myFits <- myLm$fit
plot(myResiduals ~ myFits) # Plot residuals versus estimated means.
abline(h=0) # Draw a horizontal line at 0.
# OR, use this shortcut...
plot(myLm, which=1) # Residual plot (red curve is a scatterplot smooother)
## INFERENCE
summary(myLm)
confint(myLm,level=.95)
myLm2 <- lm(Distance ~ Velocity - 1) # Drop the intercept.
summary(myLm2)
confint(myLm2)
## DISPLAY FOR PRESENTATION
plot(Distance ~ Velocity, xlab="Recession Velocity (km/sec)",
ylab="Distance from Earth (megaparsecs)",
main="Measured Distance Versus Velocity for 24 Extra-Galactic Nebulae",
pch=21, lwd=2, bg="green", cex=1.5 )
abline(myLm, lty=2, col="blue", lwd=2)
abline(myLm2, lty=3, col="red", lwd=2)
legend(-250,2.05,
c("unrestricted regression line","regression through the origin"),
lty=c(2,3), lwd=c(2,2), col=c("blue","red"))
detach(case0701)
|
'data.frame': 24 obs. of 2 variables:
$ Velocity: int 170 290 -130 -70 -185 -220 200 290 270 200 ...
$ Distance: num 0.03 0.03 0.21 0.26 0.28 0.28 0.45 0.5 0.5 0.63 ...
Call:
lm(formula = Distance ~ Velocity)
Residuals:
Min 1Q Median 3Q Max
-0.76717 -0.23517 -0.01083 0.21081 0.91463
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.3991704 0.1186662 3.364 0.0028 **
Velocity 0.0013724 0.0002278 6.024 4.61e-06 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.4056 on 22 degrees of freedom
Multiple R-squared: 0.6226, Adjusted R-squared: 0.6054
F-statistic: 36.29 on 1 and 22 DF, p-value: 4.608e-06
2.5 % 97.5 %
(Intercept) 0.1530719058 0.64526897
Velocity 0.0008999349 0.00184488
Call:
lm(formula = Distance ~ Velocity - 1)
Residuals:
Min 1Q Median 3Q Max
-0.76767 -0.06909 0.22948 0.46056 1.03931
Coefficients:
Estimate Std. Error t value Pr(>|t|)
Velocity 0.0019214 0.0001913 10.04 7.05e-10 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.4882 on 23 degrees of freedom
Multiple R-squared: 0.8143, Adjusted R-squared: 0.8062
F-statistic: 100.9 on 1 and 23 DF, p-value: 7.05e-10
2.5 % 97.5 %
Velocity 0.001525611 0.002317143
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.