<jupyter_start><jupyter_text>Test Main Effect and Interaction Effect<jupyter_code># load the model fitted in step XX
m_FULL_hypothesis = hddm.load("study2_regression_full_hypothesis")
# get the MCMC fitting nodes of each parameters in the model
s2_full_v_movie_valence,\
s2_full_v_mood_valence,\
s2_full_v_movie_arousal,\
s2_full_v_mood_arousal,\
s2_full_v_movie_valence_mood_valence,\
s2_full_v_movie_arousal_mood_arousal,\
s2_full_a_movie_valence,\
s2_full_a_mood_valence,\
s2_full_a_movie_arousal,\
s2_full_a_mood_arousal,\
s2_full_a_movie_valence_mood_valence,\
s2_full_a_movie_arousal_mood_arousal,\
s2_full_t_movie_valence,\
s2_full_t_mood_valence,\
s2_full_t_movie_arousal,\
s2_full_t_mood_arousal,\
s2_full_t_movie_valence_mood_valence,\
s2_full_t_movie_arousal_mood_arousal,\
s2_full_z_movie_valence,\
s2_full_z_mood_valence,\
s2_full_z_movie_arousal,\
s2_full_z_mood_arousal,\
s2_full_z_movie_valence_mood_valence,\
s2_full_z_movie_arousal_mood_arousal = m_FULL_hypothesis.nodes_db.loc[[
    "v_movie_valence[T.1]",
    "v_mood_valence[T.1]",
    "v_movie_arousal[T.1]",
    "v_mood_arousal[T.1]", 
    "v_movie_valence[T.1]:mood_valence[T.1]",
    "v_movie_arousal[T.1]:mood_arousal[T.1]",
    
    "a_movie_valence[T.1]",
    "a_mood_valence[T.1]",
    "a_movie_arousal[T.1]",
    "a_mood_arousal[T.1]", 
    "a_movie_valence[T.1]:mood_valence[T.1]",
    "a_movie_arousal[T.1]:mood_arousal[T.1]",
    
    "t_movie_valence[T.1]",
    "t_mood_valence[T.1]",
    "t_movie_arousal[T.1]",
    "t_mood_arousal[T.1]", 
    "t_movie_valence[T.1]:mood_valence[T.1]",
    "t_movie_arousal[T.1]:mood_arousal[T.1]",
    
    "z_movie_valence[T.1]",
    "z_mood_valence[T.1]",
    "z_movie_arousal[T.1]",
    "z_mood_arousal[T.1]", 
    "z_movie_valence[T.1]:mood_valence[T.1]",
    "z_movie_arousal[T.1]:mood_arousal[T.1]"], 'node']
# test the percentage of posteriors higher and lower than 0
def inference_test(trace):
    probability1 = round((trace < 0).mean(), 3) 
    probability2 = round((1-probability1), 3) 
    return "{} % < 0 < {} %".format(probability1 * 100, probability2 * 100)<jupyter_output><empty_output><jupyter_text>drift rate hypothesis testing<jupyter_code># test the main effect of valence and arousal against 0
print(inference_test(s2_full_v_movie_valence.trace()))
print(inference_test(s2_full_v_movie_arousal.trace()))
print(inference_test(s2_full_v_mood_valence.trace()))
print(inference_test(s2_full_v_mood_arousal.trace()))

# test the interaction between movie and mood factors for valence and arousal
print(inference_test(s2_full_v_movie_valence_mood_valence.trace()))
print(inference_test(s2_full_v_movie_arousal_mood_arousal.trace()))

# compare the size of interaction effect of valence and arousal
print(inference_test(s2_full_v_movie_valence_mood_valence.trace() - s2_full_v_movie_arousal_mood_arousal.trace()))
# get the statistics of the posteior,
# including the mean of posterior and the 0.025 & 0.975 quantiles to get the 0.95 credible intervals
s2_full_stats = m_FULL_hypothesis.gen_stats()
s2_full_stats[s2_full_stats.index.isin(["v_Intercept",
    "v_movie_valence[T.1]",
    "v_mood_valence[T.1]",
    "v_movie_arousal[T.1]",
    "v_mood_arousal[T.1]", 
    "v_movie_valence[T.1]:mood_valence[T.1]",
    "v_movie_arousal[T.1]:mood_arousal[T.1]",])]<jupyter_output><empty_output><jupyter_text>Decison boundary hypothesis testing<jupyter_code># test the main effect of valence and arousal against 0
