Final Exam
Final Exam
By Vatsal Patel
Q1. Using the attached worksheet, create a scatter plot and draw the regression line. Please
consider red triangular elements for data points, a dashed line for regression, and a frame for the
plot by applying the appropriate arguments (30 points)
Ans.
Q2. A fish survey is done to see if the proportion of fish types is consistent with previous years.
Suppose, the3 types of fish recorded: parrotfish, grouper, tang are historically in a 5:3:4
proportion and in a survey the following counts are found Please do a test of hypothesis to see if
this survey of fish has the same proportions as historically. (30 points)
Ans.
> FishSurvey = c(53,22,49)
> FishSurvey
[1] 53 22 49
> Historicdata = c(5,3,4)
> Historicdata
[1] 5 3 4
> chisq.test(FishSurvey,Historicdata)
As we can see here that p-value for chi square test is above 0.05 so we can accept the hypothesis
that proportions are same.
Q3. It is well known that the more beer you drink, the more your blood alcohol level rises.
Suppose we have the following data on student beer consumption Make a scatterplot and fit the
data with a regression line. Test the hypothesis that another beer raises your BAL by 2 percent
against the alternative that it is not. (40 points)
Ans.
BeersCount = c(5,2,9,8,3,7,3,5,3,5)
> BeersCount
[1] 5 2 9 8 3 7 3 5 3 5
> AlcBAL = c(0.10,0.03,0.19,0.12,0.04,0.095,0.07,0.06,0.02,0.05)
> AlcBAL
[1] 0.100 0.030 0.190 0.120 0.040 0.095 0.070 0.060 0.020 0.050
> ScatterPlot = plot(BeersCount,AlcBAL)
> abline(lm(AlcBAL~BeersCount))
> summary(lm(AlcBAL~BeersCount))
Call:
lm(formula = AlcBAL ~ BeersCount)
Residuals:
Min 1Q Median 3Q Max
-0.0275 -0.0187 -0.0071 0.0194 0.0357
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.018500 0.019230 -0.962 0.364200
BeersCount 0.019200 0.003511 5.469 0.000595 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
As we can see above that Alpha value is 0.02% while p-value is 0.0005 which is greater than alpha
so we can accept the hypothesis that having another beer will rise alcohol level to 0.02% against
the alternative that it is not.
Q4. What is the max and min of F value (F statistics) to accept the null hypothesis for 7 df for
numerator, and12 df for denominator? (alpha = 0.1 and two sided F distribution) (20 points)
Ans.
From the F-distribution table we can see that F critical for 7 df for numerator, and 12 df for
denominator is 2.9134.
So the max F value to accept null hypothesis is 2.9134 while min of F-value to accept null
hypothesis is 1/(2.9134)
which is 0.343246
Q5. Please perform step-by-step ANOVA analysis process for below dataset, and discuss the
results at each step. Finally answer the question of do all the three drugs has the same impact on
patients and if yes, how they are different? (The 3 steps include “graphical comparison”, “fitting
ANOVA model” and “Why and how the means are different”). (80 points)
Drug A 3,5,6,1,2,4,5,7,8,9,0,10
Drug B 6,2,3,2,1,6,8,1,5,5,3,9
Drug C 4,7,3,7,3,8,5,4,6,5,1,8
(Drug impact factors out of 10)
Ans.
ANOVA Analysis:
1. Graphical Comparison:
> results=aov(values~ind,data=Drug)
> summary(results)
Df Sum Sq Mean Sq F value Pr(>F)
ind 2 5.06 2.528 0.346 0.71
Residuals 33 241.17 7.308
If we see that p-value is more than 0.05 while f-value is significantly low so we can accept the null
Hypothesis that all 3 drugs has same effect on patient.