# R Language Programming Project

Description

4 attachmentsSlide 1 of 4attachment_1attachment_1attachment_2attachment_2attachment_3attachment_3attachment_4attachment_4

Unformatted Attachment Preview

min0 min302.76
7.7
13.914.79
67.48 94.0317.04
7.025.18
18.537.39
41.7
3.12.68
7.917.3
5.443.05
4.8511.78
3.994.1
11.13.9
5.217.05
3.7426
10.26
94.03
With.Labs
8488
Without.Labs80
82
74
68
7883
81
8279
85
8792
93
7181
76
8482
8386
8286
7689
8194
80With
83With
79With
92With
81With
82With
86With
86With
89With
94With
88Without
78Without
82
Without
87Without
71Without
84Without
83Without
82Without
76Without
81Without
84Without
82Without
74Without
68Without
81Without
85
Without
93Without
76
Chapter 5 Confidence Interval & Hypothesis Test Review: Example Solutions
Confidence Intervals
Examples
Example 3. Suppose X ∼ χ2 (5). Find P(X > 15.09).
Solution:
In this case, there are 5 degrees of freedom, so v = 5. We have that χ2α (5) = 15.09. We need to
identify α.
Option 1: Go to the Table in the textbook. Look for the v value. The body of the table contains
the chi-square values. The areas are along the top. If the exact value is not in the table,
the most you can do is to give an interval for α. In our scenario, α = 0.01 .
Option 2: In your calculator, there is a function that allows you to calculate chi-square probabilities.
It works similar to the normalcdf function, except that it has one additional input, the
degrees of freedom value.

P X ≥ χ2α (v) = χ2 cdf χ2α (v), 999, v = α,
and

P X ≤ χ2α (v) = χ2 cdf 0, χ2α (v), v = 1 − α.
For our example,
P (X ≥ 15.09) = χ2 cdf(15.09, 999, 5) = 0.01 .
Example 4. Find the χ2 value with 7 degrees of freedom leaving an area of 0.05 to the right.
Solution:
This question is asking us to find χ20.05 (7), where we have

P X > χ20.05 (5) = 0.05.
There is no inverse function for the chi-square distribution on your calculator, so you need to
know how to use the table. Our solution is
χ20.05 (5) = 14.067 .
1
Example 5. Suppose F ∼ F (5, 8).
1. Find k such that P(F > k) = 0.05.
Solution:
In this case, α = 0.05. r1 = 5 and r2 = 8. We find that k = 3.69 = F0.05 (5, 8) .
2. Find k such that P(F > k) = 0.01.
Solution:
In this case, α = 0.01. r1 = 5 and r2 = 8. We find that k = 6.63 = F0.01 (5, 8) .
3. Find F0.95 (8, 5).
Solution:
In this case, α = 0.95, which is NOT on one of our tables. However, we can still find this
value.
1
1
=
= 0.27 .
F0.95 (8, 5) =
F0.05 (5, 8)
3.69
4. Find F0.05 (8, 5).
Solution:
In this case, α = 0.05. r1 = 8 and r2 = 5. We find that F0.05 (8, 5) = 4.82 .
Example 6. Suppose we are interested in the accelerated life testing of paints. Suppose we have
independent normal distributions where
n1 = 10 s21 = 400
n2 = 12 s22 = 340
Find a 90% confidence interval for σ12 /σ22 .
Solution:
In this case, α = 0.10, so α/2 = 0.05. We have
Fα/2 (n1 − 1, n2 − 1) = F0.05 (9, 11) = 2.90
Fα/2 (n2 − 1, n1 − 1) = F0.05 (11, 9) = 3.10
The 90% confidence interval for σ12 /σ22 is given by

