def setUp(self): self.oldJoe = Person( age=60, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_BLACK, sbp=140, dbp=90, a1c=5.5, hdl=50, totChol=200, bmi=25, ldl=90, trig=150, waist=45, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0, initializeAfib=initializeAFib, ) self.youngJoe = Person( age=40, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_BLACK, sbp=140, dbp=90, a1c=5.5, hdl=50, totChol=200, bmi=25, ldl=90, trig=150, waist=45, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0, initializeAfib=initializeAFib, )
def setUp(self): self._test_person = Person( age=75, gender=0, raceEthnicity=1, sbp=140, dbp=80, a1c=6.5, hdl=50, totChol=210, ldl=90, trig=150, bmi=22, waist=50, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=1, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0, initializeAfib=initializeAfib, ) self._risk_model_repository = TestRiskModelRepository()
def test_upper_bounds(self): highBPPerson = Person( age=75, gender=0, raceEthnicity=1, sbp=500, ldl=90, trig=150, dbp=80, a1c=6.5, hdl=50, totChol=210, bmi=22, waist=50, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=1, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0, initializeAfib=initializeAfib, ) highBPPerson.advance_risk_factors(self._risk_model_repository) self.assertEqual(300, highBPPerson._sbp[-1])
def setUp(self): self.joe = Person( 42, NHANESGender.MALE, NHANESRaceEthnicity.NON_HISPANIC_BLACK, 140, 90, 5.5, 50, 200, 25, 90, 150, 70, 0, Education.COLLEGEGRADUATE, SmokingStatus.NEVER, AlcoholCategory.NONE, 0, 0, 0, 0, initializeAFib, selfReportStrokeAge=None, selfReportMIAge=None, dfIndex=1, diedBy2015=0, )
def generate_starting_mean_patient(self): df = self.get_people_initial_state_as_dataframe() return Person( age=int(round(df.age.mean())), gender=NHANESGender(df.gender.mode()), raceEthnicity=NHANESRaceEthnicity(df.raceEthnicity.mode()), sbp=df.sbp.mean(), dbp=df.dbp.mean(), a1c=df.a1c.mean(), hdl=df.hdl.mean(), totChol=df.totChol.mean(), bmi=df.bmi.mean(), ldl=df.ldl.mean(), trig=df.trig.mean(), waist=df.waist.mean(), anyPhysicalActivity=df.anyPhysicalActivity.mode(), education=Education(df.education.mode()), smokingStatus=SmokingStatus(df.smokingStatus.mode()), antiHypertensiveCount=int(round(df.antiHypetensiveCount().mean())), statin=df.statin.mode(), otherLipidLoweringMedicationCount=int( round(df.otherLipidLoweringMedicationCount.mean())), initializeAfib=(lambda _: False), selfReportStrokeAge=None, selfReportMIAge=None, randomEffects=self._outcome_model_repository.get_random_effects(), )
def build_person(x, outcome_model_repository): return Person( age=x.age, gender=NHANESGender(int(x.gender)), raceEthnicity=NHANESRaceEthnicity(int(x.raceEthnicity)), sbp=x.meanSBP, dbp=x.meanDBP, a1c=x.a1c, hdl=x.hdl, ldl=x.ldl, trig=x.trig, totChol=x.tot_chol, bmi=x.bmi, waist=x.waist, anyPhysicalActivity=x.anyPhysicalActivity, smokingStatus=SmokingStatus(int(x.smokingStatus)), alcohol=AlcoholCategory.get_category_for_consumption(x.alcoholPerWeek), education=Education(int(x.education)), antiHypertensiveCount=x.antiHypertensive, statin=x.statin, otherLipidLoweringMedicationCount=x.otherLipidLowering, creatinine=x.serumCreatinine, initializeAfib=initializeAFib, initializationRepository=InitializationRepository(), selfReportStrokeAge=x.selfReportStrokeAge, selfReportMIAge=np.random.randint(18, x.age) if x.selfReportMIAge == 99999 else x.selfReportMIAge, randomEffects=outcome_model_repository.get_random_effects(), dfIndex=x.index, diedBy2015=x.diedBy2015 == True, )
def getPerson(self, age=65): return Person( age=age, gender=0, raceEthnicity=1, sbp=140, dbp=80, a1c=6.5, hdl=50, totChol=210, ldl=90, trig=150, bmi=22, waist=50, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=1, alcohol=0, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0, initializeAfib=TestQALYAssignment.initializeAfib, initializationRepository=InitializationRepository(), )
def get_or_init_population_dataframe(cls): if VectorizedTestFixture._population_dataframe is None: test_person = Person( age=71, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=144.667, dbp=52.6667, a1c=9.5, hdl=34, totChol=191, bmi=30.05, ldl=110.0, trig=128, waist=45, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.FORMER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0.6, initializeAfib=(lambda _: None), randomEffects={"gcp": 0}, ) base_gcp = GCPModel().get_risk_for_person(test_person) test_person._gcp.append([base_gcp]) VectorizedTestFixture._population_dataframe = init_vectorized_population_dataframe( [test_person]) return VectorizedTestFixture._population_dataframe
def build_person(x): return Person(age=x.age, gender=NHANESGender(int(x.gender)), raceEthnicity=NHANESRaceEthnicity(int(x.raceEthnicity)), sbp=x.meanSBP, dbp=x.meanDBP, a1c=x.a1c, hdl=x.hdl, ldl=x.ldl, trig=x.trig, totChol=x.tot_chol, bmi=x.bmi, waist=x.waist, anyPhysicalActivity=x.anyPhysicalActivity, smokingStatus=SmokingStatus(int(x.smokingStatus)), alcohol=AlcoholCategory.get_category_for_consumption( x.alcoholPerWeek), education=Education(int(x.education)), antiHypertensiveCount=x.antiHypertensive, statin=x.statin, otherLipidLoweringMedicationCount=x.otherLipidLowering, initializeAfib=initializeAFib, selfReportStrokeAge=x.selfReportStrokeAge, selfReportMIAge=x.selfReportMIAge, dfIndex=x.index, diedBy2015=x.diedBy2015)
def setUp(self): self.joe = Person(42, NHANESGender.MALE, NHANESRaceEthnicity.NON_HISPANIC_BLACK, 140, 90, 5.5, 50, 200, 25, 90, 150, 45, 0, Education.COLLEGEGRADUATE, SmokingStatus.NEVER, AlcoholCategory.NONE, 0, 0, 0, initializeAFib) self._always_positive_repository = AlwaysPositiveOutcomeRepository() self._always_negative_repository = AlwaysNegativeOutcomeRepository() self.cvDeterminer = CVOutcomeDetermination( self._always_positive_repository)
def setUp(self): self.imputed_dataset_first_person = Person(71, NHANESGender.MALE, NHANESRaceEthnicity.NON_HISPANIC_WHITE, 144.667, 52.6667, 9.5, 34, 191, 30.05, 110.0, 128, 45, 0, Education.COLLEGEGRADUATE, SmokingStatus.FORMER, AlcoholCategory.NONE, 0, 0, 0, initializeAFib) model_spec = load_model_spec("nhanesMortalityModel") self.model = StatsModelCoxModel(CoxRegressionModel(**model_spec))
def setUp(self): self.baselineSBP = 140 self.baselineDBP = 80 self._test_person = Person( age=75, gender=0, raceEthnicity=1, sbp=self.baselineSBP, dbp=self.baselineDBP, a1c=6.5, hdl=50, totChol=210, ldl=90, trig=150, bmi=22, waist=50, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=1, alcohol=0, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=TestTreatmentStrategy.initializeAfib) self._risk_model_repository = TestRiskModelRepository() # setup so that the SBP always stays the same self._risk_model_repository._repository['sbp']._params['age'] = 0 self._risk_model_repository._repository['sbp']._params['sbp'] = 1.0 self._risk_model_repository._repository['sbp']._params['intercept'] = 0 self._risk_model_repository._repository['dbp']._params['age'] = 0 self._risk_model_repository._repository['dbp']._params['dbp'] = 1.0 self._risk_model_repository._repository['dbp']._params['sbp'] = 0 self._risk_model_repository._repository['dbp']._params['intercept'] = 0 # setup so that the anti-hypertensive count stays at zero self._risk_model_repository._repository[ 'antiHypertensiveCount']._params['age'] = 0 self._risk_model_repository._repository[ 'antiHypertensiveCount']._params['sbp'] = 0 self._risk_model_repository._repository[ 'antiHypertensiveCount']._params['intercept'] = 0
def setUp(self): self.joe = Person( 42, NHANESGender.MALE, NHANESRaceEthnicity.NON_HISPANIC_BLACK, 140, 90, 5.5, 50, 200, 25, 90, 150, 45, 0, Education.COLLEGEGRADUATE, SmokingStatus.NEVER, AlcoholCategory.NONE, 0, 0, 0, 0, initializeAFib, ) self.joe_with_mi = copy.deepcopy(self.joe) self.joe_with_mi.add_outcome_event(Outcome(OutcomeType.MI, False)) self.joe_with_stroke = copy.deepcopy(self.joe) self.joe_with_stroke.add_outcome_event(Outcome(OutcomeType.STROKE, False)) self._population_dataframe = init_vectorized_population_dataframe( [self.joe, self.joe_with_mi, self.joe_with_stroke], with_base_gcp=True, ) self._always_positive_repository = AlwaysPositiveOutcomeRepository() self._always_negative_repository = AlwaysNegativeOutcomeRepository() self.cvDeterminer = CVOutcomeDetermination(self._always_positive_repository)
def getPerson(self, baselineSBP=140, baselineDBP=80): return Person( age=75, gender=0, raceEthnicity=1, sbp=baselineSBP, dbp=baselineDBP, a1c=6.5, hdl=50, totChol=210, ldl=90, trig=150, bmi=22, waist=50, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=1, alcohol=0, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0.0, initializeAfib=TestTreatmentStrategy.initializeAfib, )
def setUp(self): self.baseAge = 55 self.baseSBP = 120 self._white_male = Person( age=self.baseAge, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_male_copy_paste = Person( age=self.baseAge, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_male_plus_one_year = Person( age=self.baseAge + 1, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_female = Person( age=self.baseAge, gender=NHANESGender.FEMALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._black_female = Person( age=self.baseAge, gender=NHANESGender.FEMALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_BLACK, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_male_plus_sbp = Person( age=self.baseAge + 1, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP + 10, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_male_plus_dbp = Person( age=self.baseAge + 1, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=90, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_male_plus_a1c = Person( age=self.baseAge + 1, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=7, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_male_plus_hdl = Person( age=self.baseAge + 1, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=60, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_male_plus_totChol = Person( age=self.baseAge + 1, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=223, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_male_plus_ldl = Person( age=self.baseAge + 1, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=213, ldl=100, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_male_plus_trig = Person( age=self.baseAge + 1, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=160, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_male_plus_bmi = Person( age=self.baseAge + 1, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=25, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_male_plus_waist = Person( age=self.baseAge + 1, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=36, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_male_plus_activity = Person( age=self.baseAge + 1, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=1, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_male_minus_edudcation = Person( age=self.baseAge + 1, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=1, education=Education.HIGHSCHOOLGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_male_plus_smoking = Person( age=self.baseAge + 1, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=1, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.CURRENT, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_male_plus_bpMed = Person( age=self.baseAge + 1, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=1, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_male_plus_statin = Person( age=self.baseAge + 1, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=1, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_male_plus_lipid = Person( age=self.baseAge + 1, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=1, initializeAfib=initializeAfib) self._white_male_plus_afib = Person( age=self.baseAge + 1, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfibAlwaysPositive) self._baseline_stroke_person = Person( age=self.baseAge, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib, selfReportStrokeAge=50) self._baseline_stroke_person_copy_paste = Person( age=self.baseAge, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=self.baseSBP, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib, selfReportStrokeAge=50)
def setUp(self): self._test_case_one = Person( age=65 - 0.828576318 * 10, gender=NHANESGender.FEMALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=120 + 0.45 * 10, dbp=80, # guessingon the centering standard for glucose...may have to check a1c=Person.convert_fasting_glucose_to_a1c(100 - 1.1 * 10), hdl=50, totChol=127 - 3.64 * 10, ldl=90, trig=150, bmi=26.6 + 15.30517532, waist=94 + 19.3, anyPhysicalActivity=1, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.ONETOSIX, antiHypertensiveCount=1, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0, initializeAfib=TestGCPModel.initializeAfib, ) self._test_case_two = Person( age=65 - 0.458555784 * 10, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=120 + 0.3 * 10, dbp=80, # guessingon the centering standard for glucose...may have to check a1c=Person.convert_fasting_glucose_to_a1c(100 + 0.732746529 * 10), hdl=50, totChol=127 + 1.18 * 10, ldl=90, trig=150, bmi=26.6 + 0.419305619, waist=94 - 2.5, anyPhysicalActivity=1, education=Education.SOMEHIGHSCHOOL, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.ONETOSIX, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0, initializeAfib=TestGCPModel.initializeAfib, ) self._test_case_three = Person( age=65 - 0.358692676 * 10, gender=NHANESGender.FEMALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_BLACK, sbp=120 + 2.3 * 10, dbp=80, # guessingon the centering standard for glucose...may have to check a1c=Person.convert_fasting_glucose_to_a1c(100 + 0.8893 * 10), hdl=50, totChol=127 + 4.7769 * 10, ldl=90, trig=150, bmi=26.6 + 2.717159247, waist=94 + 9, anyPhysicalActivity=1, education=Education.LESSTHANHIGHSCHOOL, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=1, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0, initializeAfib=TestGCPModel.initializeAfib, ) self._test_case_one._randomEffects["gcp"] = 0 self._test_case_two._randomEffects["gcp"] = 0 self._test_case_three._randomEffects["gcp"] = 0
def setUp(self): self._white_male = Person( age=55, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=120, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._black_male = Person( age=55, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_BLACK, sbp=120, dbp=80, a1c=6, hdl=50, totChol=200, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._black_treated_male = Person( age=55, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_BLACK, sbp=120, dbp=80, a1c=6, hdl=50, totChol=200, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=1, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._white_female = Person( age=55, gender=NHANESGender.FEMALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=120, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._black_female = Person( age=55, gender=NHANESGender.FEMALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_BLACK, sbp=120, dbp=80, a1c=6, hdl=50, totChol=213, ldl=90, trig=150, bmi=22, waist=34, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, initializeAfib=initializeAfib) self._outcome_model_repository = OutcomeModelRepository()
def setUp(self): # 2740200061fos self._test_case_one = Person( age=54.060233, gender=NHANESGender.FEMALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=120, dbp=80, # guessingon the centering standard for glucose...may have to check a1c=Person.convert_fasting_glucose_to_a1c(100), hdl=50, totChol=150, ldl=90, trig=150, bmi=26.6, waist=94, anyPhysicalActivity=1, education=Education.HIGHSCHOOLGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.ONETOSIX, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0, initializeAfib=TestDementiaModel.initializeAfib, initializationRepository=InitializationRepository(), ) self._test_case_one._gcp[0] = 58.68 self._test_case_one._gcp.append(self._test_case_one._gcp[0] - 1.1078128) # 2740201178fos self._test_case_two = Person( age=34.504449, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=120, dbp=80, # guessingon the centering standard for glucose...may have to check a1c=Person.convert_fasting_glucose_to_a1c(100), hdl=50, totChol=150, ldl=90, trig=150, bmi=26.6, waist=94, anyPhysicalActivity=1, education=Education.SOMECOLLEGE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.ONETOSIX, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0, initializeAfib=TestDementiaModel.initializeAfib, initializationRepository=InitializationRepository(), ) self._test_case_two._gcp[0] = 58.68 self._test_case_two._gcp.append(self._test_case_two._gcp[0] - 1.7339989) self._test_case_one_parameteric = Person( age=40, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_BLACK, sbp=120, dbp=80, # guessingon the centering standard for glucose...may have to check a1c=Person.convert_fasting_glucose_to_a1c(100), hdl=50, totChol=150, ldl=90, trig=150, bmi=26.6, waist=94, anyPhysicalActivity=1, education=Education.LESSTHANHIGHSCHOOL, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.ONETOSIX, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0, initializeAfib=TestDementiaModel.initializeAfib, initializationRepository=InitializationRepository(), ) self._test_case_one_parameteric._gcp[0] = 25 # GCP slope is zero self._test_case_one_parameteric._gcp.append( self._test_case_one._gcp[0]) # test case 71 in rep_gdta. self._test_case_two_parametric = Person( age=80, gender=NHANESGender.FEMALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_BLACK, sbp=120, dbp=80, # guessingon the centering standard for glucose...may have to check a1c=Person.convert_fasting_glucose_to_a1c(100), hdl=50, totChol=150, ldl=90, trig=150, bmi=26.6, waist=94, anyPhysicalActivity=1, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.ONETOSIX, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0, initializeAfib=TestDementiaModel.initializeAfib, initializationRepository=InitializationRepository(), ) self._test_case_two_parametric._gcp[0] = 75 self._test_case_two_parametric._gcp.append(self._test_case_two._gcp[0]) # test case 72 in rep_gdta. self._test_case_three_parametric = Person( age=80, gender=NHANESGender.FEMALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=120, dbp=80, # guessingon the centering standard for glucose...may have to check a1c=Person.convert_fasting_glucose_to_a1c(100), hdl=50, totChol=150, ldl=90, trig=150, bmi=26.6, waist=94, anyPhysicalActivity=1, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.ONETOSIX, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0, initializeAfib=TestDementiaModel.initializeAfib, initializationRepository=InitializationRepository(), ) self._test_case_three_parametric._gcp[0] = 75 self._test_case_three_parametric._gcp.append( self._test_case_two._gcp[0]) self._population_dataframe = init_vectorized_population_dataframe([ self._test_case_one, self._test_case_two, ])
def setUp(self): popSize = 100 age = np.random.normal(loc=70, scale=20, size=popSize) sbp = age * 1.05 + np.random.normal(loc=40, scale=30, size=popSize) df = pd.DataFrame({"age": age, "sbp": sbp}) simpleModel = statsmodel.ols(formula="sbp ~ age", data=df) self.simpleModelResultSM = simpleModel.fit() self.simpleModelResult = RegressionModel( self.simpleModelResultSM.params.to_dict(), self.simpleModelResultSM.bse.to_dict(), self.simpleModelResultSM.resid.mean(), self.simpleModelResultSM.resid.std(), ) self.person = Person( age=80, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=120, dbp=80, a1c=5.5, hdl=50, totChol=200, bmi=27, ldl=90, trig=150, waist=70, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0.0, initializeAfib=initializeAfib, ) self.people = [ Person( age=80, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=bpinstance, dbp=80, a1c=5.5, hdl=50, totChol=200, bmi=27, ldl=90, trig=150, waist=70, anyPhysicalActivity=0, education=Education.COLLEGEGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.NONE, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0.0, initializeAfib=initializeAfib, ) for bpinstance in sbp ] for person in self.people: self.advancePerson(person) self.population_dataframe = init_vectorized_population_dataframe( self.people, with_base_gcp=True, ) df2 = pd.DataFrame({ "age": age, "sbp": [person._sbp[-1] for person in self.people], "meanSbp": [np.array(person._sbp).mean() for person in self.people], }) self.meanModelResultSM = statsmodel.ols(formula="sbp ~ age + meanSbp", data=df2).fit() self.meanModelResult = RegressionModel( self.meanModelResultSM.params.to_dict(), self.meanModelResultSM.bse.to_dict(), self.meanModelResultSM.resid.mean(), self.meanModelResultSM.resid.std(), ) df3 = pd.DataFrame({ "age": age, "sbp": [person._sbp[-1] for person in self.people], "logMeanSbp": [np.log(np.array(person._sbp).mean()) for person in self.people], }) self.logMeanModelResultSM = statsmodel.ols( formula="sbp ~ age + logMeanSbp", data=df3).fit() self.logMeanModelResult = RegressionModel( self.logMeanModelResultSM.params.to_dict(), self.logMeanModelResultSM.bse.to_dict(), self.logMeanModelResultSM.resid.mean(), self.logMeanModelResultSM.resid.std(), ) race = np.random.randint(1, 5, size=popSize) df4 = pd.DataFrame({"age": age, "sbp": sbp, "raceEthnicity": race}) df4.raceEthnicity = df4.raceEthnicity.astype("category") self.raceModelResultSM = statsmodel.ols( formula="sbp ~ age + raceEthnicity", data=df4).fit() self.raceModelResult = RegressionModel( self.raceModelResultSM.params.to_dict(), self.raceModelResultSM.bse.to_dict(), self.raceModelResultSM.resid.mean(), self.raceModelResultSM.resid.std(), ) dfMeanAndLag = pd.DataFrame({ "age": age, "sbp": [person._sbp[-1] for person in self.people], "meanSbp": [np.array(person._sbp).mean() for person in self.people], "lagSbp": [person._sbp[-1] for person in self.people], }) self.meanLagModelResultSM = statsmodel.ols( formula="sbp ~ age + meanSbp + lagSbp", data=dfMeanAndLag).fit() self.meanLagModelResult = RegressionModel( self.meanLagModelResultSM.params.to_dict(), self.meanLagModelResultSM.bse.to_dict(), self.meanLagModelResultSM.resid.mean(), self.meanLagModelResultSM.resid.std(), ) self.ageSbpInteractionCoeff = 0.02 self.sbpInteractionCoeff = 0.5 self.interactionModel = RegressionModel( { "meanSbp#age": self.ageSbpInteractionCoeff, "meanSbp": self.sbpInteractionCoeff, "Intercept": 0, }, { "meanSbp#age": 0.0, "meanSbp": 0.0 }, 0, 0, )
def setUp(self): self._black_female_high_cr = Person( age=52, gender=NHANESGender.FEMALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_BLACK, sbp=120, dbp=80, a1c=Person.convert_fasting_glucose_to_a1c(100), hdl=50, totChol=150, ldl=90, trig=150, bmi=26.6, waist=94, anyPhysicalActivity=1, education=Education.HIGHSCHOOLGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.ONETOSIX, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0.8, initializeAfib=TestCKDEquation.initializeAfib, ) self._black_female_low_cr = Person( age=52, gender=NHANESGender.FEMALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_BLACK, sbp=120, dbp=80, a1c=Person.convert_fasting_glucose_to_a1c(100), hdl=50, totChol=150, ldl=90, trig=150, bmi=26.6, waist=94, anyPhysicalActivity=1, education=Education.HIGHSCHOOLGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.ONETOSIX, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0.4, initializeAfib=TestCKDEquation.initializeAfib, ) self._white_male_high_cr = Person( age=52, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=120, dbp=80, a1c=Person.convert_fasting_glucose_to_a1c(100), hdl=50, totChol=150, ldl=90, trig=150, bmi=26.6, waist=94, anyPhysicalActivity=1, education=Education.HIGHSCHOOLGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.ONETOSIX, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=1.2, initializeAfib=TestCKDEquation.initializeAfib, ) self._white_male_low_cr = Person( age=52, gender=NHANESGender.MALE, raceEthnicity=NHANESRaceEthnicity.NON_HISPANIC_WHITE, sbp=120, dbp=80, a1c=Person.convert_fasting_glucose_to_a1c(100), hdl=50, totChol=150, ldl=90, trig=150, bmi=26.6, waist=94, anyPhysicalActivity=1, education=Education.HIGHSCHOOLGRADUATE, smokingStatus=SmokingStatus.NEVER, alcohol=AlcoholCategory.ONETOSIX, antiHypertensiveCount=0, statin=0, otherLipidLoweringMedicationCount=0, creatinine=0.1, initializeAfib=TestCKDEquation.initializeAfib, )