hddm.models package

Submodules

hddm.models.base module

class hddm.models.base.AccumulatorModel(data, **kwargs)

Bases: Hierarchical

get_average_model(quantiles=(0.1, 0.3, 0.5, 0.7, 0.9))
optimize(method, quantiles=(0.1, 0.3, 0.5, 0.7, 0.9), n_runs=3, n_bootstraps=0, parallel_profile=None)

Optimize model using ML, chi^2 or G^2.

Input:
methodstr

Optimization method (‘ML’, ‘chisquare’ or ‘gsquare’).

quantilestuple

A sequence of quantiles to be used for chi^2 and G^2. Default values are the ones used by Ratcliff (.1, .3, .5, .7, .9).

n_runsint <default=3>

Number of attempts to optimize.

n_bootstrapsint <default=0>

Number of bootstrap iterations.

parrall_profilestr <default=None>

IPython profile for parallelization.

Output:

results <dict> - a results dictionary of the parameters values.

Note:

The values of the nodes in single subject model is updated according to the results. The nodes of group models are not updated

class hddm.models.base.HDDMBase(data, bias=False, include=(), wiener_params=None, p_outlier=0.05, **kwargs)

Bases: AccumulatorModel

HDDM base class. Not intended to be used directly. Instead, use hddm.HDDM.

create_knodes()
plot_posterior_predictive(*args, **kwargs)
plot_posterior_quantiles(*args, **kwargs)

Plot posterior predictive quantiles.

Arguments:

model : HDDM model

Optional:
value_rangenumpy.ndarray

Range over which to evaluate the CDF.

samplesint (default=10)

Number of posterior samples to use.

alphafloat (default=.75)

Alpha (transparency) of posterior quantiles.

hexbinbool (default=False)

Whether to plot posterior quantile density using hexbin.

data_plot_kwargsdict (default=None)

Forwarded to data plotting function call.

predictive_plot_kwargsdict (default=None)

Forwareded to predictive plotting function call.

columnsint (default=3)

How many columns to use for plotting the subjects.

savebool (default=False)

Whether to save the figure to a file.

pathstr (default=None)

Save figure into directory prefix

hddm.models.hddm_info module

class hddm.models.hddm_info.HDDM(*args, **kwargs)

Bases: HDDMBase

Create hierarchical drift-diffusion model in which each subject has a set of parameters that are constrained by a group distribution.

Arguments:
datapandas.DataFrame

Input data with a row for each trial.

Must contain the following columns: * ‘rt’: Reaction time of trial in seconds. * ‘response’: Binary response (e.g. 0->error, 1->correct) * ‘subj_idx’: A unique ID (int) of each subject. * Other user-defined columns that can be used in depends_on keyword.

Optional:
informativebool <default=True>

Whether to use informative priors (True) or vague priors (False). Information about the priors can be found in the methods section. If you run a classical DDM experiment you should use this. However, if you apply the DDM to a novel domain like saccade data where RTs are much lower, or RTs of rats, you should probably set this to False.

is_group_modelbool

If True, this results in a hierarchical model with separate parameter distributions for each subject. The subject parameter distributions are themselves distributed according to a group parameter distribution.

depends_ondict

Specifies which parameter depends on data of a column in data. For each unique element in that column, a separate set of parameter distributions will be created and applied. Multiple columns can be specified in a sequential container (e.g. list)

Example:
>>> hddm.HDDM(data, depends_on={'v': 'difficulty'})

Separate drift-rate parameters will be estimated for each difficulty. Requires ‘data’ to have a column difficulty.

biasbool

Whether to allow a bias to be estimated. This is normally used when the responses represent left/right and subjects could develop a bias towards responding right. This is normally never done, however, when the ‘response’ column codes correct/error.

p_outlierdouble <0.05>

The probability of outliers in the data. if p_outlier is passed in the ‘include’ argument, then it is estimated from the data and the value passed using the p_outlier argument is ignored.

default_intervarsdict <default = {‘sz’: 0, ‘st’: 0, ‘sv’: 0}>

Fix intertrial variabilities to a certain value. Note that this will only have effect for variables not estimated from the data.

plot_varbool

Plot group variability parameters when calling pymc.Matplot.plot() (i.e. variance of Normal distribution.)

trace_subjsbool

Save trace for subjs (needed for many statistics so probably a good idea.)

std_dependsbool <default=False>

Should the depends_on keyword affect the group std node. If True it means that both, group mean and std will be split by condition.