1
400
400
, 3.10
= (0.41, 3.65) .
2.90 340
340
Note that the interval we found contains 1. This means that it is reasonable to believe that σ12
may be equal to σ22 .
2
Hypothesis Testing
Examples
Example 7. We want to test whether the variability in incoming material from a new supplier
(σ22 ) is smaller than that coming from the current supplier (σ12 ). We obtain the following data:
n1 = 13 x̄ = 26.2 s2x = 29.1
n2 = 11 ȳ = 25.9 s2y = 14.6
Perform a hypothesis test with α = 0.05.
Solution:
H0 : σ12 = σ22
• Test Statistic:
F =
versus
H1 : σ12 > σ22
29.1
s2x
=
= 1.99
s2y
14.6
• Critical Region:
Reject H0 if F > F0.05 (12, 10) = 2.91
• Critical Region Decision:
Since 1.99 6> 2.91, Do Not Reject H0 .
• p-value Calculation:
p-value = P (F > 1.99) = Fcdf(1.99, 999, 12, 10) = 0.1421
• p-value Decision:
Since p-value 6< α = 0.05, Do Not Reject H0 . 3 Additional Examples Example 8. A random sample of 100 recorded deaths in the US during the last year showed an average lifespan of 71.8 years. Assuming a population standard deviation of 8.9 years, does this seem to indicate that the mean life span today is greater than 70 years? (a) Perform a hypothesis test. Use the critical region method with α = 0.04 to make your decision. Solution: • State your hypotheses. H0 : µ = 70 versus H1 : µ > 70.
We have x̄ = 71.8, σ = 8.9, and n = 100. Since σ is known, use z.
z=
x̄ − µ0
71.8 − 70

√ =
= 2.02.
σ/ n
8.9/ 100
• Define the critical region.
α = 0.04. We have
zα = z0.04 = invnorm(1 − 0.04) = 1.75.
Our critical region is:
Reject H0 if z > 1.75.
Since 2.02 > 1.75, we Reject H0 . There is enough evidence that the mean life span
today is greater than 70 years.
4
(b) Perform a hypothesis test. Use the p-value method to make your decision. Use a cutoff
value of 0.04.
Solution:
H0 : µ = 70
versus
H1 : µ > 70.
We have x̄ = 71.8, σ = 8.9, and n = 100. Since σ is known, use z.
z=
71.8 − 70
x̄ − µ0
√ =

= 2.02.
σ/ n
8.9/ 100
• Calculate the p-value.
p-value = P (Z > 2.02) = normalcdf(2.02, 999) = 0.0217.
Since our p-value is small (even smaller than our cutoff value of 0.04), we would
Reject H0 . There is enough evidence that the mean life span today is greater than
70 years.
5
Example 9. The number of kilowatt hours used annually by various home appliances is published
annually. It is claimed that a vacuum cleaner uses an average of 46 kilowatt hours per year. If a
random sample of 12 homes included in a planned study indicates that vacuums use an average
of 42 kilowatt hours per year with a standard deviation of 11.9 kilowatt hours, does this suggest
at the 0.10 level of significance that vacuum cleaners use, on average, less than 46 kilowatt hours
annually?
(a) Perform a hypothesis test. Use the critical region method to make your decision.
Solution:
H0 : µ = 46
versus
H1 : µ < 46. • Calculate your test statistic. We have x̄ = 42, s = 11.9, and n = 12. Since σ is unknown, use t. t= 42 − 46 x̄ − µ0 √ = √ = −1.164. s/ n 11.9/ 12 This value has v = n − 1 = 11 degrees of freedom. • Define the critical region. α = 0.10. Use 11 degrees of freedom. We have −tα (n − 1) = −t0.10 (11) = −1.363. Our critical region is: Reject H0 if t < −1.363. • Make your decision and state your conclusion. Since −1.164 6< −1.363, Do Not Reject H0 . There is not enough evidence to conclude that the mean number of kilowatt hours a vacuum uses per year is significantly less than 46. 6 (b) Perform a hypothesis test. Use the p-value method to make your decision, with the cutoff value being the level of significance. Solution: • State your hypotheses. H0 : µ = 46 versus H1 : µ < 46. • Calculate your test statistic. We have x̄ = 42, s = 11.9, and n = 12. Since σ is unknown, use t. t= 42 − 46 x̄ − µ0 √ = √ = −1.164. s/ n 11.9/ 12 This value has v = n − 1 = 11 degrees of freedom. • Calculate the p-value. p-value = P (T < −1.164) = tcdf(−999, −1.164, 11) = 0.1345 ∈ (0.10, 0.15) . • Make your decision and state your conclusion. Since our p-value is large (it is larger than our cutoff value of 0.10), we Do Not Reject H0 . There is not enough evidence to conclude that the mean number of kilowatt hours a vacuum uses per year is significantly less than 46. 7 Example 10. An experiment was performed to compare the abrasive wear of two different laminated materials. We obtain the following data: Material 1 n1 = 12 x̄1 = 85 units of wear s1 = 4 Material 2 n2 = 10 x̄2 = 81 units of wear s2 = 5 Assume the populations to be approximately normal with equal variances. Can we conclude at the 0.05 level of significance that the abrasive wear of material 1 exceeds that of material 2 by more than 2 units? (a) Perform a hypothesis test. Use the critical region method with the stated level of significance to make your decision. Solution: • State your hypotheses: H0 : µ1 − µ2 = 2 versus H1 : µ1 − µ2 > 2.
• Is the data paired?
No.
• Are the population variances known or unknown? If they are unknown, are they
equal?
They are unknown and assumed to be equal. Use Case 3 information.
Use t since we have an example of Case 3.
401
(12 − 1)(4)2 + (10 − 1)(5)2
=
= 20.05
12
+
10

2
20

sp = 20.05 = 4.478
(85 − 80) − 2
q
t=
= 1.043.
1
1
4.478 · 12
+ 10
s2p =
• Define the critical region.
α = 0.05. Use df = v = n1 + n2 − 2 = 12 + 10 − 2 = 20. We have
tα (n1 + n2 − 2) = t0.05 (20) = 1.725.
Our critical region is:
Reject H0 if t > 1.725.
Since 1.043 6> 1.725, Do Not Reject H0 . There is not enough evidence that the actual
abrasive wear of material 1 exceeds that of material 2 by more than 2 units.
8
(b) Perform a hypothesis test. Use the p-value method to make your decision, with the cutoff
value being the level of significance.
Solution:
H0 : µ1 − µ2 = 2
versus
H1 : µ1 − µ2 > 2.
• Is the data paired?
No.
• Are the population variances known or unknown? If they are unknown, are they
equal?
They are unknown and assumed to be equal. Use Case 3 information.
Use t since we have an example of Case 3.
401
(12 − 1)(4)2 + (10 − 1)(5)2
=
= 20.05
12
+
10

2
20

sp = 20.05 = 4.478
(85 − 80) − 2
q
= 1.043
t=
1
1
+ 10
4.478 · 12
s2p =
df = n1 + n2 − 2 = 12 + 10 − 2 = 20.
• Calculate the p-value.
p-value = P (T > 1.043) = tcdf(1.043, 999, 20) = 0.1547 ∈ (0.15, 0.20).
Since our p-value is large (larger than our cutoff value), we Do Not Reject H0 . There
is not enough evidence that the actual brasive wear of material 1 exceeds that of
material 2 by more than 2 units.
9
Example 11. The following data represent the running times of films produced by two motionpicture companies:
Company
1
2
102
81
Time (minutes)
86 98 109 92
165 97 134 92 87
114
Test the hypothesis that the average running time of films produced by company 2 is less than
or equal to the average running time of films produced by company 1 by 10 minutes against the
one-sided alternative that the difference is more than 10 minutes. Use a 0.1 level of significance
and assume the distributions of times to be approximately normal with unequal variances.
(a) Perform a hypothesis test. Use the critical region method to make your decision.
Solution:
Option 1:
H0 : µ2 − µ1 = 10
H1 : µ2 − µ1 > 10
• Is the data paired?
No.
• Are the population variances known or unknown? If they are unknown, are they
equal?
They are unknown and assumed to be unequal. Use Case 2 information.
• Sample Information
n1 = 5 x̄1 = 97.4 σ1 = 8.877
n2 = 7 x̄2 = 110 σ2 = 30.221
Degrees of Freedom

