def validateAICModelSelection(DummyEmp): """Create a DataFrame containing AIC scores of all standard models. Only NoGender at this stage. Parameters ---------- DumyEmp : pandas DataFrame, Dummy emperical data frame as generated by generateDummyDataFrame() Returns: pandas DataFrame, Sorted AIC scores for different Delta's and model types """ AICFrame = pd.DataFrame(columns = ['Delta','k','ll','AIC']) CatEmp = DummyEmp.mul(1) Deltas = [1,2,3,4,5,10] #Generate all the refactorings: CatEmps = [ oboM.changePeriod(CatEmp,Delta) for Delta in Deltas]*2 #*2 as one for Dep and one for Indep CatModsDep = [ oboM.generateDependentModelLaplace(CatEmp, Delta=Delta) for Delta in Deltas ] CatModsIndep = [ oboM.generateIndependentModel(CatEmp, Delta=Delta) for Delta in Deltas ] CatMods = CatModsDep + CatModsIndep #For all generated model types on all deltas for c,CatMod in enumerate(CatMods): ModType = 'Dependent' if (c < len(CatMods)/2) else 'Independent' if 'Dependent' in ModType: k = (9-1)*(7-1)*CatMod.shape[0] elif 'Independent' in ModType: k = (9+7-2)*CatMod.shape[0] else: print('Oh deary me') return ll = oboM.loglikilyhood(CatEmps[c], CatMod) AIC = 2*k - 2*ll AICFrame.loc[c] = [ ModType + ' Delta = ' + str(Deltas[int(c%(len(CatMods)/2))]), k, ll, AIC] ##print('{}, years: {}, model index {}, k {}, log-likelihood {}, AIC {}'.format(file,fileYearDelta,DeltasIndex,k,ll, AIC)) ##print('{} loaded'.format(file)) #except: #print('{} failed to load'.format(file)) ##Return the frame return AICFrame.sort('AIC')