wiener_paramsdict

Parameters for wfpt evaluation and numerical integration.

Parameters:
  • err: Error bound for wfpt <default=1e-4>

  • n_st: Maximum depth for numerical integration for st <default=2>

  • n_sz: Maximum depth for numerical integration for Z <default=2>

  • use_adaptive: Whether to use adaptive numerical integration <default=True>

  • simps_err: Error bound for Simpson integration <default=1e-3>

Example:
>>> data, params = hddm.generate.gen_rand_data() # gen data
>>> model = hddm.HDDM(data) # create object
>>> model.sample(5000, burn=20) # Sample from posterior
pre_sample(use_slice=True)

hddm.models.hddm_nn module

class hddm.models.hddm_nn.HDDMnn(*args, **kwargs)

Bases: HDDM

HDDM model class that uses neural network based likelihoods to include a variety of other models.

Arguments:
data: pandas.DataFrame

Input data with a row for each trial.

Must contain the following columns: * ‘rt’: Reaction time of trial in seconds. * ‘response’: Binary response (e.g. 0->error, 1->correct) * ‘subj_idx’: A unique ID (int) of each subject. * Other user-defined columns that can be used in depends_on keyword.

Optional:
model: str <default=’ddm’>

String that determines which model you would like to fit your data to. Currently available models are: ‘ddm’, ‘full_ddm’, ‘angle’, ‘weibull’, ‘ornstein’, ‘levy’

nbin: int <default=512>

Relevant only if network type was chosen to be ‘cnn’. CNNs can be trained on coarser or finer binnings of RT space. At this moment only networks with 512 bins are available.

include: list <default=None>

A list with parameters we wish to include in the fitting procedure. Generally, per default included in fitting are the drift parameter ‘v’, the boundary separation parameter ‘a’ and the non-decision-time ‘t’. Which parameters you can include depends on the model you specified under the model parameters.

informativebool <default=True>

Whether to use informative priors (True) or vague priors (False). Informative priors are not yet implemented for neural network based models.

is_group_modelbool

If True, this results in a hierarchical model with separate parameter distributions for each subject. The subject parameter distributions are themselves distributed according to a group parameter distribution.

depends_ondict

Specifies which parameter depends on data of a column in data. For each unique element in that column, a separate set of parameter distributions will be created and applied. Multiple columns can be specified in a sequential container (e.g. list)

Example:
>>> hddm.HDDM(data, depends_on={'v': 'difficulty'})

Separate drift-rate parameters will be estimated for each difficulty. Requires ‘data’ to have a column difficulty.

biasbool

Whether to allow a bias to be estimated. This is normally used when the responses represent left/right and subjects could develop a bias towards responding right. This is normally never done, however, when the ‘response’ column codes correct/error.

p_outlierdouble (default=0.05)

The probability of outliers in the data. if p_outlier is passed in the ‘include’ argument, then it is estimated from the data and the value passed using the p_outlier argument is ignored.

default_intervarsdict (default = {‘sz’: 0, ‘st’: 0, ‘sv’: 0})

Fix intertrial variabilities to a certain value. Note that this will only have effect for variables not estimated from the data. This is relevant only when fitting the Full-DDM model, and not when fitting e.g. the weibull, angle, ornstein or levy models.

plot_varbool

Plot group variability parameters when calling pymc.Matplot.plot() (i.e. variance of Normal distribution.)

trace_subjsbool

Save trace for subjs (needed for many statistics so probably a good idea.)

std_dependsbool (default=False)

Should the depends_on keyword affect the group std node. If True it means that both, group mean and std will be split by condition.

Example:
>>> data, params = hddm.generate.gen_rand_data() # gen data
>>> model = hddm.HDDMnn(data, model = 'angle') # create object
>>> mcmc.sample(500, burn=20) # Sample from posterior

hddm.models.hddm_nn_regression module

class hddm.models.hddm_nn_regression.HDDMnnRegressor(data, models, group_only_regressors=True, keep_regressor_trace=False, indirect_regressors=None, indirect_betas=None, **kwargs)

Bases: HDDMRegressor

HDDMnnRegressor allows estimation of the NNDDM where parameter values are linear models of a covariate (e.g. a brain measure like fMRI or different conditions).

hddm.models.hddm_nn_rl module

class hddm.models.hddm_nn_rl.HDDMnnRL(*args, **kwargs)

Bases: HDDMnn