v=
(s21 /n1 + s22 /n2 )2
(s21 /n1 )2
(s2 /n )2
+ n2 2 −12
n1 −1
=
8.8772
5
(8.8772 /5)2
5−1
2
+
30.2212
7
+
(30.2212 /7)2
7−1
=
21384.06612
= 7.376
2899.283387
Use v = 7 degrees of freedom.
Test Statistic
t=
(x̄2 − x̄1 ) − d0
(110 − 97.4) − (10)
q 2
= q
= 0.215
2
s1
s2
8.8772
30.2212
+
+
5
7
n1
n2
10
• Define the critical region.
α = 0.10. We have
−tα (v) = t0.10 (7) = 1.415.
Our critical region is:
Reject H0 if t > 1.415.
Since 0.215 6> 1.415, we Do Not Reject H0 . There is not enough evidence that
the average running time of films produced by company 2 is more than the average
running time of films produced by company 1 by more than 10 minutes.
Option 2:
H0 : µ1 − µ2 = −10
H1 : µ1 − µ2 < −10 • Is the data paired? No. • Are the population variances known or unknown? If they are unknown, are they equal? They are unknown and assumed to be unequal. Use Case 2 information. • Sample Information n1 = 5 x̄1 = 97.4 σ1 = 8.877 n2 = 7 x̄2 = 110 σ2 = 30.221 • Calculate your test statistic. Degrees of Freedom v= (s21 /n1 + s22 /n2 )2 (s21 /n1 )2 (s2 /n )2 + n2 2 −12 n1 −1 = 8.8772 5 (8.8772 /5)2 5−1 + + 30.2212 7 2 (30.2212 /7)2 = 7−1 21384.06612 = 7.376 2899.283387 Use v = 7 degrees of freedom. Test Statistic t= (x̄1 − x̄2 ) − d0 (97.4 − 110) − (−10) q 2 = q = −0.215 2 s1 s2 8.8772 30.2212 + + 5 7 n1 n2 • Define the critical region. α = 0.10. We have −tα (v) = −t0.10 (7) = −1.415. Our critical region is: Reject H0 if t < −1.415. 11 • Make your decision and state your conclusion. Since −0.215 6< −1.415, we Do Not Reject H0 . There is not enough evidence that the average running time of films produced by company 2 is more than the average running time of films produced by company 1 by more than 10 minutes. (b) Perform a hypothesis test. Use the p-value method to make your decision, with the cutoff value being the level of significance. Solution: Option 1: • State your hypotheses. H0 : µ2 − µ1 = 10 H1 : µ2 − µ1 > 10
• Is the data paired?
No.
• Are the population variances known or unknown? If they are unknown, are they
equal?
They are unknown and assumed to be unequal. Use Case 2 information.
• Sample Information
n1 = 5 x̄1 = 97.4 σ1 = 8.877
n2 = 7 x̄2 = 110 σ2 = 30.221
Degrees of Freedom

