代写Exercise 2代做Python编程

2024-07-16 代写Exercise 2代做Python编程

1.Table 1 is a 2×2×2 contingency table which studied the effects of racial charac- teristics on the death penalty verdict.The victims'race (V),defendants'race (D) and death penalty(P)are three binary variables.

Table 1:Death penalty verdict by defendants race and victims race

Death Penalty

Victims'Race

Defendants'Race

Yes

No

White

White

53

414

Black

11

37

Black

White

1

16

Black

4

139

(a)Hand calculate the expected frequencies,the Pearson chi-square statistic,the   degree of freedom under the total independence of V,D,and P.Report the total independence test result at the 5%significance level.Do you think the test result is appropriate? [5 marks]

(b)Hand calculate the expected frequencies,the Pearson chi-square statistic,the  degree of freedom under the group independence between (V,D)and P.Re- port the group independence test result at the 5%significance level.[5  marks]

(c)Hand calculate the expected frequencies,the Pearson chi-square statistic,the  degree of freedom under the conditional independence between D and P given V.Report the conditional independence test result at the 5%significance level. [5 marks]

(d)Hand calculate the expected frequencies,the Pearson chi-square statistic,the   degree of freedom under the marginal independence between V and P.Report  the marginal independence test result at the 5%significance level.[5 marks]

(e)Comment on the test results. [5  marks]

[Total:25 marks]

2.The   dataset    Neuralgia   contains    five   variables:Treatment,Sex,Age,Duration, and  Pain.The  last  variable,Pain=Yes,No,is  the  response  variable.Treatment  is a categorical variable with three levels A,B and P.Sex represents the gender of the patients and has two levels F and M.The Age and Duration are two continuous variables.The SAS outputs from the SAS proc logistic are given as follows.

Response Profile

Ordered Value

Pain

Total Frequency

1

No

35

2

Yes

25

Probability modeled is Pain='No'.

Class Level Information

Class

Value

Design Variables

Treatment

A

0

B

0

1

P

0

0

Sex

F

1

M

0

Testing Global Null Hypothesis:BETA=0

Test

Chi-Square

DF

Pr>ChiSo

Likelihood Ratio

32.9074

7

<.0001

Score

25.6812

7

0.0006

Wald

14.2879

7

0.0463

Analysis of Maximum Likelihood Estimates

Parameter

DF

Fstimate

Standard Error

Wald Chi-Square

Pr>ChiSq

Intercept

1

15.8108

6.6978

5.5725

0.0182

Treatment

A

3.5448

1.5135

5.4853

0.0192

Treatment

B

3.9417

1.6123

5.9771

0.0145

Sex

F

1

2.1392

1.3958

2.3490

0.1254

Treatment*Sex

A

F

-0.7067

1.9377

0.1330

0.7153

Treatment*Sex

B

F

-0.2072

1.9361

0.0114

0.9148

Age

-0.2688

0.0996

7.2744

0.0070

Duration

0.00523

0.0333

0.0247

0.8752

(a)The procedure models the probability of which event?Write down the fitted logistic model                    [4  marks]

(b)What is the null hypothesis for Global Null Hypothesis?Report the global null hypothesis test result at the  5%significance level.Is the  sample  size sufficiently large?                   [4 marks]

(c)Consider the following two patients with

(i)Treatment=P,Sex=M,Age=30,Duration=5; (ii)Treatment=B,Sex=F,Age=50,Duration=10.

Write down the coefficients of contrast for patient (i);patient (ii);and (i)vs (ii).Report  the  odds  ratio  of  (i)vs  (ii)as  well  as  the  corresponding  95% confidence interval and provide appropriate interpretations. [9 marks]

(d)What is the null hypothesis for the following TEST statement?

test  SexF  +TreatmentASexF  =0,SexF  +TreatmentBSexF  =0;

Report the test result at the 5%significance level. [4 marks]

(e)Report the result of the Hosmer-Lemeshow lack-of-fit test at the 5%signif- cance level.The lack-of-fit test yields p=0.4390 for the probit link function.  Which link function fits better? [4 marks] [Total:25 marks]