代写ECON10071/20071 - 2023/24 Week 9 - Practice Exercises调试R语言程序

2025-05-08 代写ECON10071/20071 - 2023/24 Week 9 - Practice Exercises调试R语言程序

ECON10071/20071 - 2023/24

Week 9 - Practice Exercises

Hypothesis Testing and Confidence Intervals

1.  The YouGov Voting Intention opinion poll (for end of March 2023) delivers the following table of results to the question ”Which of the following do you think would make the best Prime Minister?”.

Obs Percentages

Prime Minister

Age   18-24

 

25-49

 

50-64

 

65+

Rishi Sunak

18%

19%

27%

42%

Keir Starmer

28%

34%

30%

25%

Not Sure

41%

42%

41%

31%

Refused

13%

5%

2%

2%

Total

100%

100%

100%

100%

Test whether the variables (preferred prime minister, P , and age, A) are independent.

2.  In order to see whether their random sample  has the same average age as the intended population (voting age population), YouGov wishes to calculate a confidence interval for the average age, µ, using a sample of n = 2003.  Calculate a 99% confidence interval. The sample average age is 46.3 years.  From excellent population data from the last census we know that the population variance in age is σ 2  = 90.

3.  Using the same data, calculate a 95% confidence  interval for the population percentage of Rishi Sunak and  Keir Starmer supporters amongst the  19 to 24 year olds  (separate confidence intervals for both party leaders). 

Test whether the variables (preferred prime minister, P , and age, A) are independent.

Age

18-24    25-49    50-64    65+    Total

Total    210      827      495      471    2003

Obs number

Prime Minister(Pi )

Age(Aj ) 18-24

 

25-49

 

50-64

 

65+

 

Total

Rishi Sunak

38

157

 

198

 

Keir Starmer

59

 

149

118

 

Not Sure

86

347

203

146

782

Refused

27

41

10

9

88

Total

210

827

495

471

2003

Expected number   Prime Minister(Pi )

Age(Aj ) 18-24

 

25-49

 

50-64

 

65+

Rishi Sunak

55.1473

217.1752

 

123.6875

Keir Starmer

63.5347

 

149.7604

142.4993

Not Sure

81.9870

322.8727

193.2551

183.8852

Refused

9.2262

36.3335

21.7474

20.6930

Joint probabilities   Prime Minister(Pi )

Age (Aj ) 18-24

 

25-49

 

50-64

 

65+

 

Pr(Pi )

Rishi Sunak

0.0275

0.1084

 

0.0618

 

Keir Starmer

0.0317

 

0.0748

0.0711

 

Not Sure

0.0409

0.1612

0.0965

0.0918

0.3904

Refused

0.0046

0.0181

0.0109

0.0103

0.0439

Pr(Aj )

0.1048

 

 

0.2351

1