import hddm
From version HDDM >= 0.9.0, you have access to multiple new sequential sampling models. You can simulate from these models, perform parameter estimation and moreover you have some extended plotting capabilities which can be useful to visualize model fits, or simply to investigate the behavior of models across parameter settings.
Lets take a look at the new hddm.model_config.model_config
dictionary, which allows you to investigate metadata for all the new (and old) models which are available through the HDDM-LAN extension.
# List all available models
list(hddm.model_config.model_config.keys())[:10]
- ['test',
'ddm', 'ddm_hddm_base', 'angle', 'weibull', 'levy', 'full_ddm', 'full_ddm_hddm_base', 'ornstein', 'ddm_sdv']
# Take an example to list data available for a given model
model_tmp = 'ornstein'
hddm.model_config.model_config[model_tmp]
- {'params': ['v', 'a', 'z', 'g', 't'],
'params_trans': [0, 0, 1, 0, 0], 'params_std_upper': [1.5, 1.0, None, 1.0, 1.0], 'param_bounds': [[-2.0, 0.3, 0.2, -1.0, 0.001], [2.0, 2.0, 0.8, 1.0, 2]], 'boundary': <function hddm.simulators.boundary_functions.constant(t=0)>, 'n_params': 5, 'params_default': [0.0, 1.0, 0.5, 0.0, 0.001], 'hddm_include': ['z', 'g'], 'n_choices': 2, 'choices': [-1, 1], 'slice_widths': {'v': 1.5, 'v_std': 0.1, 'a': 1, 'a_std': 0.1, 'z': 0.1, 'z_trans': 0.2, 't': 0.01, 't_std': 0.15, 'g': 0.1, 'g_trans': 0.2, 'g_std': 0.1}}
You have access to the following data (we focus on the parts important for the user):
params
, the names of paramaters for a given model (order matters)params_trans
whether HDDM should internally transform a parameter to an unconstrained domainparam_bounds
the range of parameter values that the respective LAN was trained on (order as inparams
)boundary
the boundary function, which corresponds to the model (access the available boundary functions through thehddm.simulators.boundary_functions
module.params_default
, defaults settings for the parameters of the modelhddm_include
, list to supply to hddm to include all model parameters (you may want to drop some)slide_widths
, slice sampler settings parameter by parameter (changing these can improve / deteriorate sampler behavior)
You can change these settings as you see fit.
The new simulator_h_c()
function lets you generate complex datasets using the models available under hddm.model_config.model_config
. The function is especially useful for parameter recovery studies. It can generate fully synthetic data, or you can supply an empirial dataset and it’s structure can be used to generate simulation based replicas. Find more information using the help()
function. Here we give a simple example.
model = 'angle'
n_subjects = 1
n_samples_by_subject = 500
data, full_parameter_dict = hddm.simulators.hddm_dataset_generators.simulator_h_c(n_subjects = n_subjects,
n_samples_by_subject = n_samples_by_subject,
model = model,
p_outlier = 0.00,
conditions = None,
depends_on = None,
regression_models = None,
regression_covariates = None,
group_only_regressors = False,
group_only = None,
fixed_at_default = None)
# A look at the data generated
data
rt | response | subj_idx | v | a | z | t | theta | |
---|---|---|---|---|---|---|---|---|
0 | 1.579309 | 1.0 | 0 | 0.702983 | 0.633137 | 0.519282 | 1.393309 | 0.415966 |
1 | 1.618309 | 1.0 | 0 | 0.702983 | 0.633137 | 0.519282 | 1.393309 | 0.415966 |
2 | 1.622309 | 1.0 | 0 | 0.702983 | 0.633137 | 0.519282 | 1.393309 | 0.415966 |
3 | 1.611309 | 0.0 | 0 | 0.702983 | 0.633137 | 0.519282 | 1.393309 | 0.415966 |
4 | 1.669309 | 1.0 | 0 | 0.702983 | 0.633137 | 0.519282 | 1.393309 | 0.415966 |
... | ... | ... | ... | ... | ... | ... | ... | ... |
95 | 1.838306 | 0.0 | 0 | 0.702983 | 0.633137 | 0.519282 | 1.393309 | 0.415966 |
96 | 1.526309 | 1.0 | 0 | 0.702983 | 0.633137 | 0.519282 | 1.393309 | 0.415966 |
97 | 1.548309 | 1.0 | 0 | 0.702983 | 0.633137 | 0.519282 | 1.393309 | 0.415966 |
98 | 1.722308 | 1.0 | 0 | 0.702983 | 0.633137 | 0.519282 | 1.393309 | 0.415966 |
99 | 1.460309 | 1.0 | 0 | 0.702983 | 0.633137 | 0.519282 | 1.393309 | 0.415966 |
100 rows × 8 columns
Note:
The full_parameter_dict returned plays well with HDDM and some plots that give you the option to provide ground truth parameters. In our case the output is simple.
More complicated datasets, will make this much more interesting.
full_parameter_dict
- {'theta': 0.41596571495194185,
'v': 0.7029832446663296, 't': 1.3933086736547817, 'a': 0.6331370688655752, 'z': 0.5192818348445416}