# Statistics assignment in R

Statisticsassignment in R

Student`sname

PartB:

1. Input and print the HeartAttack dataset.

ha2&lt-c(1,1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

ha2

[1]1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0

ang&lt-c(1,1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0)

ang

[1]1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0

sco&lt-c(70,80, 50, 60, 40, 65, 75, 80, 70, 60, 65, 50, 45, 35, 40, 50, 55, 45,50, 60)

sco

[1]70 80 50 60 40 65 75 80 70 60 65 50 45 35 40 50 55 45 50 60

1. Type the logit model equation for predicting the probability that a patient has a second attack (ha2) from ang and sco. (See the dataset for the meanings of these variables.)

#Runthe code below.

mylogit&lt-glm(ha2~ang+sco,family=&quotbinomial&quot)

mylogit

#Andthe equation is:

ha2=-6.363-1.024ang+0.199sco

1. Find the predicted probability of having a second heart attack for each observation.

#Runthe code below.

predict(mylogit,type=&quotresponse&quot)

#Andthe probabilities are as follows:

1 234 5 6

0.72022303 0.89435490 0.19226955 0.68551307 0.16774789 0.79809811

7

0.92856807

8 910111213

0.959305760.87757611 0.68551307 0.58670090 0.19226955 0.11603202

14

0.03838292

15 16 17 18 19 20

0.067497630.19226955 0.54587077 0.26767543 0.39861864 0.68551307&nbsp

1. If a new patient has ang=1 and sco=35, calculate the probability of a second heart attack, using R

#Runthe code below:

predict(mylogit,data.frame(ang=1,sco=35),type=&quotresponse&quot)

#Andthe probability is:

0.03838292

&nbsp