Description Usage Format Source Examples
In 1609 Galileo proved mathematically that the trajectory of a body falling with a horizontal velocity component is a parabola. His search for an experimental setting in which horizontal motion was not affected appreciably (to study inertia) let him to construct a certain apparatus. The data comes from one of his experiments.
1 |
A data frame with 7 observations on the following 2 variables.
horizontal distances (in punti)
initial height (in punti)
Ramsey, F.L. and Schafer, D.W. (2013). The Statistical Sleuth: A Course in Methods of Data Analysis (3rd ed), Cengage Learning.
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 35 36 37 | str(case1001)
attach(case1001)
## EXPLORATION
plot(Distance ~ Height)
myLm <- lm(Distance ~ Height)
plot(myLm, which=1)
height2 <- Height^2
myLm2 <- lm(Distance ~ Height + height2)
plot(myLm2, which=1)
summary(myLm2) # Note p-value for quadratic term (it's small)
height3 <- Height^3
myLm3 <- update(myLm2, ~ . + height3)
plot(myLm3,which=1)
summary(myLm3) # Note p-value for cubic term (it's small)
height4 <- Height^4
myLm4 <- update(myLm3, ~ . + height4)
summary(myLm4) # Note p-value for quartic term (it's not small)
## DISPLAY FOR PRESENTATION
plot(Distance ~ Height, xlab="Initial Height (Punti)",
ylab="Horizontal Distance Traveled (Punti)",
main="Galileo's Falling Body Experiment",
pch=21, bg="green", lwd=2, cex=2)
dummyHeight <- seq(min(Height),max(Height),length=100)
betaQ <- myLm2$coef
quadraticCurve <- betaQ[1] + betaQ[2]*dummyHeight + betaQ[3]*dummyHeight^2
lines(quadraticCurve ~ dummyHeight,col="blue",lwd=3)
betaC <- myLm3$coef # coefficients of cubic model
cubicCurve <- betaC[1] + betaC[2]*dummyHeight + betaC[3]*dummyHeight^2 +
betaC[4]*dummyHeight^3
lines(cubicCurve ~ dummyHeight,lty=3,col="red",lwd=3)
legend(590,290,legend=c(expression("Quadratic Fit "*R^2*" = 99.0%"),
expression("Cubic Fit "*R^2*" = 99.9%")),
lty=c(1,3),col=c("blue","red"), lwd=c(3,3))
detach(case1001)
|
'data.frame': 7 obs. of 2 variables:
$ Distance: int 253 337 395 451 495 534 573
$ Height : int 100 200 300 450 600 800 1000
Call:
lm(formula = Distance ~ Height + height2)
Residuals:
1 2 3 4 5 6 7
-14.308 9.170 13.523 1.940 -6.177 -12.607 8.458
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.999e+02 1.676e+01 11.928 0.000283 ***
Height 7.083e-01 7.482e-02 9.467 0.000695 ***
height2 -3.437e-04 6.678e-05 -5.147 0.006760 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 13.64 on 4 degrees of freedom
Multiple R-squared: 0.9903, Adjusted R-squared: 0.9855
F-statistic: 205 on 2 and 4 DF, p-value: 9.333e-05
Call:
lm(formula = Distance ~ Height + height2 + height3)
Residuals:
1 2 3 4 5 6 7
-2.40359 3.58091 1.89175 -4.46885 -0.08044 2.32159 -0.84138
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.558e+02 8.326e+00 18.710 0.000333 ***
Height 1.115e+00 6.567e-02 16.983 0.000445 ***
height2 -1.245e-03 1.384e-04 -8.994 0.002902 **
height3 5.477e-07 8.327e-08 6.577 0.007150 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 4.011 on 3 degrees of freedom
Multiple R-squared: 0.9994, Adjusted R-squared: 0.9987
F-statistic: 1595 on 3 and 3 DF, p-value: 2.662e-05
Call:
lm(formula = Distance ~ Height + height2 + height3 + height4)
Residuals:
1 2 3 4 5 6 7
-0.4433 0.9338 0.2576 -2.3092 2.3183 -0.9279 0.1708
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.383e+02 9.066e+00 15.254 0.00427 **
Height 1.346e+00 1.061e-01 12.690 0.00615 **
height2 -2.117e-03 3.793e-04 -5.582 0.03063 *
height3 1.766e-06 5.186e-07 3.406 0.07644 .
height4 -5.610e-10 2.375e-10 -2.362 0.14201
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2.523 on 2 degrees of freedom
Multiple R-squared: 0.9998, Adjusted R-squared: 0.9995
F-statistic: 3024 on 4 and 2 DF, p-value: 0.0003306
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.