print(inference_test(s2_full_a_movie_valence.trace()))
print(inference_test(s2_full_a_movie_arousal.trace()))

print(inference_test(s2_full_a_mood_valence.trace()))
print(inference_test(s2_full_a_mood_arousal.trace()))

# test the interaction between movie and mood factors for valence and arousal
print(inference_test(s2_full_a_movie_valence_mood_valence.trace()))
print(inference_test(s2_full_a_movie_arousal_mood_arousal.trace()))

# get the statistics of the posteior,
# including the mean of posterior and the 0.025 & 0.975 quantiles to get the 0.95 credible intervals
s2_full_stats = m_FULL_hypothesis.gen_stats()
s2_full_stats[s2_full_stats.index.isin(["a_Intercept",
    "a_movie_valence[T.1]",
    "a_mood_valence[T.1]",
    "a_movie_arousal[T.1]",
    "a_mood_arousal[T.1]", 
    "a_movie_valence[T.1]:mood_valence[T.1]",
    "a_movie_arousal[T.1]:mood_arousal[T.1]",])]<jupyter_output><empty_output><jupyter_text>Non decision time hypothesis testing<jupyter_code># test the main effect of valence and arousal against 0
print(inference_test(s2_full_t_movie_valence.trace()))
print(inference_test(s2_full_t_movie_arousal.trace()))
print(inference_test(s2_full_t_mood_valence.trace()))
print(inference_test(s2_full_t_mood_arousal.trace()))

# test the interaction between movie and mood factors for valence and arousal
print(inference_test(s2_full_t_movie_valence_mood_valence.trace()))
print(inference_test(s2_full_t_movie_arousal_mood_arousal.trace()))

# get the statistics of the posteior,
# including the mean of posterior and the 0.025 & 0.975 quantiles to get the 0.95 credible intervals
s2_full_stats = m_FULL_hypothesis.gen_stats()
s2_full_stats[s2_full_stats.index.isin(["t_Intercept",
    "t_movie_valence[T.1]",
    "t_mood_valence[T.1]",
    "t_movie_arousal[T.1]",
    "t_mood_arousal[T.1]", 
    "t_movie_valence[T.1]:mood_valence[T.1]",
    "t_movie_arousal[T.1]:mood_arousal[T.1]",])]<jupyter_output><empty_output><jupyter_text>Decision bias hypothesis testing<jupyter_code># test the main effect of valence and arousal against 0
print(inference_test(s2_full_z_movie_valence.trace()))
print(inference_test(s2_full_z_movie_arousal.trace()))
print(inference_test(s2_full_z_mood_valence.trace()))
print(inference_test(s2_full_z_mood_arousal.trace()))

# test the interaction between movie and mood factors for valence and arousal
print(inference_test(s2_full_z_movie_valence_mood_valence.trace()))
print(inference_test(s2_full_z_movie_arousal_mood_arousal.trace()))

# get the statistics of the posteior,
# including the mean of posterior and the 0.025 & 0.975 quantiles to get the 0.95 credible intervals
s2_full_stats = m_FULL_hypothesis.gen_stats()
s2_full_stats[s2_full_stats.index.isin(["z_Intercept",
    "z_movie_valence[T.1]",
    "z_mood_valence[T.1]",
    "z_movie_arousal[T.1]",
    "z_mood_arousal[T.1]", 
    "z_movie_valence[T.1]:mood_valence[T.1]",
    "z_movie_arousal[T.1]:mood_arousal[T.1]",])]
