case0701 | R Documentation |
Hubble's initial data on 24 nebulae outside the Milky Way.
case0701
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.
ex0725
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.