Professional Documents
Culture Documents
Pedro G. Martins
3/15/2019
Problem Set 7
Question 1
Part c
for(l in 1:1000) {
counter <- 0
t_1_sam <- sample(t_1, replace=T)
t_2_sam <- sample(t_2, replace=T)
for(j in 1:10){
for(k in 1:10){
if(t_1_sam[k] > t_2_sam[j]) {
counter <- counter + 1
}}}
mean(est_pi)
## [1] 0.74535
sd(est_pi)
## [1] 0.1172042
Part d
Now, the condidence interval is just mean_pi +/- 1.28*sd_pi/sqrt(100), with the values calculated above.
1
Question 3
Part a
plot(load,deflection1)
700
500
deflection1
300
100
load
plot(load,deflection2,col = "red")
2
700
500
deflection2
300
100
load
plot(load,deflection3,col = "blue")
700
500
deflection3
300
100
load
The relationship does look linear.
Part b
3
summary(model)
##
## Call:
## lm(formula = deflection1 ~ load)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.7745 -0.3707 -0.1980 0.3374 0.9331
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.464000000 0.416444802 -3.515 0.0079 **
## load 0.006892309 0.000006712 1026.922 <0.0000000000000002 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.6096 on 8 degrees of freedom
## Multiple R-squared: 1, Adjusted R-squared: 1
## F-statistic: 1.055e+06 on 1 and 8 DF, p-value: < 0.00000000000000022
beta1 <- summary(model)$coefficients[2]
beta0 <- summary(model)$coefficients[1]
y <- beta0+beta1*load
0.0
−0.5
load
#Same calculation for the second deflection
4
model <- lm(deflection2 ~ load)
summary(model)
##
## Call:
## lm(formula = deflection2 ~ load)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.7074 -0.3751 -0.1620 0.2794 0.8965
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.46733333 0.40578434 -3.616 0.00682 **
## load 0.00689208 0.00000654 1053.866 < 0.0000000000000002 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.594 on 8 degrees of freedom
## Multiple R-squared: 1, Adjusted R-squared: 1
## F-statistic: 1.111e+06 on 1 and 8 DF, p-value: < 0.00000000000000022
beta1 <- summary(model)$coefficients[2]
beta0 <- summary(model)$coefficients[1]
y <- beta0+beta1*load
0.0
−0.5
load
#Same calculation for the third deflection
5
summary(model)
##
## Call:
## lm(formula = deflection3 ~ load)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.7736 -0.3946 -0.1880 0.3942 0.8527
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.474000000 0.414130963 -3.559 0.00741 **
## load 0.006892127 0.000006674 1032.633 < 0.0000000000000002 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.6062 on 8 degrees of freedom
## Multiple R-squared: 1, Adjusted R-squared: 1
## F-statistic: 1.066e+06 on 1 and 8 DF, p-value: < 0.00000000000000022
beta1 <- summary(model)$coefficients[2]
beta0 <- summary(model)$coefficients[1]
y <- beta0+beta1*load
0.0
−0.5
load
In all the three cases we have a very clear pattern: the errors are systematically greater form small loads and
for large loads, so we know the deflection load relationship is mostly linear for intermediate loads, and a little
more deviant (but still quite linear under visual inspection in part a) for extremely large or small loads.
6
Part c
##
## Call:
## lm(formula = deflection1 ~ I(load) + I(load^2))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.18818 -0.10741 0.05748 0.08807 0.13491
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.14850000000013 0.16423329344358 0.904 0.396
## I(load) 0.00681168409091 0.00000685907472 993.091 < 0.0000000000000002
## I(load^2) 0.00000000073295 0.00000000006077 12.061 0.00000614
##
## (Intercept)
## I(load) ***
## I(load^2) ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1396 on 7 degrees of freedom
## Multiple R-squared: 1, Adjusted R-squared: 1
## F-statistic: 1.005e+07 on 2 and 7 DF, p-value: < 0.00000000000000022
beta2 <- summary(model)$coefficients[3]
beta1 <- summary(model)$coefficients[2]
beta0 <- summary(model)$coefficients[1]
y <- beta0+beta1*deflection1+beta2*(deflection1^2)
7
700
500
residuals
300
100
load
#Quadratic fit for second deflection run
##
## Call:
## lm(formula = deflection2 ~ I(load) + I(load^2))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.13048 -0.06359 0.02297 0.06473 0.09558
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 0.12266666666695 0.11318985060483 1.084
## I(load) 0.00681257878788 0.00000472728535 1441.119
## I(load^2) 0.00000000072273 0.00000000004188 17.256
## Pr(>|t|)
## (Intercept) 0.314
## I(load) < 0.0000000000000002 ***
## I(load^2) 0.000000539 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.09624 on 7 degrees of freedom
## Multiple R-squared: 1, Adjusted R-squared: 1
## F-statistic: 2.116e+07 on 2 and 7 DF, p-value: < 0.00000000000000022
beta2 <- summary(model)$coefficients[3]
beta1 <- summary(model)$coefficients[2]
beta0 <- summary(model)$coefficients[1]
8
se_beta2 <- summary(model)$coefficients[3,2]
se_beta1 <- summary(model)$coefficients[2,2]
se_beta0 <- summary(model)$coefficients[1,2]
y <- beta0+beta1*deflection2+beta2*(deflection2^2)
300
100
load
#Quadratic fit for third deflection run
##
## Call:
## lm(formula = deflection3 ~ I(load) + I(load^2))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.187576 -0.034955 0.008985 0.082856 0.138424
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 0.13766666666683 0.14505570905745 0.949
## I(load) 0.00681154393939 0.00000605813794 1124.363
## I(load^2) 0.00000000073258 0.00000000005367 13.649
## Pr(>|t|)
## (Intercept) 0.374
## I(load) < 0.0000000000000002 ***
## I(load^2) 0.00000267 ***
## ---
9
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1233 on 7 degrees of freedom
## Multiple R-squared: 1, Adjusted R-squared: 1
## F-statistic: 1.288e+07 on 2 and 7 DF, p-value: < 0.00000000000000022
beta2 <- summary(model)$coefficients[3]
beta1 <- summary(model)$coefficients[2]
beta0 <- summary(model)$coefficients[1]
y <- beta0+beta1*deflection3+beta2*(deflection3^2)
300
100
load
The fit does not seem reasonable, as this time we have residuals in a scale two order of magnitude higher
than in the linear fitting case.
10