<jupyter_start><jupyter_text>Import the relevant modules<jupyter_code>import pandas as pd
import statsmodels.api as sm
import scipy.stats<jupyter_output><empty_output><jupyter_text>Load and visualize the data<jupyter_code>bones = ['femur', 'tibia', 'patella']
variabledict = {bone:{} for bone in bones}
for bone in bones:
    variabledict[bone] = pd.read_csv(f'../data/stats/{bone}logisticvariables.csv')<jupyter_output><empty_output><jupyter_text>Show process for Femur<jupyter_code>bone = 'femur'
variabledict[bone].columns<jupyter_output><empty_output><jupyter_text>Fit Logistic Regression Models<jupyter_code>classicalX = variabledict[bone].iloc[:,:-2]
dlguidedX = variabledict[bone].iloc[:,:-1]
outcome = variabledict[bone].Outcome

smclassicalX = sm.add_constant(classicalX)
smdlguidedX = sm.add_constant(dlguidedX)

smLRclassical = sm.Logit(outcome, smclassicalX)
smLRdlguided = sm.Logit(outcome, smdlguidedX)

smLRclassicalfit = smLRclassical.fit()
smLRdlguidedfit = smLRdlguided.fit()<jupyter_output>Optimization terminated successfully.
         Current function value: 0.609721
         Iterations 5
Optimization terminated successfully.
         Current function value: 0.576531
         Iterations 5<jupyter_text>Show model statistics<jupyter_code>smLRclassicalfit.summary()
smLRdlguidedfit.summary()<jupyter_output><empty_output><jupyter_text>Likelihood Ratio $\chi^2$ test<jupyter_code>scipy.stats.chi2.sf(2*(smLRdlguidedfit.llf - smLRclassicalfit.llf), 1)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup