In: Statistics and Probability
Need use R, and please tell me how to code.
Conc,Thick
452,.14
139,.21
166,.23
175,.24
260,.26
204,.28
138,.29
316,.29
396,.3
46,.31
218,.34
173,.36
220,.37
147,.39
216,.42
216,.46
206,.49
184,.19
177,.22
246,.23
296,.25
188,.26
89,.28
198,.29
122,.3
250,.3
256,.31
261,.34
132,.36
212,.37
171,.4
164,.42
199,.46
115,.2
214,.22
177,.23
205,.25
208,.26
320,.28
191,.29
305,.3
230,.3
204,.32
143,.35
175,.36
119,.39
216,.41
185,.42
236,.47
315,.2
356,.22
289,.23
324,.26
109,.27
265,.29
193,.29
203,.3
214,.3
150,.34
229,.35
236,.37
144,.39
232,.41
87,.44
237,.49
1.Investigate the relationship between the thickness of the shell and the amount of PCB in pelican eggs.
Preliminary data analysis:
Construct a scatterplot of PCB concentration and thickness of the egg shell, and fit the linear regression line. (You have to run the regression model here to be able to drawthe line).
Upload the graph here. Make sure you have put a title to the graph and that the X and Y variables have the correct names.
2.
Run the regression model.
Test whether concentration of PCB (Conc) is an important predictor for thickness of the shell (Thick).
3.
QUESTION 3
Obtain a 99% confidence interval for the slope.
Lower bound: __, Upper bound: __ (use 6 decimals)
Obtain the coefficient of determination: __ (use 5 decimals)
and the estimate for σ : __ (use 5 decimals)
4.Estimate the (mean) egg thickness (millimeters) for a PCB concentration of 400 (parts per million).
5.
Plot the scatter plot with the regression line and the confidence bands for the mean response and for the individual response.
For help, see file "Adding prediction bands to a regression plot", ( and if you do, you may want to modify the newx as follows: newx<-data.frame(Conc=seq(46,451,by=5)); )
Upload the graph here. Make sure the graph has an appropriate title.
6.
Set up the ANOVA table. anova(model)
Source | df | SS | MS | F | p-value |
Regression | __ | __ | __ | __ | __ |
Residuals (errors) | __ | __ | __ | ||
Total | __ | __ |
7.
Conduct an F ratio test for a significant linear relationship.
Use a significance level of α =.01.
1.
From above we see that PVB concentration and Thickness are negatively correlated but the relationship is not good.
2.
6.
Source | df | SS | MS | F | p-value |
Regression | 1 | 0.02649 | 0.0264933 | 4.3015 | 0.04217 |
Residuals (errors) | 63 | 0.38802 | 0.0061591 | ||
Total | 64 | 0.02649+0.38802=0.41451 |
7.
Null hypothesis, H0: Two variables are not linearly related vs. Alternative hypothesis, Ha: H0 is not true.
p-value=0.04217
Since p-value>0.01 hence we fail to reject H0 at 1% level of significance and conclude that two variables are not significantly linearly related.
R code:
Conc=c(452,139,166,175,260,204,138,316,396,46,218,173,220,147,216,216,206,184,
177,246,296,188,89,198,122,250,256,261,132,212,171,164,199,115,214,177,205,
208,320,191,305,230,204,143,175,119,216,185,236,315,356,289,324,109,265,193,
203,214,150,229,236,144,232,87,237)
Thick=c(.14,.21,.23,.24,.26,.28,.29,.29,.3,.31,.34,.36,.37,.39,.42,.46,.49,.19,
.22,.23,.25,.26,.28,.29,.3,.3,.31,.34,.36,.37,.4,.42,.46,.2,.22,.23,.25,.26,
.28,.29,.3,.3,.32,.35,.36,.39,.41,.42,.47,.2,.22,.23,.26,.27,.29,.29,.3,.3,.34,
.35,.37,.39,.41,.44,.49)
plot(Conc,Thick,lwd=2,type="p",xlab="PCB
concentration",ylab="Thickness",main="Scatter plot")
summary(lm(Thick~Conc))
lines(Conc,0.3749372-0.0002790*Conc,type="l",col=2,lwd=2)
anova(lm(Thick~Conc))
Output:
Call:
lm(formula = Thick ~ Conc)
Residuals:
Min 1Q
Median
3Q Max
-0.142852 -0.056904 -0.005656 0.054212 0.181187
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.3749372 0.0298977 12.541 <2e-16
***
Conc -0.0002790 0.0001345
-2.074 0.0422 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.07848 on 63 degrees of freedom
Multiple R-squared: 0.06391, Adjusted R-squared:
0.04906
F-statistic: 4.302 on 1 and 63 DF, p-value: 0.04217
Analysis of Variance Table
Response: Thick
Df Sum
Sq Mean Sq F value Pr(>F)
Conc 1 0.02649 0.0264933 4.3015
0.04217 *
Residuals 63 0.38802
0.0061591
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1