v=
(s21 /n1 + s22 /n2 )2
(s21 /n1 )2
n1 −1
+
(s22 /n2 )2
n2 −1
=
8.8772
5
(8.8772 /5)
5−1
2
2
+
30.2212
7
+
(30.2212 /7)2
7−1
=
21384.06612
= 7.376
2899.283387
Use v = 7 degrees of freedom.
Test Statistic
t=
(x̄2 − x̄1 ) − d0
(110 − 97.4) − 10
q 2
= q
= 0.215
2
s1
s2
8.8772
30.2212
+
+
5
7
n1
n2
• Calculate the p-value.
(
= tcdf(0.215, 999, 7) = 0.4179
p-value = P (T > 0.215)
> 0.40
12
via calculator
via table
Since our p-value is large (even larger than our cutoff value of 0.10), we Do Not Reject
H0 . There is not enough evidence that the average running time of films produced
by company 2 is more than the average running time of films produced by company
1 by more than 10 minutes.
Option 2:
H0 : µ1 − µ2 = −10
H1 : µ1 − µ2 < −10 • Is the data paired? No. • Are the population variances known or unknown? If they are unknown, are they equal? They are unknown and assumed to be unequal. Use Case 2 information. • Sample Information n1 = 5 x̄1 = 97.4 σ1 = 8.877 n2 = 7 x̄2 = 110 σ2 = 30.221 • Calculate your test statistic. Degrees of Freedom v= (s21 /n1 + s22 /n2 )2 (s2 /n )2 (s21 /n1 )2 + n2 2 −12 n1 −1 = 8.8772 5 (8.8772 /5)2 5−1 + + 30.2212 7 2 (30.2212 /7)2 7−1 = 21384.06612 = 7.376 2899.283387 Use v = 7 degrees of freedom. Test Statistic t= (x̄1 − x̄2 ) − d0 (97.4 − 110) − (−10) q 2 = q = −0.215 2 s1 s2 8.8772 30.2212 + + 5 7 n1 n2 • Calculate the p-value. ( = tcdf(−999, −0.215, 7) = 0.4179 p-value = P (T < −0.215) > 0.40
via calculator
via table
Since our p-value is large (even larger than our cutoff value of 0.10), we Do Not Reject
H0 . There is not enough evidence that the average running time of films produced
by company 2 is more than the average running time of films produced by company
1 by more than 10 minutes.
13
Example 12 (Math Finals). Having done poorly on their math final exam in June, 6 students
repeat the course in summer school and take another exam in August. Assume these students
are representative of all students who might attend his summer school. Assume a Normal
Distribution. We obtain the following data:
Student
1
2
3
4
5
6
June Percentage
54
49
68
66
62
62
August Percentage
50
65
74
64
68
72
We want to test the hypothesis that the average difference in student test scores in June are
different from the test scores in August. Use a significance level of 0.05.
(a) Perform a hypothesis test. Use the critical region method to make your decision.
Solution:
H0 : µD = 0
versus
µD 6= 0.
• Is the data paired?
Yes.
• Sample Information
Student
1
2
3
4
5
6
June Percentage
54
49
68
66
62
62
August Percentage August – June
50
−4
65
16
74
6
64
−2
68
6
72
10
¯
d
5.333
sd
7.448
Degrees of Freedom
v =n−1=6−1=5
Test Statistic
t=
d¯ − d0
5.333 − 0
√ =
√ = 1.754.
sd / n
7.448/ 6
14
• Define the critical region. α = 0.05. We have
−tα/2 (n − 1) = −t0.025 (5) = −2.571;
tα/2 (n − 1) = t0.025 (5) = 2.571.
Our critical region is:
Reject H0 if t < −2.571 or t > 2.571.
Since 1.754 6> 2.571, Do Not Reject H0 . There is not enough evidence that the
average difference in student test scorers from June to August are different.
(b) Perform a hypothesis test. Use the p-value method to make your decision, with the cutoff
value being the level of significance.
Solution:
H0 : µD = 0
versus
µD 6= 0.
• Is the data paired?
Yes.
• Sample Information
Student
1
2
3
4
5
6
June Percentage
54
49
68
66
62
62
August Percentage August – June
50
−4
65
16
74
6
64
−2
68
6
72
10

5.333
sd
7.448
Degrees of Freedom
v =n−1=6−1=5
Test Statistic
t=
5.333 − 0
d¯ − d0
√ =
√ = 1.754.
sd / n
7.448/ 6
• Calculate the p-value.
p-value = 2 · P (T > |1.754|)
(
= 2 · tcdf(1.754, 999, 5) = 0.1398
= 2 · P (T > 1.754)
∈ 2 · (0.05, 0.10) = (0.10, 0.20)
15
via calculator
via table
Since our p-value is large (even larger than our cutoff), we Do Not Reject H0 . There
is not enough evidence that the average difference in student test scores from June
to August are different.
(c) It is possible to find our 95% CI for µD to be
−2.484 < µD < 13.15. Use this confidence interval to perform your hypothesis test. Solution: Our hypotheses are H0 : µD = 0 versus µD 6= 0. Our hypothesis is a 2-sided hypothesis. We have α = 0.05. This corresponds directly to a 95% confidence interval. In our case, we have d0 = 0. Therefore, we look to see if 0 is within our interval. Since 0 is within our interval, we Do Not Reject H0 . There is not enough evidence that the average difference in student test scores from June to August are different. 16 Purchase answer to see full attachment User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

## Reviews, comments, and love from our customers and community

### Article Writing

Great service so far. Keep doing what you do, I am really impressed by the work done.

Researcher

### PowerPoint Presentation

I am speechless…WoW! Thank you so much! Definitely, the writer is talented person. She provided me with an essay a day early before the due date!

#### Stacy V.

Part-time student

### Dissertation & Thesis

This was a very well-written paper. Great work fast. I was in pretty desperate need for help to finish this paper before the due date, which was in nine hours.

Student

### Annotated Bibliography

I love working with this company. You always go above and beyond and exceed my expectations every time. Kate did a WONDERFUL job. I would highly recommend her.

Student

### Book Report / Review

I received my order wayyyyyyy sooner than I expected. Couldn’t ask for more. Very good at communicating & fast at replying. And change & corrections she put in the effort to go back and change it!

Student

### Essay (Any Type)

On time, perfect paper. All concerns & matters I had Tom was able to answer them! I will definitely provide him with more orders!

Student

### Case Study

Awesome! Great papers, and early! Thank you so much once again! Definitely recommend to trust James with your assignments! He won’t disappoint!

#### Kaylin Green

Student

Thank you Dr. Rebecca for editing my essays! She completed my task literally in 3 hours. For sure will work with her again, she is great and follows all instructions

Researcher

### Critical Thinking / Review

Extremely thorough summary, understanding and examples found for social science readings, with edits made as needed and on time. It’s like having a tutoring service available (:

Customer

### Coursework

Perfect!I only paid about \$80, which i think was a good price considering what my paper entailed. My paper was done early and it was well written!

Student