HDDMnn model class that uses neural network based likelihoods in conjuction with RL rules.

Arguments:
data: pandas.DataFrame

Input data with a row for each trial.

Must contain the following columns: * ‘rt’: Reaction time of trial in seconds. * ‘response’: Binary response (e.g. 0->error, 1->correct) * ‘subj_idx’: A unique ID (int) of each subject. * Other user-defined columns that can be used in depends_on keyword.

Optional:
model: str <default=’ddm’>

String that determines which sequential sampling model you would like to fit your data to. Currently available models are: ‘ddm’, ‘full_ddm’, ‘angle’, ‘weibull’, ‘ornstein’, ‘levy’

rl_rule: str <default=’RWupdate’>

String that determines which reinforcement learning model you would like to fit your data to.

include: list <default=None>

A list with parameters we wish to include in the fitting procedure. Which parameters you can include depends on the model you specified under the model parameters.

non_centered: bool <default=False>

Denotes whether non-centered distributions (a form of re-parameterization) should be used for reinforcement learning parameters.

informativebool <default=True>

Whether to use informative priors (True) or vague priors (False). Informative priors are not yet implemented for neural network based models.

is_group_modelbool

If True, this results in a hierarchical model with separate parameter distributions for each subject. The subject parameter distributions are themselves distributed according to a group parameter distribution.

p_outlierdouble (default=0.05)

The probability of outliers in the data. if p_outlier is passed in the ‘include’ argument, then it is estimated from the data and the value passed using the p_outlier argument is ignored.

Example:
>>> m = hddm.HDDMnnRL(data, model='angle', rl_rule='RWupdate', include=['v', 'a', 't', 'z', 'theta', 'rl_alpha'], p_outlier = 0.0)
>>> m.sample(2000, burn=1000, dbname='traces.db', db='pickle')

hddm.models.hddm_nn_rl_regression module

class hddm.models.hddm_nn_rl_regression.HDDMnnRLRegressor(data, models, group_only_regressors=True, keep_regressor_trace=False, indirect_regressors=None, indirect_betas=None, **kwargs)

Bases: HDDMRegressor

HDDMnnRLRegressor allows estimation of the RLSSM where parameter values are linear models of a covariate (e.g. a brain measure like fMRI or different conditions).

hddm.models.hddm_nn_stimcoding module

class hddm.models.hddm_nn_stimcoding.HDDMnnStimCoding(*args, **kwargs)

Bases: HDDMStimCoding

HDDMnn model that can be used when stimulus coding and estimation of bias (i.e. displacement of starting point z) is required.

In that case, the ‘resp’ column in your data should contain 0 and 1 for the chosen stimulus (or direction), not whether the response was correct or not as you would use in accuracy coding. You then have to provide another column (referred to as stim_col) which contains information about which the correct response was.

HDDMnnStimCoding distinguishes itself from the HDDMStimCoding class by allowing you to specify a variety of generative models. Likelihoods are based on Neural Networks.

Arguments:
model: str <default=’ddm’>

String that determines which model you would like to fit your data to. Currently available models are: ‘ddm’, ‘full_ddm’, ‘angle’, ‘weibull’, ‘ornstein’, ‘levy’

nbin: int <default=512>

Relevant only if network type was chosen to be ‘cnn’. CNNs can be trained on coarser or finer binnings of RT space. At this moment only networks with 512 bins are available.

include: list <default=None>

A list with parameters we wish to include in the fitting procedure. Generally, per default included in fitting are the drift parameter ‘v’, the boundary separation parameter ‘a’ and the non-decision-time ‘t’. Which parameters you can include depends on the model you specified under the model parameters.

split_param{‘v’, ‘z’} <default=’z’>

There are two ways to model stimulus coding in the case where both stimuli have equal information (so that there can be no difference in drift): * ‘z’: Use z for stimulus A and 1-z for stimulus B * ‘v’: Use drift v for stimulus A and -v for stimulus B

stim_colstr

Column name for extracting the stimuli to use for splitting.

drift_criterionbool <default=False>

Whether to estimate a constant factor added to the drift-rate. Requires split_param=’v’ to be set.

hddm.models.hddm_regression module

class hddm.models.hddm_regression.HDDMRegressor(data, models, group_only_regressors=True, keep_regressor_trace=False, **kwargs)

Bases: HDDM

HDDMRegressor allows estimation of the DDM where parameter values are linear models of a covariate (e.g. a brain measure like fMRI or different conditions).

