#NEWLINE# def test_framing_example( ) : #NEWLINE# #INDENT# cur_dir = os . path . dirname ( os . path . abspath ( __file__ ) ) #NEWLINE# data = pd . read_csv ( os . path . join ( cur_dir , 'results' , 'framing.csv' ) ) #NEWLINE# outcome = np . asarray ( para_rslt [ 'cong_mesg' ] ) #NEWLINE# outcome_exog = patsy . dmatrix ( 'emo + treat + age + educ + gender + income' , data , return_type = 'dataframe' ) #NEWLINE# probit = sm . families . links . probit #NEWLINE# outcome_model = sm . GLM ( outcome , outcome_exog , family = sm . families . Binomial ( link = probit ) ) #NEWLINE# mediator = np . asarray ( data [ 'emo' ] ) #NEWLINE# mediator_exog = patsy . dmatrix ( 'treat + age + educ + gender + income' , data , return_type = 'dataframe' ) #NEWLINE# mediator_model = sm . OLS ( mediator , mediator_exog ) #NEWLINE# tx_pos = [ outcome_exog . columns . tolist ( ) . index ( 'treat' ) , mediator_exog . columns . tolist ( ) . index ( 'treat' ) ] #NEWLINE# med_pos = outcome_exog . columns . tolist ( ) . index ( 'emo' ) #NEWLINE# med = Mediation ( outcome_model , mediator_model , tx_pos , med_pos ) #NEWLINE# np . random . seed ( 4231 ) #NEWLINE# para_rslt = med . fit ( method = 'parametric' , n_rep = 100 ) #NEWLINE# diff = np . asarray ( ( para_rslt . summary ( ) - framing_para_4231 ) ) #NEWLINE# assert_allclose ( diff , 0 , atol = 1e-06 ) #NEWLINE# np . random . seed ( 4231 ) #NEWLINE# boot_rslt = med . fit ( method = 'boot' , n_rep = 100 ) #NEWLINE# diff = np . asarray ( ( boot_rslt . summary ( ) - framing_boot_4231 ) ) #NEWLINE# assert_allclose ( diff , 0 , atol = 1e-06 )