hddm-devs / hddm

HDDM is a python module that implements Hierarchical Bayesian parameter estimation of Drift Diffusion Models (via PyMC).
http://ski.clps.brown.edu/hddm_docs/
Other
261 stars 117 forks source link

Biased response generation #77

Closed jasongong11 closed 2 years ago

jasongong11 commented 2 years ago

When specifying drift rate equals to 0, the generated data has biased response toward correct response (response == 1). I would assume the probability of correct response and error response would be equal when the drift rate is 0. However, this does not seem to be the case in simulated datasets.

I tried generate from cdf. I wonder if this issue is going to influence the MC sampling process.

To reproduce:

import hddm
import matplotlib.pyplot as plt

v = [0]
cond_params, merged_params = hddm.generate.gen_rand_params(
            include=include, cond_dict={"v": v}
        )
test_param = cond_params["c0"]

# drifting generation
test_rts_list_drift = []
prob_resp_drift = []
for i in range(200):
    test_rts = hddm.generate._gen_rts_from_simulated_drift(test_param, 200, 0.0001, intra_sv=1.0)[0]
    test_rts_list_drift.append(test_rts)
    prob_resp_drift.append(sum(test_rts > 0)/test_rts.shape[0])
plt.hist(prob_resp_drift)

# cdf generation
test_rts_list_cdf = []
prob_resp_cdf = []
for i in range(200):
    samples = hddm.generate.gen_rand_data(test_param, size=n_samples)[0]
    test_rts_list_cdf.append(test_rts)
    samples = hddm.utils.flip_errors(samples)
    samples_list.append(samples)

    prob_resp_cdf.append(sum(samples.response==0)/samples.shape[0])

plt.hist(prob_resp_drift)

plt.hist(prob_resp_cdf)

However, it seems the estimated drift rate is not biased as the probability of response.

jasongong11 commented 2 years ago

looks like decision bias "z" is biasing the response. To generate unbiased dataset, should set z to be 0.5. However, it is still intersting that most of time generate random parameters is setting z to be biased toward correct response.