class hddm.models.hddm_regression.KnodeRegress(*args, **kwargs)

Bases: Knode

create_node(name, kwargs, data)
hddm.models.hddm_regression.generate_wfpt_reg_stochastic_class(wiener_params=None, sampling_method='cdf', cdf_range=(-5, 5), sampling_dt=0.0001)

hddm.models.hddm_rl module

class hddm.models.hddm_rl.HDDMrl(*args, **kwargs)

Bases: HDDM

HDDM model that can be used for two-armed bandit tasks.

hddm.models.hddm_rl.wienerRL_like(x, v, alpha, pos_alpha, sv, a, z, sz, t, st, p_outlier=0)

hddm.models.hddm_rl_regression module

class hddm.models.hddm_rl_regression.HDDMrlRegressor(data, models, group_only_regressors=True, keep_regressor_trace=False, **kwargs)

Bases: HDDM

HDDMrlRegressor allows estimation of the RLDDM where parameter values are linear models of a covariate (e.g. a brain measure like fMRI or different conditions).

class hddm.models.hddm_rl_regression.KnodeRegress(*args, **kwargs)

Bases: Knode

create_node(name, kwargs, data)
hddm.models.hddm_rl_regression.generate_wfpt_rl_reg_stochastic_class(wiener_params=None, sampling_method='cdf', cdf_range=(-5, 5), sampling_dt=0.0001)

hddm.models.hddm_stimcoding module

class hddm.models.hddm_stimcoding.HDDMStimCoding(*args, **kwargs)

Bases: HDDM

HDDM model that can be used when stimulus coding and estimation of bias (i.e. displacement of starting point z) is required.

In that case, the ‘resp’ column in your data should contain 0 and 1 for the chosen stimulus (or direction), not whether the response was correct or not as you would use in accuracy coding. You then have to provide another column (referred to as stim_col) which contains information about which the correct response was.

Arguments:
split_param{‘v’, ‘z’} <default=’z’>

There are two ways to model stimulus coding in the case where both stimuli have equal information (so that there can be no difference in drift): * ‘z’: Use z for stimulus A and 1-z for stimulus B * ‘v’: Use drift v for stimulus A and -v for stimulus B

stim_colstr

Column name for extracting the stimuli to use for splitting.

drift_criterionbool <default=False>

Whether to estimate a constant factor added to the drift-rate. Requires split_param=’v’ to be set.

class hddm.models.hddm_stimcoding.KnodeWfptStimCoding(*args, **kwargs)

Bases: Knode

create_node(name, kwargs, data)

hddm.models.hddm_transformed module

class hddm.models.hddm_transformed.HDDMTransformed(*args, **kwargs)

Bases: HDDMBase

pre_sample()

hddm.models.hddm_truncated module

class hddm.models.hddm_truncated.HDDMTruncated(*args, **kwargs)

Bases: HDDMBase

hddm.models.rl module

class hddm.models.rl.Hrl(*args, **kwargs)

Bases: HDDM

RL model that can be used to analyze data from two-armed bandit tasks.

hddm.models.rl.RL_like(x, v, alpha, pos_alpha, z=0.5, p_outlier=0)

Module contents

class hddm.models.AccumulatorModel(data, **kwargs)

Bases: Hierarchical

get_average_model(quantiles=(0.1, 0.3, 0.5, 0.7, 0.9))
optimize(method, quantiles=(0.1, 0.3, 0.5, 0.7, 0.9), n_runs=3, n_bootstraps=0, parallel_profile=None)

Optimize model using ML, chi^2 or G^2.

Input:
methodstr

Optimization method (‘ML’, ‘chisquare’ or ‘gsquare’).

quantilestuple

A sequence of quantiles to be used for chi^2 and G^2. Default values are the ones used by Ratcliff (.1, .3, .5, .7, .9).

n_runsint <default=3>

Number of attempts to optimize.

n_bootstrapsint <default=0>

Number of bootstrap iterations.

parrall_profilestr <default=None>

IPython profile for parallelization.

Output:

results <dict> - a results dictionary of the parameters values.

Note:

The values of the nodes in single subject model is updated according to the results. The nodes of group models are not updated

class hddm.models.HDDM(*args, **kwargs)

Bases: HDDMBase

Create hierarchical drift-diffusion model in which each subject has a set of parameters that are constrained by a group distribution.

Arguments:
datapandas.DataFrame

