This is written using rStudio only. Please only help if you are using that program with explanations please. Thank you Here are all instructions with
This is written using rStudio only. Please only help if you are using that program with explanations please. Thank you
Here are all instructions with questions. The data frame being used will be provided at the bottom of this question.
## Load all packages used in this assignment in the code following chunk.
```{r, message=FALSE}
```
# Anesthesia
A study was conducted whereby the type of anesthetic (A or B), nausea after the surgery (Yes or No), the amount of pain medication taken during the recovery period, and age for a random sample of 72 patients undergoing reconstructive knee surgery.
The data is in the file "anesthesia" AT THE BOTTOM OF THE PAGE
Load the data and obtain the output from R for the logistic regression model with nausea as the response variable and the type of anesthetic as the explanatory variable. Summarize it using summary() function.
Use this model to address questions 1-5 below.
Note: "Yes" should correspond to Y=1 for the response and anesthetic A should be the reference category in the model.
## Question 1 (1 point)
Is the coefficient of anesthetic (labeled as anestheticB in the output) statistically significantly different from 0 at a 5% level of significance? (Yes or No)
## Question 2 (2 points)
Report the p-value for the hypothesis test on that coefficient. Round it to 4 decimal places.
Convert the estimated coefficient of anestheticB to an odds ratio. select the correct interpretation of it.
## Question 3 (2 points)
Select the correct interpretation of the odds ratio computed directly from the coefficient of anestheticB.
a. The odds of having nausea with anesthetic B are 4.6 times the odds of having nausea when using anesthetic A.
b. The odds of having nausea with anesthetic A are 0.217 times the odds of having nausea when using anesthetic B.
c. The odds of having nausea with anesthetic A are 21.7% more than for anesthetic B.
d. The odds of having nausea with anesthetic B are 78.3% less than for anesthetic A.
e. The odds of having nausea with anesthetic B are -1.526 times the odds of having nausea when using anesthetic A.
## Question 4 (1 point)
Report the AIC for the logistic regression model with nausea as the response variable and the type of anesthetic as the explanatory variable. Round it to 1 decimal place.
## Question 5 (1 point)
Compute the McFadden pseudo-$R^2$ for the logistic regression model with nausea as the response variable and the type of anesthetic as the explanatory variable. Round it to 3 decimal places.
Fit the logistic regression model with nausea as the response variable and only the amount of pain medication (painmed) as the explanatory variable. Summarize it using summary() function. Use this model to address questions 6-10 below.
## Question 6 (2 points)
Is the coefficient of painmed statistically significantly different from 0 at a 5% level of significance?
(Yes or No)
## Question 7 (2 points)
Report the p-value for the hypothesis test on that coefficient. Round it to 4 decimal places.
Convert the estimated coefficient of painmed to an odds ratio. select the correct interpretation of it.
## Question 8 (2 points)
Select the correct interpret ion of the odds ratio computed directly from the coefficient of painmed.
a. The odds of having nausea increase by a factor of 1.038 for each unit increase in painmed.
b. The odds of having nausea increase by a factor of 0.037 for each unit increase in painmed.
c. The odds of having nausea decrease by a factor of 1.038 for each unit increase in painmed.
d. The odds of having nausea increase by 0.037 for each unit increase in painmed.
e. The odds of having nausea decrease by 1.038 for each unit increase in painmed.
## Question 9 (1 point)
Report the AIC for the logistic regression model with nausea as the response variable and the amount of pain medication as the explanatory variable. Round it to 1 decimal place.
## Question 10 (1 point)
Compute the McFadden pseudo-$R^2$ for the logistic regression model with nausea as the response variable and the amount of pain medication as the explanatory variable. Round it to 3 decimal places.
Fit the logistic regression model with nausea as the response variable and painmed, anesthetic and age as the explanatory variables. Summarize it using summary() function.
## Question 11 (2 points)
Select the explanatory variables for which the coefficient(s) are significantly different from 0 at a 5% level of significance.
a. painmed
b. anesthetic
c. age
Use the likelihood ratio test to compare the model with only painmed as the explanatory variable to the model containing all 3 explanatory variables. Use a 10% level of significance.
## Question 12 (2 points)
Choose the correct conclusion to the likelihood ratio test to compare the models.
a. The model with all three explanatory variables is not significantly better than the model with only painmed.
b. The model with only painmed is not significantly better than the model with all three explanatory variables.
c. The test is inconclusive.
## Question 13 (1 point)
Report the p-value for this likelihood ratio test to compare models. Round it to 3 decimal places.
Which model is "best"?
## Question 14 (2 points)
Select the model that is "best" according to the AIC.
a. The model with only painmed.
b. The model with only anesthetic.
c. The model with all three explanatory variables.
## Question 15 (2 points)
Select the model that is "best" according to the McFadden pseudo-$R^2$.
a. The model with only painmed.
b. The model with only anesthetic.
c. The model with all three explanatory variables.
Use the deviance goodness of fit test to test the fit of the model with only painmed as the explanatory variable. Use a 5% level of significance.
## Question 16 (2 points)
Choose the correct conclusion to the deviance goodness of fit test.
a. The model fits.
b. The model does not fit.
c. The test is inconclusive.
## Question 17 (2 points)
Report the p-value for this deviance goodness of fit test to compare models. Round it to 3 decimal places.
Using the model with only painmed as the explanatory variable, construct a 90% confidence interval for the odds ratio relating nausea to the amount of pain medication.
## Question 18 (2 points)
Report the upper bound for this confidence interval. Round it to 3 decimal places.
Here is the dataset (Anesthesia) Used in this Question:
age | painmed | anesthetic | nausea |
49.90136986 | 53.49 | A | No |
70.23561644 | 21.66 | A | No |
64.07123288 | 86.5 | A | No |
73.31506849 | 37.34 | A | No |
59.7260274 | 87 | A | No |
80.60821918 | 18.33 | A | No |
59.41643836 | 103.5 | A | No |
74.96712329 | 68.5 | A | No |
47.53424658 | 121.5 | A | No |
72.2630137 | 86.66 | A | No |
73.63013699 | 25 | A | No |
44.55342466 | 147 | A | No |
64.41643836 | 26.67 | A | No |
71.15616438 | 106.5 | A | Yes |
62.40821918 | 189 | A | Yes |
54.28219178 | 84 | A | Yes |
51.73424658 | 98 | A | Yes |
51.37808219 | 40 | B | No |
57.48219178 | 23.33 | B | No |
62.05753425 | 11.66 | B | No |
51.9369863 | 32.5 | B | No |
84.19726027 | 106 | B | No |
66.90958904 | 45.01 | B | No |
61.86849315 | 190 | B | No |
82 | 45 | B | No |
62.38356164 | 16.67 | B | No |
67.80547945 | 67.5 | B | No |
64.63013699 | 36.66 | B | No |
49.74520548 | 85 | B | No |
47.15890411 | 40 | B | No |
68.05753425 | 11.67 | B | No |
73.91506849 | 37.67 | B | No |
70.69315068 | 53.34 | B | No |
58.45205479 | 20 | B | No |
69.37260274 | 22.5 | B | No |
62.73150685 | 25 | B | No |
56.35616438 | 39.99 | B | No |
66.46575342 | 54.16 | B | No |
52.40821918 | 66.66 | B | No |
57.55616438 | 23.33 | B | No |
72.02739726 | 87.5 | B | Yes |
64.98630137 | 88 | B | Yes |
66.12876712 | 163 | B | Yes |
55.00547945 | 160 | B | Yes |
56.64657534 | 166.34 | B | Yes |
70.8109589 | 80.01 | B | Yes |
54.35068493 | 45 | B | Yes |
68.94794521 | 102 | B | Yes |
66.7890411 | 56.67 | B | Yes |
63.23561644 | 118.33 | B | Yes |
45 | 150 | A | Yes |
70 | 122 | A | Yes |
36 | 148 | A | Yes |
49 | 198 | A | Yes |
58 | 160 | A | Yes |
52 | 151 | A | Yes |
56 | 148 | A | Yes |
55 | 137 | A | Yes |
63 | 120 | A | Yes |
48 | 75 | A | Yes |
66 | 98 | A | Yes |
61 | 88 | A | Yes |
59 | 128 | A | Yes |
50 | 107 | A | Yes |
42 | 96 | A | Yes |
70 | 82 | A | Yes |
28 | 65 | A | Yes |
39 | 75 | A | Yes |
53 | 84 | A | Yes |
49 | 90 | A | Yes |
68 | 105 | A | Yes |
62 | 115 | A | Yes |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started