distributions = pd.DataFrame({"v_movie_valence":s2_full_v_movie_valence.trace(),
                             "v_mood_valence":s2_full_v_mood_valence.trace(),
                             "v_movie_arousal":s2_full_v_movie_arousal.trace(),
                             "v_mood_arousal":s2_full_v_mood_arousal.trace(),
                             "v_movie_valence_mood_valence":s2_full_v_movie_valence_mood_valence.trace(),
                             "v_movie_arousal_mood_arousal":s2_full_v_movie_arousal_mood_arousal.trace(),
                             "a_movie_valence":s2_full_a_movie_valence.trace(),
                             "a_mood_valence":s2_full_a_mood_valence.trace(),
                             "a_movie_arousal":s2_full_a_movie_arousal.trace(),
                             "a_mood_arousal":s2_full_a_mood_arousal.trace(),
                             "a_movie_valence_mood_valence":s2_full_a_movie_valence_mood_valence.trace(),
                             "a_movie_arousal_mood_arousal":s2_full_a_movie_arousal_mood_arousal.trace(),
                             "t_movie_valence":s2_full_t_movie_valence.trace(),
                             "t_mood_valence":s2_full_t_mood_valence.trace(),
                             "t_movie_arousal":s2_full_t_movie_arousal.trace(),
                             "t_mood_arousal":s2_full_t_mood_arousal.trace(),
                             "t_movie_valence_mood_valence":s2_full_t_movie_valence_mood_valence.trace(),
                             "t_movie_arousal_mood_arousal":s2_full_t_movie_arousal_mood_arousal.trace(),
                             "z_movie_valence":s2_full_z_movie_valence.trace(),
                             "z_mood_valence":s2_full_z_mood_valence.trace(),
                             "z_movie_arousal":s2_full_z_movie_arousal.trace(),
                             "z_mood_arousal":s2_full_z_mood_arousal.trace(),
                             "z_movie_valence_mood_valence":s2_full_z_movie_valence_mood_valence.trace(),
                             "z_movie_arousal_mood_arousal":s2_full_z_movie_arousal_mood_arousal.trace()})

distributions.to_csv("plot/study2_full_regression_hypothesis.csv")<jupyter_output><empty_output><jupyter_text>Test effects of movie valence/arousal at different level of mood<jupyter_code># load the model fitted in step XX
m_FULL_hypothesis_interaction = hddm.load("study2_regression_full_hypothesis_interaction")
# get MCMC chains of parameters
# drift rate, decision boundary, non-decision time, and decision bias

s2_interaction_v_mood_valence,\
s2_interaction_v_mood_arousal,\
s2_interaction_v_movie_valence_mood_valence0,\
s2_interaction_v_movie_valence_mood_valence1,\
s2_interaction_v_movie_arousal_mood_arousal0,\
s2_interaction_v_movie_arousal_mood_arousal1,\
s2_interaction_a_mood_valence,\
s2_interaction_a_mood_arousal,\
s2_interaction_a_movie_valence_mood_valence0,\
s2_interaction_a_movie_valence_mood_valence1,\
s2_interaction_a_movie_arousal_mood_arousal0,\
s2_interaction_a_movie_arousal_mood_arousal1,\
s2_interaction_t_mood_valence,\
s2_interaction_t_mood_arousal,\
s2_interaction_t_movie_valence_mood_valence0,\
s2_interaction_t_movie_valence_mood_valence1,\
s2_interaction_t_movie_arousal_mood_arousal0,\
s2_interaction_t_movie_arousal_mood_arousal1,\
s2_interaction_z_mood_valence,\
s2_interaction_z_mood_arousal,\
s2_interaction_z_movie_valence_mood_valence0,\
s2_interaction_z_movie_valence_mood_valence1,\
s2_interaction_z_movie_arousal_mood_arousal0,\
s2_interaction_z_movie_arousal_mood_arousal1 = m_FULL_hypothesis_interaction.nodes_db.loc[[
    "v_mood_valence[T.1]",
    "v_mood_arousal[T.1]", 
    "v_movie_valence[T.1]:mood_valence[0]",
    "v_movie_valence[T.1]:mood_valence[1]",
    "v_movie_arousal[T.1]:mood_arousal[0]",
    "v_movie_arousal[T.1]:mood_arousal[1]",
    
    "a_mood_valence[T.1]",
    "a_mood_arousal[T.1]", 
    "a_movie_valence[T.1]:mood_valence[0]",
    "a_movie_valence[T.1]:mood_valence[1]",
    "a_movie_arousal[T.1]:mood_arousal[0]",
    "a_movie_arousal[T.1]:mood_arousal[1]",
    
    "t_mood_valence[T.1]",
    "t_mood_arousal[T.1]", 
    "t_movie_valence[T.1]:mood_valence[0]",
    "t_movie_valence[T.1]:mood_valence[1]",
    "t_movie_arousal[T.1]:mood_arousal[0]",
    "t_movie_arousal[T.1]:mood_arousal[1]",
    
    "z_mood_valence[T.1]",
    "z_mood_arousal[T.1]", 
    "z_movie_valence[T.1]:mood_valence[0]",
    "z_movie_valence[T.1]:mood_valence[1]",
    "z_movie_arousal[T.1]:mood_arousal[0]",
    "z_movie_arousal[T.1]:mood_arousal[1]"], 'node']<jupyter_output><empty_output><jupyter_text>effect of movie valence at different level of mood valence<jupyter_code># test the effect of movie valence at difference level of mood valence