Input data with a row for each trial.

Must contain the following columns: * ‘rt’: Reaction time of trial in seconds. * ‘response’: Binary response (e.g. 0->error, 1->correct) * ‘subj_idx’: A unique ID (int) of each subject. * Other user-defined columns that can be used in depends_on keyword.

Optional:
informativebool <default=True>

Whether to use informative priors (True) or vague priors (False). Information about the priors can be found in the methods section. If you run a classical DDM experiment you should use this. However, if you apply the DDM to a novel domain like saccade data where RTs are much lower, or RTs of rats, you should probably set this to False.

is_group_modelbool

If True, this results in a hierarchical model with separate parameter distributions for each subject. The subject parameter distributions are themselves distributed according to a group parameter distribution.

depends_ondict

Specifies which parameter depends on data of a column in data. For each unique element in that column, a separate set of parameter distributions will be created and applied. Multiple columns can be specified in a sequential container (e.g. list)

Example:
>>> hddm.HDDM(data, depends_on={'v': 'difficulty'})

Separate drift-rate parameters will be estimated for each difficulty. Requires ‘data’ to have a column difficulty.

biasbool

Whether to allow a bias to be estimated. This is normally used when the responses represent left/right and subjects could develop a bias towards responding right. This is normally never done, however, when the ‘response’ column codes correct/error.

p_outlierdouble <0.05>

The probability of outliers in the data. if p_outlier is passed in the ‘include’ argument, then it is estimated from the data and the value passed using the p_outlier argument is ignored.

default_intervarsdict <default = {‘sz’: 0, ‘st’: 0, ‘sv’: 0}>

Fix intertrial variabilities to a certain value. Note that this will only have effect for variables not estimated from the data.

plot_varbool

Plot group variability parameters when calling pymc.Matplot.plot() (i.e. variance of Normal distribution.)

trace_subjsbool

Save trace for subjs (needed for many statistics so probably a good idea.)

std_dependsbool <default=False>

Should the depends_on keyword affect the group std node. If True it means that both, group mean and std will be split by condition.

wiener_paramsdict

Parameters for wfpt evaluation and numerical integration.

Parameters:
  • err: Error bound for wfpt <default=1e-4>

  • n_st: Maximum depth for numerical integration for st <default=2>

  • n_sz: Maximum depth for numerical integration for Z <default=2>

  • use_adaptive: Whether to use adaptive numerical integration <default=True>

  • simps_err: Error bound for Simpson integration <default=1e-3>

Example:
>>> data, params = hddm.generate.gen_rand_data() # gen data
>>> model = hddm.HDDM(data) # create object
>>> model.sample(5000, burn=20) # Sample from posterior
pre_sample(use_slice=True)
class hddm.models.HDDMBase(data, bias=False, include=(), wiener_params=None, p_outlier=0.05, **kwargs)

Bases: AccumulatorModel

HDDM base class. Not intended to be used directly. Instead, use hddm.HDDM.

create_knodes()
plot_posterior_predictive(*args, **kwargs)
plot_posterior_quantiles(*args, **kwargs)

Plot posterior predictive quantiles.

Arguments:

model : HDDM model

Optional:
value_rangenumpy.ndarray

Range over which to evaluate the CDF.

samplesint (default=10)

Number of posterior samples to use.

alphafloat (default=.75)

Alpha (transparency) of posterior quantiles.

hexbinbool (default=False)

Whether to plot posterior quantile density using hexbin.

data_plot_kwargsdict (default=None)

Forwarded to data plotting function call.

predictive_plot_kwargsdict (default=None)

Forwareded to predictive plotting function call.

columnsint (default=3)

How many columns to use for plotting the subjects.

savebool (default=False)

Whether to save the figure to a file.

pathstr (default=None)

Save figure into directory prefix

class hddm.models.HDDMRegressor(data, models, group_only_regressors=True, keep_regressor_trace=False, **kwargs)

Bases: HDDM

HDDMRegressor allows estimation of the DDM where parameter values are linear models of a covariate (e.g. a brain measure like fMRI or different conditions).

class hddm.models.HDDMStimCoding(*args, **kwargs)

Bases: HDDM

HDDM model that can be used when stimulus coding and estimation of bias (i.e. displacement of starting point z) is required.

In that case, the ‘resp’ column in your data should contain 0 and 1 for the chosen stimulus (or direction), not whether the response was correct or not as you would use in accuracy coding. You then have to provide another column (referred to as stim_col) which contains information about which the correct response was.

