Question: A data.frame: 1 5 times 5 pH nisin temp brix growth 1 5 . 5 7 0 4 3 1 9 0 2 5

A data.frame: 15\times 5
pH nisin temp brix growth
15.57043190
25.55043131
35.55035151
45.53035131
55.53025110
65.5050190
75.5025151
83.57043150
93.57035110
103.55050130
113.55035190
123.53050110
133.53043150
143.5025190
155.07025150
Call:
glm(formula = growth ~ pH + nisin + temp + brix, family = "binomial",
data = apple.data)
Deviance Residuals:
Min 1Q Median 3Q Max
-2.3245-0.4325-0.14150.53081.5593
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept)-7.683633.28201-2.3410.019225*
pH 2.049080.574813.5650.000364***
nisin -0.062730.01910-3.2830.001026**
temp 0.125320.050792.4670.013614*
brix -0.380000.15909-2.3890.016915*
---
Signif. codes: 0***0.001**0.01*0.05.0.11
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 95.072 on 72 degrees of freedom
Residual deviance: 49.844 on 68 degrees of freedom
AIC: 59.844
Number of Fisher Scoring iterations: 6
1. The Effects of Temp (The correct code for question 1 is shown below. Please help me answer question 2)
What if we want to determine how a specific predictor affects the probability (or odds, in the Logistic Regression case) of growth=1? One idea would be to calculate the odds of growth, given different levels of that predictor, while keeping all other predictors constant. Then we could compare the difference between the odds, to see if a larger predictor resulted in a larger probability.
Using your model, calculate the odds of growth with a temperature at the first quartile and at the third quartile, assuming all other features are held constant. Then calculate the difference between the two and store that value as temp.odds.diff.
To calculate this difference, it may be helpful to first think through this equation. Note that oi is the odds of growth for the it quantile.
d=o1/o3= exp(log(o1/o3))= exp(n1n3)=...
If we let this difference be d, then this value can be interpreted as "The odds of showing evidence of growth is d% more/less when the temperature is in the first quantile than in the third quantile, when adjusted for other predictors."
mod1<- predict(glmod.apple, newdata = data.frame(temp = quantile(apple.data$temp, 0.25),
pH = mean(apple.data$pH),
nisin = mean(apple.data$nisin),
brix = mean(apple.data$brix)))
mod3<- predict(glmod.apple, newdata = data.frame(temp = quantile(apple.data$temp, 0.75),
pH = mean(apple.data$pH),
nisin = mean(apple.data$nisin),
brix = mean(apple.data$brix)))
odds_first <- exp(mod1)
odds_third <- exp(mod3)
temp.odds.diff = odds_first / odds_third
temp.odds.diff =0.366951038477902
2. But there's more than that.
Remember, we're assuming all of our predictors come from some distribution, meaning there is some inherent randomness in our values and calculations. A point-value is only so helpful. If we really want to understand the difference, we should calculate the range of values that the difference could potentially fall within.
Calculate the 95% confidence interval for this difference. Store the lower bound in temp.odds.lower and the upper bound in temp.odds.upper.
Hint: You can get the Standard Error of temp from your model.
temp.odds.lower = NA
temp.odds.upper = NA
# your code here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!