print(inference_test(s2_interaction_v_movie_valence_mood_valence0.trace()))
print(inference_test(s2_interaction_v_movie_valence_mood_valence1.trace()))<jupyter_output>100.0 % < 0 < 0.0 %
99.6 % < 0 < 0.4 %<jupyter_text>effect of movie arousal at different level of mood arousal<jupyter_code># test the effect of movie arousal at difference level of mood arousal
print(inference_test(s2_interaction_v_movie_arousal_mood_arousal0.trace()))
print(inference_test(s2_interaction_v_movie_arousal_mood_arousal1.trace()))<jupyter_output>1.4000000000000001 % < 0 < 98.6 %
0.7000000000000001 % < 0 < 99.3 %<jupyter_text>main effect of mood valence/arousal<jupyter_code># test the main effect of mood arousal on drift rate
print(inference_test(s2_interaction_v_mood_valence.trace()))
print(inference_test(s2_interaction_v_mood_arousal.trace()))<jupyter_output>65.4 % < 0 < 34.599999999999994 %
17.0 % < 0 < 83.0 %<jupyter_text>compare the effect of movie valence/arousal at different level of mood valence/arousal<jupyter_code>print(inference_test(s2_interaction_v_movie_valence_mood_valence0.trace() - 
                        s2_interaction_v_movie_valence_mood_valence1.trace()))


print(inference_test(s2_interaction_v_movie_arousal_mood_arousal0.trace() -
                        s2_interaction_v_movie_arousal_mood_arousal1.trace()))
# get the mean of the posteriors and the quantiles for credible interval

stats_interaction = m_FULL_hypothesis_interaction.gen_stats()
stats_interaction[stats_interaction.index.isin(["v_mood_valence[T.1]",
    "v_mood_arousal[T.1]", 
    "v_movie_valence[T.1]:mood_valence[0]",
    "v_movie_valence[T.1]:mood_valence[1]",
    "v_movie_arousal[T.1]:mood_arousal[0]",
    "v_movie_arousal[T.1]:mood_arousal[1]",
    
    "a_mood_valence[T.1]",
    "a_mood_arousal[T.1]", 
    "a_movie_valence[T.1]:mood_valence[0",
    "a_movie_valence[T.1]:mood_valence[1]",
    "a_movie_arousal[T.1]:mood_arousal[0]",
    "a_movie_arousal[T.1]:mood_arousal[1]",
    
    "t_mood_valence[T.1]",
    "t_mood_arousal[T.1]", 
    "t_movie_valence[T.1]:mood_valence[0]",
    "t_movie_arousal[T.1]:mood_arousal[1]",
    "t_movie_arousal[T.1]:mood_arousal[0]",
    "t_movie_arousal[T.1]:mood_arousal[1]",
    
    "z_mood_valence[T.1]",
    "z_mood_arousal[T.1]", 
    "z_movie_valence[T.1]:mood_valence[0]",
    "z_movie_arousal[T.1]:mood_arousal[1]",
    "z_movie_arousal[T.1]:mood_arousal[0]",
    "z_movie_arousal[T.1]:mood_arousal[1]",])]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.114548802946593, 'fraction_numerical': 0.03233885819521179, 'mean_word_length': 5.370717972782731, 'pattern_counts': {'":': 24, '<': 53, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 3, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '207037', 'license': 'MIT', 'n_tokens_mistral': 6022, 'n_tokens_neox': 5336, 'n_words': 602, 'path': 'ddm_analysis/step5_Inference_testing_study_2.ipynb', 'repo_name': 'jasongong11/movie_selection', 'size': '13575'}