Arguments:
split_param{‘v’, ‘z’} <default=’z’>

There are two ways to model stimulus coding in the case where both stimuli have equal information (so that there can be no difference in drift): * ‘z’: Use z for stimulus A and 1-z for stimulus B * ‘v’: Use drift v for stimulus A and -v for stimulus B

stim_colstr

Column name for extracting the stimuli to use for splitting.

drift_criterionbool <default=False>

Whether to estimate a constant factor added to the drift-rate. Requires split_param=’v’ to be set.

class hddm.models.HDDMTransformed(*args, **kwargs)

Bases: HDDMBase

pre_sample()
class hddm.models.HDDMTruncated(*args, **kwargs)

Bases: HDDMBase

class hddm.models.HDDMnn(*args, **kwargs)

Bases: HDDM

HDDM model class that uses neural network based likelihoods to include a variety of other models.

Arguments:
data: pandas.DataFrame

Input data with a row for each trial.

Must contain the following columns: * ‘rt’: Reaction time of trial in seconds. * ‘response’: Binary response (e.g. 0->error, 1->correct) * ‘subj_idx’: A unique ID (int) of each subject. * Other user-defined columns that can be used in depends_on keyword.

Optional:
model: str <default=’ddm’>

String that determines which model you would like to fit your data to. Currently available models are: ‘ddm’, ‘full_ddm’, ‘angle’, ‘weibull’, ‘ornstein’, ‘levy’

nbin: int <default=512>

Relevant only if network type was chosen to be ‘cnn’. CNNs can be trained on coarser or finer binnings of RT space. At this moment only networks with 512 bins are available.

include: list <default=None>

A list with parameters we wish to include in the fitting procedure. Generally, per default included in fitting are the drift parameter ‘v’, the boundary separation parameter ‘a’ and the non-decision-time ‘t’. Which parameters you can include depends on the model you specified under the model parameters.

informativebool <default=True>

Whether to use informative priors (True) or vague priors (False). Informative priors are not yet implemented for neural network based models.

is_group_modelbool

If True, this results in a hierarchical model with separate parameter distributions for each subject. The subject parameter distributions are themselves distributed according to a group parameter distribution.

depends_ondict

Specifies which parameter depends on data of a column in data. For each unique element in that column, a separate set of parameter distributions will be created and applied. Multiple columns can be specified in a sequential container (e.g. list)

Example:
>>> hddm.HDDM(data, depends_on={'v': 'difficulty'})

Separate drift-rate parameters will be estimated for each difficulty. Requires ‘data’ to have a column difficulty.

biasbool

Whether to allow a bias to be estimated. This is normally used when the responses represent left/right and subjects could develop a bias towards responding right. This is normally never done, however, when the ‘response’ column codes correct/error.

p_outlierdouble (default=0.05)

The probability of outliers in the data. if p_outlier is passed in the ‘include’ argument, then it is estimated from the data and the value passed using the p_outlier argument is ignored.

default_intervarsdict (default = {‘sz’: 0, ‘st’: 0, ‘sv’: 0})

Fix intertrial variabilities to a certain value. Note that this will only have effect for variables not estimated from the data. This is relevant only when fitting the Full-DDM model, and not when fitting e.g. the weibull, angle, ornstein or levy models.

plot_varbool

Plot group variability parameters when calling pymc.Matplot.plot() (i.e. variance of Normal distribution.)

trace_subjsbool

Save trace for subjs (needed for many statistics so probably a good idea.)

std_dependsbool (default=False)

Should the depends_on keyword affect the group std node. If True it means that both, group mean and std will be split by condition.

Example:
>>> data, params = hddm.generate.gen_rand_data() # gen data
>>> model = hddm.HDDMnn(data, model = 'angle') # create object
>>> mcmc.sample(500, burn=20) # Sample from posterior
class hddm.models.HDDMnnRL(*args, **kwargs)

Bases: HDDMnn

HDDMnn model class that uses neural network based likelihoods in conjuction with RL rules.

Arguments:
data: pandas.DataFrame

Input data with a row for each trial.

Must contain the following columns: * ‘rt’: Reaction time of trial in seconds. * ‘response’: Binary response (e.g. 0->error, 1->correct) * ‘subj_idx’: A unique ID (int) of each subject. * Other user-defined columns that can be used in depends_on keyword.

Optional:
model: str <default=’ddm’>

