R代写-W21-Assignment 2

AFM 113, W21 Assignment 2 Example Template
Question 1

A small college town has 2 pizza stores that make deliveries. A student doing a research paper
for their business management class decides to compare how promptly each store delivers. On
six randomly chosen nights, they order a large pepperoni pizza from each establishment, then
they record the elapsed time until the pizza is delivered to the apartment. Assume that the
apartment is approximately the same distance from the two pizza stores. The table below shows
the times (in minutes) for these deliveries. It is also known that the group variances are not
equal.
Tony’s Luigi’s
20.0 22.1
24.0 27.0
18.3 20.2
22.0 32.0
20.8 26.0
19.0 24.8
Mean
Standard
Deviation

a) (Do by hand) You are interested in testing whether the average time of delivery is different
between the two stores.
- Use the data to test the hypothesis of interest by performing a hypothesis test at a 5%
level of significance.
- Clearly show all four steps of your hypothesis test and use the critical value to make a
clear conclusion.

b) Use R to solve for a 95% confidence interval of the average difference in delivery time
between the pizza stores.
- Interpret your interval, what does this suggest about the difference in the average
delivery time between the two stores??
- Is this a matching confidence interval to the hypothesis test performed in part a)?
Explain.

Question 2
A home improvement show gives tips on ways to improve your house before it is listed for sale.
The show claims that their tips will help to sell your house faster. To test the claim a researcher
found five pairs of houses that were similar in condition, area, and asking price. In each pair the
homeowners of one house were asked to follow the tips given in the show before putting their
houses on the market (no major renovations were allowed). The table lists the number of weeks
it took for the houses to sell.
Without Tips 9 10.5 3 5.5 14.5
Tips 7 6 5 1 4

a) Use R to solve for a 90% confidence interval for the true mean difference between the
number of weeks required to sell a house for homeowners that follow the show’s tips and
those who do not. Interpret your interval, what does this suggest about the tips given and
the number of weeks to sell a home?

b) Test the shows claim by performing a hypothesis test.

- Use R to perform a hypothesis test at a 10% level of significance.
- Your solution should clearly state the hypothesis being tested using the notation
introduced in the course lessons.
- Your solution should include a clear conclusion statement.

Solutions:
Question 1
a) Using Excel I solved for the mean and standard deviation of each group. Results are
below:
Group 1 Group 2
20 22.1
24 27
18.3 20.2
22 32
20.8 26
19 24.8
Sample
Mean
20.68333 25.35
Sample
Std
dev
2.084626 4.117159

b) Using R we have:
Tony<-c(20.0, 24.0, 18.3, 22.0, 20.8, 19.0)
Luigi<-c(22.1, 27.0, 20.2, 32.0, 26.0, 24.8)
t.test(Tony, Luigi, var.equal=FALSE, conf.level=0.95)

Hence, we are 95% confident that the true but unknown average difference in delivery
times between the two stores lies between -9.07262 and -0.26071. Since this interval is
entirely negative it says that on average Tony’s delivery time is less than Luigi’s i.e
Tony’s delivers at a faster rate on average.

Step 1: 0: 1 = 2 . : 1 ≠ 2
Step 2: Since group variances are NOT equal we have
=
(̅1 − ̅2) − 0

1
2
1
+
2
2
2
=
(20.6833 − 25.35) − 0
√2.0846
2
6 +
4.11722
6
= −2.477

Step 3: The critical value is given by ±min(6−1,6−1);0.025 =
±5; 0.025 = ±2.571
Step 4: Our test statistic value lies between our critical values and
hence we do NOT reject the null hypothesis at a 5% level of
significance. Therefore the data suggests that there is no
statistically significant difference in the average delivery times of
the stores.
This confidence interval is a match to the two-sided hypothesis test performed in part a).
This is since the level of confidence is a match to the level of significance i.e 0.95 = 1-
0.05. The noted difference in results is due to the approximate degrees of freedom used
when performing the test by hand in part a).

Question 2:

a) Using R we have:
NoTips<-c(9, 10.5, 3, 5.5, 14.5)
Tips<-c(7, 6, 5, 1, 4)
t.test(NoTips, Tips, paired=TRUE, conf.level=0.9)

Hence, we are 90% confident that the true but unknown average difference in number of
weeks to sell between homes that used no tips vs. those that did lies between -0.435 and
8.235. Since this interval contains the value 0 it suggests that there is no statistically
significant difference in the average selling time between the homes.

b) Using R we have:
t.test(NoTips, Tips, paired=TRUE, conf.level=0.9,
alternative="greater")
Step 1: Consider Without Tips as Group 1 and With Tips as Group 2 hence = 1 − 2 and
0: = 0 . : > 0
Steps 2 and 3:

Step 4: p-value < = 0.1 therefore we Reject the null hypothesis at a 10% level of significance.
Hence the data suggests that we are going towards the alternative suggesting that homes that did
not follow the tips took on average longer to sell when compared to the homes that did follow the
tips.