<jupyter_start><jupyter_text>Parameter recovery of the DDM with starting point bias<jupyter_code>import rlssm
import pandas as pd<jupyter_output><empty_output><jupyter_text>Simulate individual data<jupyter_code>from rlssm.random import simulate_ddm
data = simulate_ddm(
    n_trials=400, 
    gen_drift=.8, 
    gen_threshold=1.3, 
    gen_ndt=.23, 
    gen_rel_sp=.6)
data.describe()[['rt', 'accuracy']]<jupyter_output><empty_output><jupyter_text>Initialize the model<jupyter_code>model = rlssm.DDModel(hierarchical_levels = 1, starting_point_bias=True)<jupyter_output>Using cached StanModel<jupyter_text>Fit<jupyter_code># sampling parameters
n_iter = 3000
n_chains = 2
n_thin = 1

# bayesian model, change default priors:
drift_priors = {'mu':1, 'sd':3}
threshold_priors = {'mu':-1, 'sd':3}
ndt_priors = {'mu':-1, 'sd':1}
model_fit = model.fit(
    data,
    drift_priors=drift_priors,
    threshold_priors=threshold_priors,
    ndt_priors=ndt_priors,
    thin = n_thin,
    iter = n_iter,
    chains = n_chains,
    verbose = False)<jupyter_output>Fitting the model using the priors:
drift_priors {'mu': 1, 'sd': 3}
threshold_priors {'mu': -1, 'sd': 3}
ndt_priors {'mu': -1, 'sd': 1}
rel_sp_priors {'mu': 0, 'sd': 0.8}<jupyter_text>get Rhat<jupyter_code>model_fit.rhat<jupyter_output><empty_output><jupyter_text>calculate wAIC<jupyter_code>model_fit.waic<jupyter_output><empty_output><jupyter_text>Posteriors<jupyter_code>model_fit.samples.describe()
import seaborn as sns
sns.set(context = "talk", 
        style = "white", 
        palette = "husl",
        rc={'figure.figsize':(15, 8)})<jupyter_output><empty_output><jupyter_text>Here we plot the estimated posterior distributions against the generating parameters, to see whether the model parameters are recovering well:<jupyter_code>g = model_fit.plot_posteriors(height=5, show_intervals='HDI')

for i, ax in enumerate(g.axes.flatten()):
    ax.axvline(data[['drift', 'threshold', 'ndt', 'rel_sp']].mean().values[i], color='grey', linestyle='--')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13696612665684832, 'fraction_numerical': 0.01718213058419244, 'mean_word_length': 6.384057971014493, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '384748', 'license': 'MIT', 'n_tokens_mistral': 830, 'n_tokens_neox': 779, 'n_words': 142, 'path': 'docs/notebooks/DDM_starting-point-bias_fitting.ipynb', 'repo_name': 'birgovanandrei/rlssm', 'size': '2037'}