String that determines which sequential sampling model you would like to fit your data to. Currently available models are: ‘ddm’, ‘full_ddm’, ‘angle’, ‘weibull’, ‘ornstein’, ‘levy’

rl_rule: str <default=’RWupdate’>

String that determines which reinforcement learning model you would like to fit your data to.

include: list <default=None>

A list with parameters we wish to include in the fitting procedure. Which parameters you can include depends on the model you specified under the model parameters.

non_centered: bool <default=False>

Denotes whether non-centered distributions (a form of re-parameterization) should be used for reinforcement learning parameters.

informativebool <default=True>

Whether to use informative priors (True) or vague priors (False). Informative priors are not yet implemented for neural network based models.

is_group_modelbool

If True, this results in a hierarchical model with separate parameter distributions for each subject. The subject parameter distributions are themselves distributed according to a group parameter distribution.

p_outlierdouble (default=0.05)

The probability of outliers in the data. if p_outlier is passed in the ‘include’ argument, then it is estimated from the data and the value passed using the p_outlier argument is ignored.

Example:
>>> m = hddm.HDDMnnRL(data, model='angle', rl_rule='RWupdate', include=['v', 'a', 't', 'z', 'theta', 'rl_alpha'], p_outlier = 0.0)
>>> m.sample(2000, burn=1000, dbname='traces.db', db='pickle')
class hddm.models.HDDMnnRLRegressor(data, models, group_only_regressors=True, keep_regressor_trace=False, indirect_regressors=None, indirect_betas=None, **kwargs)

Bases: HDDMRegressor

HDDMnnRLRegressor allows estimation of the RLSSM where parameter values are linear models of a covariate (e.g. a brain measure like fMRI or different conditions).

class hddm.models.HDDMnnRegressor(data, models, group_only_regressors=True, keep_regressor_trace=False, indirect_regressors=None, indirect_betas=None, **kwargs)

Bases: HDDMRegressor

HDDMnnRegressor allows estimation of the NNDDM where parameter values are linear models of a covariate (e.g. a brain measure like fMRI or different conditions).

class hddm.models.HDDMnnStimCoding(*args, **kwargs)

Bases: HDDMStimCoding

HDDMnn model that can be used when stimulus coding and estimation of bias (i.e. displacement of starting point z) is required.

In that case, the ‘resp’ column in your data should contain 0 and 1 for the chosen stimulus (or direction), not whether the response was correct or not as you would use in accuracy coding. You then have to provide another column (referred to as stim_col) which contains information about which the correct response was.

HDDMnnStimCoding distinguishes itself from the HDDMStimCoding class by allowing you to specify a variety of generative models. Likelihoods are based on Neural Networks.

Arguments:
model: str <default=’ddm’>

String that determines which model you would like to fit your data to. Currently available models are: ‘ddm’, ‘full_ddm’, ‘angle’, ‘weibull’, ‘ornstein’, ‘levy’

nbin: int <default=512>

Relevant only if network type was chosen to be ‘cnn’. CNNs can be trained on coarser or finer binnings of RT space. At this moment only networks with 512 bins are available.

include: list <default=None>

A list with parameters we wish to include in the fitting procedure. Generally, per default included in fitting are the drift parameter ‘v’, the boundary separation parameter ‘a’ and the non-decision-time ‘t’. Which parameters you can include depends on the model you specified under the model parameters.

split_param{‘v’, ‘z’} <default=’z’>

There are two ways to model stimulus coding in the case where both stimuli have equal information (so that there can be no difference in drift): * ‘z’: Use z for stimulus A and 1-z for stimulus B * ‘v’: Use drift v for stimulus A and -v for stimulus B

stim_colstr

Column name for extracting the stimuli to use for splitting.

drift_criterionbool <default=False>

Whether to estimate a constant factor added to the drift-rate. Requires split_param=’v’ to be set.

class hddm.models.HDDMrl(*args, **kwargs)

Bases: HDDM

HDDM model that can be used for two-armed bandit tasks.

class hddm.models.HDDMrlRegressor(data, models, group_only_regressors=True, keep_regressor_trace=False, **kwargs)

Bases: HDDM

HDDMrlRegressor allows estimation of the RLDDM where parameter values are linear models of a covariate (e.g. a brain measure like fMRI or different conditions).

class hddm.models.Hrl(*args, **kwargs)

Bases: HDDM

RL model that can be used to analyze data from two-armed bandit tasks.