Practical 9

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Practical 9 – CP2403

(Please ensure you show your work to your tutor once completed as each practical is 3
marks.)

Part 1 – Download the Jupyter notebook for Module 9 and run the notebook

Part 2
Download the Jupyter Notebook Template for Prac 9 from LearnJCU. Complete the template
& run the code. Refer to Module 9 Lecture Jupyter Notebook for help
Complete the questions in Part 3 as you work on the Prac 9 template

Part 3
Scenario 1
Beer dependency (S2BQ1B1 - Categorical Explanatory variable) and Beer drinking
frequency in a month (BEER_FEQMO - Quantitative Response variable
1: Regression Analysis result
OLS Regression Results
==============================================================================
Dep. Variable: NUMBEERMO_EST R-squared: 0.027
Model: OLS Adj. R-squared: 0.027
Method: Least Squares F-statistic: 197.7
Date: Mon, 31 Dec 2018 Prob (F-statistic): 2.49e-44
Time: 12:43:17 Log-Likelihood: -38303.
No. Observations: 7226 AIC: 7.661e+04
Df Residuals: 7224 BIC: 7.662e+04
Df Model: 1
Covariance Type: nonrobust
==============================================================================
coef std err t P>|t| [0.025 0.975]
------------------------------------------------------------------------------
Intercept 25.5414 0.592 43.143 0.000 24.381 26.702
S2BQ1B1 31.3361 2.228 14.062 0.000 26.968 35.704
==============================================================================
Omnibus: 7487.162 Durbin-Watson: 2.030
Prob(Omnibus): 0.000 Jarque-Bera (JB): 617395.248
Skew: 5.091 Prob(JB): 0.00
Kurtosis: 47.124 Cond. No. 3.93
==============================================================================

2: Regression equation

Number of drinking beer = 25.5414 + 31.3361 * S2BQ1B1

3. Conclusion
Mean
NUMBEERMO_EST
S2BQ1B1
0.000000 25.541394
1.000000 56.877451
Standard deviation
NUMBEERMO_EST
S2BQ1B1
0.000000 44.356007
1.000000 86.321327

If someone is addicted to drink beer, S2BQ1B1 = 1


- Number of drinking beer = 25.5414 + 31.3361 * (1) = 56.8775
If someone is not addicted to drink beer, S2BQ1B1 = 0
- Number of drinking beer = 25.5414 + 31.3361*(0) = 25.5414

Conclusion: People who are addicted to drink beer will drink about 31 more beer
than those who are not addicted.

4. Bar Chart
Scenario 2
Perform Logistical Regression analysis between beer dependency (y=S2BQ1B1) and
general anxiety (x=GENAXLIFE).
1: Regression Analysis results
Optimization terminated successfully.
Current function value: 0.212712
Iterations 7
Logit Regression Results
==============================================================================
Dep. Variable: S2BQ1B1 No. Observations: 10406
Model: Logit Df Residuals: 10404
Method: MLE Df Model: 1
Date: Mon, 31 Dec 2018 Pseudo R-squ.: 0.007208
Time: 12:47:52 Log-Likelihood: -2213.5
converged: True LL-Null: -2229.6
LLR p-value: 1.434e-08
==============================================================================
coef std err z P>|z| [0.025 0.975]
------------------------------------------------------------------------------
Intercept -2.8998 0.045 -64.130 0.000 -2.988 -2.811
GENAXLIFE 0.8948 0.144 6.227 0.000 0.613 1.176
==============================================================================

2: Lower Confidence Interval, Upper Confidence Interval, Odds Ratio

Lower CI Upper CI OR
Intercept 0.050367 0.060134 0.055034
GENAXLIFE 1.846265 3.242687 2.446806

3. Conclusion

People with general anxiety are 2.44 times more like to be beer dependent compare to
people without general anxiety
Scenario 3
Perform Logistical Regression analysis between beer dependency (y=S2BQ1B1) and
general anxiety (x1=GENAXLIFE) and minor depression (x2=DYSLIFE).
1: Regression Analysis results
Optimization terminated successfully.
Current function value: 0.212607
Iterations 7
Logit Regression Results
==============================================================================
Dep. Variable: S2BQ1B1 No. Observations: 10406
Model: Logit Df Residuals: 10403
Method: MLE Df Model: 2
Date: Mon, 31 Dec 2018 Pseudo R-squ.: 0.007697
Time: 12:49:13 Log-Likelihood: -2212.4
converged: True LL-Null: -2229.6
LLR p-value: 3.524e-08
==============================================================================
coef std err z P>|z| [0.025 0.975]
------------------------------------------------------------------------------
Intercept -2.9099 0.046 -63.488 0.000 -3.000 -2.820
GENAXLIFE 0.8070 0.156 5.162 0.000 0.501 1.113
DYSLIFE 0.2638 0.174 1.513 0.130 -0.078 0.606
==============================================================================

2: Lower Confidence Interval, Upper Confidence Interval, Odds Ratio

Lower CI Upper CI OR
Intercept 0.049798 0.059600 0.054479
GENAXLIFE 1.649620 3.044656 2.241099
DYSLIFE 0.924975 1.832270 1.301846

3. Conclusion

People with general anxiety are 2.24 times more like to be beer dependent compare to
people without general anxiety, after controlling for minor depression.

People with minor depression are 1.3 times more like to be beer dependent compare to
people without minor depression, after controlling for general anxiety.
Scenario 4
Perform Logistical Regression analysis between beer dependency (y=S2BQ1B1) and
panic disorder (x=PANIC).
1: Regression Analysis results
Optimization terminated successfully.
Current function value: 0.213531
Iterations 7
Logit Regression Results
==============================================================================
Dep. Variable: S2BQ1B1 No. Observations: 10406
Model: Logit Df Residuals: 10404
Method: MLE Df Model: 1
Date: Mon, 31 Dec 2018 Pseudo R-squ.: 0.003385
Time: 12:50:35 Log-Likelihood: -2222.0
converged: True LL-Null: -2229.6
LLR p-value: 0.0001023
==============================================================================
coef std err z P>|z| [0.025 0.975]
------------------------------------------------------------------------------
Intercept -2.8917 0.046 -62.875 0.000 -2.982 -2.802
PANIC 0.5210 0.127 4.102 0.000 0.272 0.770
==============================================================================

2: Lower Confidence Interval, Upper Confidence Interval, Odds Ratio

Lower CI Upper CI OR
Intercept 0.050699 0.060715 0.055481
PANIC 1.312633 2.159621 1.683684

3. Conclusion

People with panic disorder are 1.68 times more like to be beer dependent compare to
people without panic disorder.
Scenario 5
Perform Logistical Regression analysis between beer dependency (y=S2BQ1B1) and
panic disorder (x1=PANIC) and minor depression (x2=DYSLIFE).

1: Regression Analysis results


Optimization terminated successfully.
Current function value: 0.213222
Iterations 7
Logit Regression Results
==============================================================================
Dep. Variable: S2BQ1B1 No. Observations: 10406
Model: Logit Df Residuals: 10403
Method: MLE Df Model: 2
Date: Mon, 31 Dec 2018 Pseudo R-squ.: 0.004828
Time: 12:51:17 Log-Likelihood: -2218.8
converged: True LL-Null: -2229.6
LLR p-value: 2.113e-05
==============================================================================
coef std err z P>|z| [0.025 0.975]
------------------------------------------------------------------------------
Intercept -2.9109 0.047 -62.201 0.000 -3.003 -2.819
PANIC 0.4432 0.131 3.373 0.001 0.186 0.701
DYSLIFE 0.4380 0.165 2.655 0.008 0.115 0.761
==============================================================================

2: Lower Confidence Interval, Upper Confidence Interval, Odds Ratio

Lower CI Upper CI OR
Intercept 0.049659 0.059658 0.054429
PANIC 1.203973 2.015228 1.557652
DYSLIFE 1.121488 2.141030 1.549561
3. Conclusion

People with panic disorder are 1.5 times more like to be beer dependent compare to people
without panic disorder, after controlling for minor depression.

People with minor depression are 1.54 times more like to be beer dependent compare to
people without minor depression, after controlling panic disorder.

You might also like