GithubHelp home page GithubHelp logo

hddm-devs / hddm Goto Github PK

View Code? Open in Web Editor NEW
259.0 259.0 120.0 204.78 MB

HDDM is a python module that implements Hierarchical Bayesian parameter estimation of Drift Diffusion Models (via PyMC).

Home Page: http://ski.clps.brown.edu/hddm_docs/

License: Other

Shell 0.01% Python 4.56% R 0.03% C 0.06% Batchfile 0.01% Jupyter Notebook 94.46% Makefile 0.01% Dockerfile 0.03% MATLAB 0.01% Cython 0.84%

hddm's People

Contributors

alexanderfengler avatar ctw avatar frankmj avatar gbiele avatar hcp4715 avatar isofer avatar janfreyberg avatar jona-sassenhagen avatar jwdegee avatar krishnbera avatar madslupe avatar michaelosthege avatar srsteinkamp avatar twiecki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hddm's Issues

Installation Problem for Mac with Python 3.7

I am having trouble installing hddm for my mac. I tried both the pip and conda install methods. I also have successfully installed all the dependencies (pymc3, pandas, kabuki, cython).

My error for the conda install method was that:
Solving environment: failed with current_repodata.json, will retry with next repodata source.

My error for the pip install method was:

#warning "Using deprecated NumPy API, disable it with "
^
src/wfpt.cpp:629:10: fatal error: 'algorithm' file not found
#include
^~~~~~~~~~~
2 warnings and 1 error generated.
error: command 'gcc' failed with exit status 1

Running setup.py install for HDDM ... error
ERROR: Command errored out with exit status 1:
command: /Users/vyshukadambi/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/q6/0f7npjx55x1452w50jc1f0th0000gn/T/pip-req-build-9l012xfs/setup.py'"'"'; file='"'"'/private/var/folders/q6/0f7npjx55x1452w50jc1f0th0000gn/T/pip-req-build-9l012xfs/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/q6/0f7npjx55x1452w50jc1f0th0000gn/T/pip-record-u4yj9cx8/install-record.txt --single-version-externally-managed --compile
cwd: /private/var/folders/q6/0f7npjx55x1452w50jc1f0th0000gn/T/pip-req-build-9l012xfs/
Complete output (59 lines):
running install
running build
running build_py
creating build
creating build/lib.macosx-10.7-x86_64-3.7
creating build/lib.macosx-10.7-x86_64-3.7/hddm
copying hddm/MPLTraits_qt.py -> build/lib.macosx-10.7-x86_64-3.7/hddm
copying hddm/generate.py -> build/lib.macosx-10.7-x86_64-3.7/hddm
copying hddm/init.py -> build/lib.macosx-10.7-x86_64-3.7/hddm
copying hddm/utils.py -> build/lib.macosx-10.7-x86_64-3.7/hddm
copying hddm/diag.py -> build/lib.macosx-10.7-x86_64-3.7/hddm
copying hddm/MPLTraits.py -> build/lib.macosx-10.7-x86_64-3.7/hddm
copying hddm/likelihoods.py -> build/lib.macosx-10.7-x86_64-3.7/hddm
creating build/lib.macosx-10.7-x86_64-3.7/hddm/tests
copying hddm/tests/benchmark.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/tests
copying hddm/tests/init.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/tests
copying hddm/tests/test_generate.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/tests
copying hddm/tests/matlab_values.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/tests
copying hddm/tests/test_likelihoods.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/tests
copying hddm/tests/test_models.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/tests
copying hddm/tests/test_optimization.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/tests
creating build/lib.macosx-10.7-x86_64-3.7/hddm/models
copying hddm/models/rl.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/models
copying hddm/models/hddm_regression.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/models
copying hddm/models/hddm_rl.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/models
copying hddm/models/init.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/models
copying hddm/models/hddm_info.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/models
copying hddm/models/hddm_stimcoding.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/models
copying hddm/models/hddm_truncated.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/models
copying hddm/models/hddm_transformed.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/models
copying hddm/models/base.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/models
creating build/lib.macosx-10.7-x86_64-3.7/hddm/examples
copying hddm/examples/simple_model.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/examples
copying hddm/examples/plot_posterior_quantiles.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/examples
copying hddm/examples/init.py -> build/lib.macosx-10.7-x86_64-3.7/hddm/examples
copying hddm/examples/simple_subjs_difficulty.csv -> build/lib.macosx-10.7-x86_64-3.7/hddm/examples
copying hddm/examples/simple_subjs_difficulty_single.csv -> build/lib.macosx-10.7-x86_64-3.7/hddm/examples
copying hddm/examples/cavanagh_theta_nn.csv -> build/lib.macosx-10.7-x86_64-3.7/hddm/examples
copying hddm/examples/rlddm_data.csv -> build/lib.macosx-10.7-x86_64-3.7/hddm/examples
copying hddm/examples/simple_difficulty.csv -> build/lib.macosx-10.7-x86_64-3.7/hddm/examples
copying hddm/examples/simple_difficulty.conf -> build/lib.macosx-10.7-x86_64-3.7/hddm/examples
running build_ext
building 'wfpt' extension
creating build/temp.macosx-10.7-x86_64-3.7
creating build/temp.macosx-10.7-x86_64-3.7/src
gcc -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/Cellar/openssl/1.0.2t/include -I/Users/vyshukadambi/anaconda3/lib/python3.7/site-packages/numpy/core/include -I/Users/vyshukadambi/anaconda3/include/python3.7m -c src/wfpt.cpp -o build/temp.macosx-10.7-x86_64-3.7/src/wfpt.o
warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
In file included from src/wfpt.cpp:626:
In file included from /Users/vyshukadambi/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4:
In file included from /Users/vyshukadambi/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12:
In file included from /Users/vyshukadambi/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1824:
/Users/vyshukadambi/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
#warning "Using deprecated NumPy API, disable it with "
^
src/wfpt.cpp:629:10: fatal error: 'algorithm' file not found
#include
^~~~~~~~~~~
2 warnings and 1 error generated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Users/vyshukadambi/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/q6/0f7npjx55x1452w50jc1f0th0000gn/T/pip-req-build-9l012xfs/setup.py'"'"'; file='"'"'/private/var/folders/q6/0f7npjx55x1452w50jc1f0th0000gn/T/pip-req-build-9l012xfs/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/q6/0f7npjx55x1452w50jc1f0th0000gn/T/pip-record-u4yj9cx8/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

Can't install hddm in Conda virutal env Python 3.5 Ubuntu 18.04

I'm trying to install hddm in an Anaconda virtual environment using the following commands.

conda create -n py35hddm python=3.5
conda activate py35hddm
conda install -c pymc hddm

but I keep getting the same error.

Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: - 
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed                                                                                              

UnsatisfiableError: The following specifications were found to be incompatible with each other:

Output in format: Requested package -> Available versions

No idea what packages are in conflict as it does not output anything about it.

This is the output of conda list of the env:

# packages in environment at anaconda3/envs/py35hddm:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
ca-certificates           2020.6.24                     0  
certifi                   2018.8.24                py35_1  
libedit                   3.1.20191231         h14c3975_1  
libffi                    3.2.1                hd88cf55_4  
libgcc-ng                 9.1.0                hdf63c60_0  
libstdcxx-ng              9.1.0                hdf63c60_0  
ncurses                   6.2                  he6710b0_1  
openssl                   1.0.2u               h7b6447c_0  
pip                       10.0.1                   py35_0  
python                    3.5.6                hc3d631a_0  
readline                  7.0                  h7b6447c_5  
setuptools                40.2.0                   py35_0  
sqlite                    3.32.3               h62c20be_0  
tk                        8.6.10               hbc83047_0  
wheel                     0.31.1                   py35_0  
xz                        5.2.5                h7b6447c_0  
zlib                      1.2.11               h7b6447c_3  

And my Anaconda installation:

 active environment : py35hddm
    active env location : /home/nico/anaconda3/envs/py35hddm
            shell level : 1
       user config file : /home/nico/.condarc
 populated config files : /home/nico/.condarc
          conda version : 4.8.3
    conda-build version : 3.17.8
         python version : 3.7.3.final.0
       virtual packages : __glibc=2.27
       base environment : /home/nico/anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/nico/anaconda3/pkgs
                          /home/nico/.conda/pkgs
       envs directories : /home/nico/anaconda3/envs
                          /home/nico/.conda/envs
               platform : linux-64
             user-agent : conda/4.8.3 requests/2.24.0 CPython/3.7.3 Linux/5.4.0-42-generic ubuntu/18.04.4 glibc/2.27
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False

Any idea?

loading data with HDDM tutorial

hello,

I've beeb using a python 2.7 environment using Conda and jupyter notebook. I can't load the data data = hddm.load_csv ('./cavanagh_theta_nn.csv')

I get the error message
IOError Traceback (most recent call last)
in ()
----> 1 data = hddm.load_csv ('./cavanagh_theta_nn.csv')

/Users/gorana/opt/anaconda3/envs/py27/lib/python2.7/site-packages/kabuki/utils.pyc in load_csv(*args, **kwargs)
132 :SeeAlso: save_csv, pandas.read_csv()
133 """
--> 134 return pd.read_csv(*args, **kwargs)
135
136

/Users/gorana/opt/anaconda3/envs/py27/lib/python2.7/site-packages/pandas/io/parsers.pyc in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision)
700 skip_blank_lines=skip_blank_lines)
701
--> 702 return _read(filepath_or_buffer, kwds)
703
704 parser_f.name = name

/Users/gorana/opt/anaconda3/envs/py27/lib/python2.7/site-packages/pandas/io/parsers.pyc in _read(filepath_or_buffer, kwds)
427
428 # Create the parser.
--> 429 parser = TextFileReader(filepath_or_buffer, **kwds)
430
431 if chunksize or iterator:

/Users/gorana/opt/anaconda3/envs/py27/lib/python2.7/site-packages/pandas/io/parsers.pyc in init(self, f, engine, **kwds)
893 self.options['has_index_names'] = kwds['has_index_names']
894
--> 895 self._make_engine(self.engine)
896
897 def close(self):

/Users/gorana/opt/anaconda3/envs/py27/lib/python2.7/site-packages/pandas/io/parsers.pyc in _make_engine(self, engine)
1120 def _make_engine(self, engine='c'):
1121 if engine == 'c':
-> 1122 self._engine = CParserWrapper(self.f, **self.options)
1123 else:
1124 if engine == 'python':

/Users/gorana/opt/anaconda3/envs/py27/lib/python2.7/site-packages/pandas/io/parsers.pyc in init(self, src, **kwds)
1851 kwds['usecols'] = self.usecols
1852
-> 1853 self._reader = parsers.TextReader(src, **kwds)
1854 self.unnamed_cols = self._reader.unnamed_cols
1855

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.cinit()

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source()

IOError: [Errno 2] File ./cavanagh_theta_nn.csv does not exist: './cavanagh_theta_nn.csv'

I think the issue is my directory, but I don't know what to change the directory to using os.chdir. I've tried to make my own csv from the GitHub data, but that didn't work. I don't know how to ask python to use the GitHub directory to carry this out either.

I have 0 python/coding experience.

Deprecation Warnings and PyMC

I am getting deprecation warnings for pymc, which I can see is now deprecated by PyMC3, when calling model_group_basic.sample(num_samples,burn=num_burn,dbname=model_group_basic_traces,db='pickle')

C:\Anaconda3\lib\site-packages\pymc\Node.py:403: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
self.name = input['name']
C:\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py:224: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future

I noticed HDDM has not been updated in several years, and just wondering whether to expect upgrades soon or to remain on the deprecated pymc.

stats do not show up after loading any model

#Output for loaded model

model.print_stats()
mean std 2.5q 25q 50q 75q 97.5q mc err
a(NJ.day1) NaN NaN NaN NaN NaN NaN NaN NaN
a(NJ.day2) NaN NaN NaN NaN NaN NaN NaN NaN
....
v_C(rwd)[T.5] NaN NaN NaN NaN NaN NaN NaN NaN
v_C(rwd)[T.6] NaN NaN NaN NaN NaN NaN NaN NaN
DIC: 3311.607805
deviance: 3188.665514
pD: 122.942291

Tutorial documentation

hddm/docs/tutorial_config_difficulty.rst

The tutorial describes the data in simple_difficulty.csv as:

The rows following the header contain the reaction time of the trial, followed by a comma, followed by the response made (e.g. 1=correct, 0=error or 1=left, 0=right), followed by the difficulty of the trial. Note, that ‘difficulty’ is just an example, you can call them whatever you like.

The data in simple_difficulty.csv looks like:
response,rt,difficulty
1.0,1.06,hard
1.0,1.052,hard

Looks like the tutorial should read:
The rows following the header contain the response made (e.g. 1=correct, 0=error or 1=left, 0=right), followed by the reaction time of the trial, followed by the difficulty of the trial. Note, that ‘difficulty’ is just an example, you can call them whatever you like.

test_optimization.py unittests are failing.

>>nosetests test_optimization.py
..FF...
======================================================================
FAIL: hddm.tests.test_optimization.test_chisquare_recovery_single_subject_from_true_starting_point
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/wiecki/envs/hddm/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/wiecki/working/projects/hddm/hddm/tests/test_optimization.py", line 126, in test_chisquare_recovery_single_subject_from_true_starting_point
    optimization_recovery_single_subject(repeats=5, seed=1, true_starting_point=True, optimization_method='chisquare')
  File "/home/wiecki/working/projects/hddm/hddm/tests/test_optimization.py", line 93, in optimization_recovery_single_subject
    np.testing.assert_allclose(df.values[0], df.values[1], atol=0.1)
  File "/home/wiecki/envs/hddm/local/lib/python2.7/site-packages/numpy/testing/utils.py", line 1168, in assert_allclose
    verbose=verbose, header=header)
  File "/home/wiecki/envs/hddm/local/lib/python2.7/site-packages/numpy/testing/utils.py", line 636, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Not equal to tolerance rtol=1e-07, atol=0.1

(mismatch 100.0%)
 x: array([ 0.66630308,  0.27365502,  0.        ,  0.5       ,  0.75      ,
        1.        ,  0.56300107])
 y: array([ 0.65926739,  0.27516055,  0.12853521,  0.613678  ,  0.86490377,
        1.06992727,  0.54477662])
-------------------- >> begin captured stdout << ---------------------
*** the true parameters ***
{'v(c3)': 1.0, 'a': 0.5001715622260173, 'sz': 0, 'v(c2)': 0.75, 'sv': 0, 'st': 0, 't': 0.4160973480326474, 'v(c0)': 0, 'z': 0.5, 'v(c1)': 0.5}
Optimization terminated successfully.
         Current function value: 1903.806592
         Iterations: 3
         Function evaluations: 221
Optimization terminated successfully.
         Current function value: 1903.806747
         Iterations: 5
         Function evaluations: 355
Warning: Maximum number of function evaluations has been exceeded.
               a      t  v(c0)  v(c1)  v(c2)  v(c3)
true       0.500  0.416  0.000  0.500  0.750  1.000
estimated  0.496  0.417  0.002  0.457  0.832  1.008
*** the true parameters ***
{'v(c3)': 1.0, 'a': 1.9121569474977251, 'sz': 0, 'v(c2)': 0.75, 'sv': 0, 'st': 0, 't': 0.2505529076859609, 'v(c0)': 0, 'z': 0.5, 'v(c1)': 0.5}
Optimization terminated successfully.
         Current function value: 172.078258
         Iterations: 3
         Function evaluations: 235
Optimization terminated successfully.
         Current function value: 172.078232
         Iterations: 5
         Function evaluations: 384
Optimization terminated successfully.
         Current function value: 172.078228
         Iterations: 8
         Function evaluations: 611
               a      t  v(c0)  v(c1)  v(c2)  v(c3)
true       1.912  0.251  0.000  0.500  0.750  1.000
estimated  1.911  0.256  0.001  0.495  0.766  0.974
*** the true parameters ***
{'v(c3)': 1.0, 'a': 0.6588550480374213, 'sz': 0, 'v(c2)': 0.75, 'sv': 0, 'st': 0, 't': 0.38766784309341146, 'v(c0)': 0, 'z': 0.5, 'v(c1)': 0.5}
Optimization terminated successfully.
         Current function value: 852.619434
         Iterations: 3
         Function evaluations: 229
Optimization terminated successfully.
         Current function value: 852.626209
         Iterations: 10
         Function evaluations: 665
Optimization terminated successfully.
         Current function value: 852.619511
         Iterations: 5
         Function evaluations: 362
               a      t  v(c0)  v(c1)  v(c2)  v(c3)
true       0.659  0.388  0.000  0.500  0.750  1.000
estimated  0.666  0.386 -0.001  0.549  0.752  0.932
*** the true parameters ***
{'v(c3)': 1.0, 'a': 1.3095831118813606, 'sz': 0, 'v(c2)': 0.75, 'sv': 0, 'st': 0, 't': 0.4121142876735653, 'v(c0)': 0, 'z': 0.5, 'v(c1)': 0.5}
Optimization terminated successfully.
         Current function value: 324.017378
         Iterations: 3
         Function evaluations: 235
Optimization terminated successfully.
         Current function value: 324.017387
         Iterations: 5
         Function evaluations: 373
Optimization terminated successfully.
         Current function value: 324.017380
         Iterations: 6
         Function evaluations: 451
               a      t  v(c0)  v(c1)  v(c2)  v(c3)
true       1.310  0.412  0.000  0.500  0.750  1.000
estimated  1.307  0.414  0.025  0.518  0.726  0.993
*** the true parameters ***
{'v(c3)': 1.0, 'a': 0.592369877607861, 'sz': 0, 'v(c2)': 0.75, 'sv': 0, 'st': 0, 't': 0.35280088557498057, 'v(c0)': 0, 'z': 0.5, 'v(c1)': 0.5}
Optimization terminated successfully.
         Current function value: 1112.505000
         Iterations: 3
         Function evaluations: 236
Warning: Maximum number of function evaluations has been exceeded.
Optimization terminated successfully.
         Current function value: 1112.505000
         Iterations: 8
         Function evaluations: 587
               a      t  v(c0)  v(c1)  v(c2)  v(c3)
true       0.592  0.353   0.00  0.500  0.750   1.00
estimated  0.588  0.353  -0.01  0.438  0.786   0.93
*** the true parameters ***
{'v(c3)': 1.0, 'a': 1.7204219618387624, 'sz': 0, 'v(c2)': 0.75, 'sv': 0, 'st': 0, 't': 0.4051326837907725, 'v(c0)': 0, 'z': 0.5986094931105445, 'v(c1)': 0.5}
Optimization terminated successfully.
         Current function value: 213.333105
         Iterations: 5
         Function evaluations: 456
Optimization terminated successfully.
         Current function value: 213.333872
         Iterations: 7
         Function evaluations: 623
Optimization terminated successfully.
         Current function value: 213.333922
         Iterations: 6
         Function evaluations: 532
              a      t  v(c0)  v(c1)  v(c2)  v(c3)      z
true       1.72  0.405  0.000  0.500  0.750  1.000  0.599
estimated  1.71  0.410  0.028  0.509  0.785  1.037  0.588
*** the true parameters ***
{'v(c3)': 1.0, 'a': 0.6663030751135781, 'sz': 0, 'v(c2)': 0.75, 'sv': 0, 'st': 0, 't': 0.273655018463263, 'v(c0)': 0, 'z': 0.5630010742790033, 'v(c1)': 0.5}
Optimization terminated successfully.
         Current function value: 629.375166
         Iterations: 6
         Function evaluations: 531
Optimization terminated successfully.
         Current function value: 629.374003
         Iterations: 7
         Function evaluations: 578
Optimization terminated successfully.
         Current function value: 629.366813
         Iterations: 11
         Function evaluations: 954
               a      t  v(c0)  v(c1)  v(c2)  v(c3)      z
true       0.666  0.274  0.000  0.500  0.750   1.00  0.563
estimated  0.659  0.275  0.129  0.614  0.865   1.07  0.545

--------------------- >> end captured stdout << ----------------------

======================================================================
FAIL: hddm.tests.test_optimization.test_gsquare_recovery_single_subject_from_true_starting_point
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/wiecki/envs/hddm/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/wiecki/working/projects/hddm/hddm/tests/test_optimization.py", line 129, in test_gsquare_recovery_single_subject_from_true_starting_point
    optimization_recovery_single_subject(repeats=5, seed=1, true_starting_point=True, optimization_method='gsquare')
  File "/home/wiecki/working/projects/hddm/hddm/tests/test_optimization.py", line 93, in optimization_recovery_single_subject
    np.testing.assert_allclose(df.values[0], df.values[1], atol=0.1)
  File "/home/wiecki/envs/hddm/local/lib/python2.7/site-packages/numpy/testing/utils.py", line 1168, in assert_allclose
    verbose=verbose, header=header)
  File "/home/wiecki/envs/hddm/local/lib/python2.7/site-packages/numpy/testing/utils.py", line 636, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Not equal to tolerance rtol=1e-07, atol=0.1

(mismatch 100.0%)
 x: array([ 0.66630308,  0.27365502,  0.        ,  0.5       ,  0.75      ,
        1.        ,  0.56300107])
 y: array([ 0.66036752,  0.27511103,  0.11856771,  0.62397546,  0.87239892,
        1.08069072,  0.54353552])
-------------------- >> begin captured stdout << ---------------------
*** the true parameters ***
{'v(c3)': 1.0, 'a': 0.5001715622260173, 'sz': 0, 'v(c2)': 0.75, 'sv': 0, 'st': 0, 't': 0.4160973480326474, 'v(c0)': 0, 'z': 0.5, 'v(c1)': 0.5}
Optimization terminated successfully.
         Current function value: 245830.269597
         Iterations: 2
         Function evaluations: 143
Optimization terminated successfully.
         Current function value: 245826.840369
         Iterations: 4
         Function evaluations: 281
Warning: Maximum number of function evaluations has been exceeded.
               a      t  v(c0)  v(c1)  v(c2)  v(c3)
true       0.500  0.416  0.000  0.500  0.750  1.000
estimated  0.499  0.417 -0.025  0.451  0.813  0.999
*** the true parameters ***
{'v(c3)': 1.0, 'a': 1.9121569474977251, 'sz': 0, 'v(c2)': 0.75, 'sv': 0, 'st': 0, 't': 0.2505529076859609, 'v(c0)': 0, 'z': 0.5, 'v(c1)': 0.5}
Optimization terminated successfully.
         Current function value: 233182.025709
         Iterations: 1
         Function evaluations: 68
Optimization terminated successfully.
         Current function value: 233176.772750
         Iterations: 5
         Function evaluations: 328
Optimization terminated successfully.
         Current function value: 233177.115979
         Iterations: 4
         Function evaluations: 267
               a      t  v(c0)  v(c1)  v(c2)  v(c3)
true       1.912  0.251      0  0.500   0.75  1.000
estimated  1.915  0.256      0  0.498   0.77  0.977
*** the true parameters ***
{'v(c3)': 1.0, 'a': 0.6588550480374213, 'sz': 0, 'v(c2)': 0.75, 'sv': 0, 'st': 0, 't': 0.38766784309341146, 'v(c0)': 0, 'z': 0.5, 'v(c1)': 0.5}
Optimization terminated successfully.
         Current function value: 244186.060004
         Iterations: 2
         Function evaluations: 140
Optimization terminated successfully.
         Current function value: 244184.428892
         Iterations: 4
         Function evaluations: 282
Optimization terminated successfully.
         Current function value: 244184.435312
         Iterations: 5
         Function evaluations: 326
               a      t  v(c0)  v(c1)  v(c2)  v(c3)
true       0.659  0.388  0.000  0.500  0.750  1.000
estimated  0.667  0.386  0.013  0.534  0.744  0.937
*** the true parameters ***
{'v(c3)': 1.0, 'a': 1.3095831118813606, 'sz': 0, 'v(c2)': 0.75, 'sv': 0, 'st': 0, 't': 0.4121142876735653, 'v(c0)': 0, 'z': 0.5, 'v(c1)': 0.5}
Optimization terminated successfully.
         Current function value: 238924.910313
         Iterations: 1
         Function evaluations: 71
Optimization terminated successfully.
         Current function value: 238921.780183
         Iterations: 3
         Function evaluations: 213
Optimization terminated successfully.
         Current function value: 238921.567039
         Iterations: 5
         Function evaluations: 346
               a      t  v(c0)  v(c1)  v(c2)  v(c3)
true       1.310  0.412  0.000  0.500  0.750  1.000
estimated  1.308  0.414  0.027  0.516  0.728  0.994
*** the true parameters ***
{'v(c3)': 1.0, 'a': 0.592369877607861, 'sz': 0, 'v(c2)': 0.75, 'sv': 0, 'st': 0, 't': 0.35280088557498057, 'v(c0)': 0, 'z': 0.5, 'v(c1)': 0.5}
Optimization terminated successfully.
         Current function value: 244878.185234
         Iterations: 1
         Function evaluations: 70
Warning: Maximum number of function evaluations has been exceeded.
Optimization terminated successfully.
         Current function value: 244872.172495
         Iterations: 4
         Function evaluations: 278
               a      t  v(c0)  v(c1)  v(c2)  v(c3)
true       0.592  0.353  0.000  0.500  0.750  1.000
estimated  0.589  0.353 -0.005  0.448  0.777  0.923
*** the true parameters ***
{'v(c3)': 1.0, 'a': 1.7204219618387624, 'sz': 0, 'v(c2)': 0.75, 'sv': 0, 'st': 0, 't': 0.4051326837907725, 'v(c0)': 0, 'z': 0.5986094931105445, 'v(c1)': 0.5}
Optimization terminated successfully.
         Current function value: 228886.405374
         Iterations: 3
         Function evaluations: 251
Optimization terminated successfully.
         Current function value: 228884.829504
         Iterations: 4
         Function evaluations: 322
Optimization terminated successfully.
         Current function value: 228883.655281
         Iterations: 8
         Function evaluations: 646
               a      t  v(c0)  v(c1)  v(c2)  v(c3)      z
true       1.720  0.405  0.000  0.500  0.750  1.000  0.599
estimated  1.711  0.410  0.027  0.509  0.785  1.036  0.588
*** the true parameters ***
{'v(c3)': 1.0, 'a': 0.6663030751135781, 'sz': 0, 'v(c2)': 0.75, 'sv': 0, 'st': 0, 't': 0.273655018463263, 'v(c0)': 0, 'z': 0.5630010742790033, 'v(c1)': 0.5}
Optimization terminated successfully.
         Current function value: 241663.365866
         Iterations: 3
         Function evaluations: 244
Optimization terminated successfully.
         Current function value: 241670.396260
         Iterations: 4
         Function evaluations: 327
Optimization terminated successfully.
         Current function value: 241661.948524
         Iterations: 8
         Function evaluations: 680
               a      t  v(c0)  v(c1)  v(c2)  v(c3)      z
true       0.666  0.274  0.000  0.500  0.750  1.000  0.563
estimated  0.660  0.275  0.119  0.624  0.872  1.081  0.544

--------------------- >> end captured stdout << ----------------------

----------------------------------------------------------------------
Ran 7 tests in 597.239s

FAILED (failures=2)

Add documentation

  • How to spot convergence problems and what to do about them
  • How to save and load models (load_from_db)
  • How to code responses (stimulus VS accuracy)
  • depends_on can receive lists.

getting AttributeError: module 'pymc' has no attribute 'Matplot'

I made a model using following code:
m_reg = hddm.HDDMRegressor(idf, reg_descr, include='z') m_reg.find_starting_values() m_reg.sample(10000, burn=500,thin=5,dbname='intmodel.db',db='pickle') m_reg.save('intmodel')

and when performing m_reg.plot_posteriors(), i get following traceback:

`AttributeError Traceback (most recent call last)
in
----> 1 m_reg.plot_posteriors()

~\Anaconda3\envs\py36ddm\lib\site-packages\kabuki\hierarchical.py in plot_posteriors(self, params, plot_subjs, save, **kwargs)
857 if (params is not None) and (node['knode_name'] in params): # plot if it was sepecficily mentioned
858 node['node'].plot = True
--> 859 pm.Matplot.plot(node['node'], last=save, **kwargs)
860 node['node'].plot = plot_value
861

AttributeError: module 'pymc' has no attribute 'Matplot'`

Problems with Pandas 0.13

I'm trying HDDM for the first time so I might be doing something dumb, but I'm getting errors that look like they are caused by Series no longer being an NDArray in pandas 0.13.

See gist here with data file, script, and the full traceback.

The short version is that

hddm.HDDM(df)

takes a long and winding road to raising

TypeError: Argument 'x' has incorrect type (expected numpy.ndarray, got Series)

with

print df.head()

     rt             response subj_idx
0  1.207926         1     pc07
1  1.772109         1     pc07
2  1.005322         1     pc07
3  1.505597         0     pc07
4  1.974979         1     pc07

I installed pandas from the github release right before doing this (it's not on PyPi for some reason).

Installation problem

Hey,
I can't install hddm using pip on python 3.5.2.2, windows 10 64x (I'm using WinPyhon).

Do you have any idea on why is this erroring?

Thanks a lot!

Here's the full error log:

Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,>=1.5.6 in c:\users\dom\desktop\winpython-64bit-3.5.2.2\python-3.5.2.amd64\lib\site-packages (from matplotlib>=1.0.0->kabuki>=0.6.0->HDDM==0.6.1)
Requirement already satisfied: cycler in c:\users\dom\desktop\winpython-64bit-3.5.2.2\python-3.5.2.amd64\lib\site-packages (from matplotlib>=1.0.0->kabuki>=0.6.0->HDDM==0.6.1)
Installing collected packages: HDDM
  Running setup.py install for HDDM ... error
    Complete output from command C:\Users\Dom\Desktop\WinPython-64bit-3.5.2.2\python-
3.5.2.amd64\python.exe -u -c "import setuptools, 
tokenize;__file__='C:\\Users\\Dom\\AppData\\Local\\Temp\\pip-eaetvo7a-
build\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', 
'\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Dom\AppData\Local\Temp\pip-
uc4akrza-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.5
    creating build\lib.win-amd64-3.5\hddm
    copying hddm\diag.py -> build\lib.win-amd64-3.5\hddm
    copying hddm\generate.py -> build\lib.win-amd64-3.5\hddm
    copying hddm\likelihoods.py -> build\lib.win-amd64-3.5\hddm
    copying hddm\MPLTraits.py -> build\lib.win-amd64-3.5\hddm
    copying hddm\MPLTraits_qt.py -> build\lib.win-amd64-3.5\hddm
    copying hddm\utils.py -> build\lib.win-amd64-3.5\hddm
    copying hddm\__init__.py -> build\lib.win-amd64-3.5\hddm
    creating build\lib.win-amd64-3.5\hddm\tests
    copying hddm\tests\benchmark.py -> build\lib.win-amd64-3.5\hddm\tests
    copying hddm\tests\matlab_values.py -> build\lib.win-amd64-3.5\hddm\tests
    copying hddm\tests\test_generate.py -> build\lib.win-amd64-3.5\hddm\tests
    copying hddm\tests\test_likelihoods.py -> build\lib.win-amd64-3.5\hddm\tests
    copying hddm\tests\test_models.py -> build\lib.win-amd64-3.5\hddm\tests
    copying hddm\tests\test_optimization.py -> build\lib.win-amd64-3.5\hddm\tests
    copying hddm\tests\__init__.py -> build\lib.win-amd64-3.5\hddm\tests
    creating build\lib.win-amd64-3.5\hddm\models
    copying hddm\models\base.py -> build\lib.win-amd64-3.5\hddm\models
    copying hddm\models\hddm_info.py -> build\lib.win-amd64-3.5\hddm\models
    copying hddm\models\hddm_regression.py -> build\lib.win-amd64-3.5\hddm\models
    copying hddm\models\hddm_stimcoding.py -> build\lib.win-amd64-3.5\hddm\models
    copying hddm\models\hddm_transformed.py -> build\lib.win-amd64-3.5\hddm\models
    copying hddm\models\hddm_truncated.py -> build\lib.win-amd64-3.5\hddm\models
    copying hddm\models\__init__.py -> build\lib.win-amd64-3.5\hddm\models
    creating build\lib.win-amd64-3.5\hddm\examples
    copying hddm\examples\plot_posterior_quantiles.py -> build\lib.win-amd64-3.5\hddm\examples
    copying hddm\examples\simple_model.py -> build\lib.win-amd64-3.5\hddm\examples
    copying hddm\examples\__init__.py -> build\lib.win-amd64-3.5\hddm\examples
    copying hddm\examples\cavanagh_theta_nn.csv -> build\lib.win-amd64-3.5\hddm\examples
    copying hddm\examples\simple_difficulty.csv -> build\lib.win-amd64-3.5\hddm\examples
    copying hddm\examples\simple_subjs_difficulty.csv -> build\lib.win-amd64-3.5\hddm\examples
    copying hddm\examples\simple_subjs_difficulty_single.csv -> build\lib.win-amd64-3.5\hddm\examples
    copying hddm\examples\simple_difficulty.conf -> build\lib.win-amd64-3.5\hddm\examples
    running build_ext
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Dom\AppData\Local\Temp\pip-eaetvo7a-build\setup.py", line 39, in <module>
        ext_modules = ext_modules
      File "C:\Users\Dom\Desktop\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\Users\Dom\Desktop\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\lib\distutils\dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "C:\Users\Dom\Desktop\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Users\Dom\Desktop\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\lib\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "C:\Users\Dom\Desktop\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\lib\distutils\command\install.py", line 539, in run
        self.run_command('build')
      File "C:\Users\Dom\Desktop\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Users\Dom\Desktop\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Users\Dom\Desktop\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "C:\Users\Dom\Desktop\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Users\Dom\Desktop\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Users\Dom\Desktop\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\lib\site-packages\setuptools\command\build_ext.py", line 68, in run
        _build_ext.run(self)
      File "C:\Users\Dom\Desktop\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\lib\site-packages\Cython\Distutils\build_ext.py", line 164, in run
        _build_ext.build_ext.run(self)
      File "C:\Users\Dom\Desktop\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\lib\distutils\command\build_ext.py", line 307, in run
        force=self.force)
      File "C:\Users\Dom\Desktop\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\lib\distutils\ccompiler.py", line 1031, in new_compiler
        return klass(None, dry_run, force)
      File "C:\Users\Dom\Desktop\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\lib\distutils\cygwinccompiler.py", line 282, in __init__
        CygwinCCompiler.__init__ (self, verbose, dry_run, force)
      File "C:\Users\Dom\Desktop\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\lib\distutils\cygwinccompiler.py", line 126, in __init__
        if self.ld_version >= "2.10.90":
    TypeError: unorderable types: NoneType() >= str()

    ----------------------------------------
Command "C:\Users\Dom\Desktop\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\python.exe -u -c 
"import setuptools, tokenize;__file__='C:\\Users\\Dom\\AppData\\Local\\Temp\\pip-eaetvo7a-
build\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', 
'\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Dom\AppData\Local\Temp\pip-
uc4akrza-record\install-record.txt --single-version-externally-managed --compile" failed with error code 
1 in C:\Users\Dom\AppData\Local\Temp\pip-eaetvo7a-build\

Reproducibility issue

Hi

I'm attempting to seed the random number stream to get identical results every time.
A notebook showing what I mean is at

https://github.com/mikecroucher/hddm_test/blob/master/hddm_test.ipynb

That notebook performs the same calculation 4 times while setting random number seed.
Runs 2 and 3 are identical as I would hope but these are different from runs 1 and 4.

My guess is that some sort of parallelisation is going on which may cause numbers to be drawn from the random stream in different orders sometimes.

Any ideas? Should I be initialising the seed anywhere else?

HDDMInformative and HDDMNoninformative

take HDDMGamma from HDDM-paper and create two models: HDDMInformative, and HDDMNoninformative

class HDDMBase2(Accumulator / HDDMBase)
in here we will add the create_family_x()

class HDDMInfo(HDDMBase2)
class HDDMNoninfo(HDDMBase2)

plot_posterior_predictive for single subject

Is it possible to use plot_posterior_predictive for a specific subject?

In case of >50 subjects not all fit one big subplot. I'd rather generate N separate plots in higher quality.

running within-subject model

Following this link(http://ski.clps.brown.edu/hddm_docs/tutorial_python.html#within-subject-effects), I’m trying to run within-subject analysis, and I have a few questions regarding model specification. Here is a list of three variables that I’m interested in.
Session - 2 levels of “behav”, “fmri”
Condition - 2 levels of “Black”, “Like”
Diff (difficulty) - 2 levels of “1”, “0”

My primary goal is to compare subject performance between “fmri” and “behav” sessions. For example, for those in easy & Black condition (diff =0, condition = Black), do those in (session = behav) differ from those in (session = fmri)?

Using pseudo-code, I need an intercept of
Black_easy_behav -> black[black] : easy[easy] : behav[behav]
And second term of
Black_easy_fmri -> black[black] : easy[easy] : behav[fmri] waiting to be compared.

Using this input, I type -
m_within = hddm.HDDMRegressor(data, "a ~ C(session, Treatment('fmri')):C(condition, Treatment('Black')):C(diff, Treatment(0))")
I get this -
[‘a_Intercept’, ..., “a_C(session, Treatment(‘fmri’))[T.behav]:C(condition, Treatment(‘Black’))[T.Like]:C(diff, Treatment(0))[T.1]”]
While I have the intercept term, the second term is not what I wanted. I was looking for something like this ->
“a_C(session, Treatment(‘fmri’))[T.behav]:C(condition, Treatment(‘Black’))[T.Black]:C(diff, Treatment(0))[T.0]”]

In summary, my questions are

  1. How do I get the specified results that I need? I’m a bit confused by how the co-variates are added. I can output the right combination (222, all8) by having
    > m_within = hddm.HDDMRegressor(data, "a ~ 0 + C(session, Treatment('fmri')):C(condition, Treatment('Black')):C(diff, Treatment(0))")
    Then I have this error. Also not sure how to solve.
    > AssertionError: Step-out procedure failed
  2. What would the intercept be if there are more than 1 term? In the tutorial, there intercept is only 1 variable. However, if mine has more variables for intercept, what does it become? Case 1: a ~ A:B, in this case I assume intercept is A:B. Case2: a ~ A:B + B:C, would intercept be A:B, or the combination of (A:B + B:C)
  3. What's the difference between C(diff, Treatment(1))[T.0] vs. C(diff, Treatment(0))[0]?
  4. Why sometimes there is [T.0], sometimes its just [0]? I’ve already made them “factors” rather than “integer/numbers” via R. Upon comparing my results and those from the Demo, I see a divergence from very early on here -

Where the Demo has
> from patsy import dmatrix dmatrix("C(stim, Treatment('WL'))", data.head(10)) and outputs all levels
> DesignMatrix with shape (10, 3) Intercept C(stim, Treatment('WL'))[T.LL] C(stim, Treatment('WL'))[T.WW]
My line of ...
> from patsy import dmatrix("C(condition, Treatment('Black'))", data.head(10)) only generates the following with out the other conditions. I hope to see something like "C(condition, Treatment('Black'))[T.Like]"
> DesignMatrix with shape (10, 1) Intercept Whats more, if I type
> dmatrix("C(condition, Treatment('Like'))", data.head(10)) I got result of this. and I wasn't sure what caused the level issue.
`> PatsyError: specified level 'Like' not found

Thank you so much in advance!

graph of priors

plot of priors on top of real data that are used in HDDMInform, and place the graphic into docs/sources.

how to load data and run this command

i am a new user

import hddm
data = hddm.load_csv('0005.HK.csv')

model = hddm.HDDM(data)

i do not know what is the function of depends_on, is it to define the header of data ?

# Create a HDDM model multi object
model = hddm.HDDM(data, depends_on={'v': ['Date', 'Open', 'High', 'Low', 'Close', 'Adj Close', 'Volume']})

there is error when run this command

  File "pandas\_libs\hashtable_class_helper.pxi", line 1215, in pandas._libs.hashtable.PyObjectHashTable.get_item (pandas\_libs\hashtable.c:20359)
KeyError: 'rt'

quantiles_summary() and qp_plot() are broken

I first ran a model called 'model' then called

quantiles_summary(model, method='deviance', n_samples=50,
quantiles = (10, 30, 50, 70, 90), sorted_idx = None,
cdf_range = (-6, 6))

Which led kicked back:

AttributeError Traceback (most recent call last)
in ()
1 quantiles_summary(model, method='deviance', n_samples=50,
2 quantiles = (10, 30, 50, 70, 90), sorted_idx = None,
----> 3 cdf_range = (-5, 5))

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/hddm/utils.pyc in quantiles_summary(hm, method, n_samples, quantiles, sorted_idx, cdf_range)
636 #Init
637 n_q = len(quantiles)
--> 638 wfpt_dict = hm.params_dict['wfpt'].subj_nodes
639 conds = wfpt_dict.keys()
640 n_conds = len(conds)

AttributeError: 'HDDM' object has no attribute 'params_dict'

regressor with interaction

I've got data that looks like this (with response accuracy encoded):

        Idx        rt  response  axes  cogr      cond      subj    angle
          0  2.384600         1   2.0   0.0        I2         0      20
          1  1.960730         1   2.0   0.0        I2         0      20
          3  1.857445         1   1.0   0.0        I1         0      20
          4 -2.672745         0   2.0   1.0        C2         0      20
          5  1.869880         1   2.0   0.0        I2         0      20

I want to create regression model for v and t, with baseline condition I2. I also want to include interaction dep. on angle. After studying docs of hddm and patsy I think that something like this should work:

vmod = {'model': "v ~ C(cond, Treatment('I2')):C(angle)", 'link_func': lambda x: x}
tmod = {'model': "t ~ C(cond, Treatment('I2')):C(angle)", 'link_func': lambda x: x}

m = hddm.HDDMRegressor(dataf, [vmod, tmod], include = 't', p_outlier=0.05, bias = False)

However, I'm getting:

NotImplementedError: Missing columns in design matrix. You need data for all conditions for all subjects.

Do you know some workaround?

Issues with indexing conditions of experiment

New to Python and HDDM. I have run into the following problem:

One of the conditions of the experiment is how the coherence of dots differ. The coherence ratings are 0, 0.025, 0.05, 0.1, 0.15, 0.25, 0.35, 0.45 and 0.7. After building a model looking at drift rate 'v' and boundary threshold 'a' that depends on the different coherence conditions I've been getting some errors when trying to plot the posteriors. The error message is for posterior plots and not the models but I have put the model code so you can see the model.

1 Drift rate

m_stim = hddm.HDDM(data, depends_on={'v': 'stim'}, p_outlier=.05)
m_stim.find_starting_values()
m_stim.sample(10000, burn=1000, thin = 5)

v_7, v_45, v_35, v_25, v_15, v_1, v_05, v_025, v_0 = m_stim.nodes_db.node[['v(0.7)', 'v(0.45)', 'v(0.35)', 'v(0.25)', 'v(0.15)', 'v(0.1)', 'v(0.05)', 'v(0.025)', 'v(0)']]
hddm.analyze.plot_posterior_nodes([v_7, v_45, v_35, v_25, v_15, v_1, v_05, v_025, v_0])
plt.xlabel('drift-rate')
plt.ylabel('Posterior probability')
plt.title('Posterior of drift-rate group means')
plt.savefig('hddm_demo_fig_06.pdf')  

KeyError: u"None of [Index([u'v(0.7)', u'v(0.45)', u'v(0.35)', u'v(0.25)', u'v(0.15)', u'v(0.1)',\n       u'v(0.05)', u'v(0.025)', u'v(0)'],\n      dtype='object')] are in the [index]" 

2 Boundary Threshold

a_stim = hddm.HDDM(data, depends_on={'a': 'stim'}, p_outlier=.05)
a_stim.find_starting_values()
a_stim.sample(10000, burn=1000, thin = 5)


a_7, a_45, a_35, a_25, a_15, a_1, a_05, a_025, a_0 = a_stim.nodes_db.node[['a(0.7)', 'a(0.45)', 'a(0.35)', 'a(0.25)', 'a(0.15)', 'a(0.1)', 'a(0.05)', 'a(0.025)', 'a(0)']]
hddm.analyze.plot_posterior_nodes([a_7, a_45, a_35, a_25, a_15, a_1, a_05, a_025, a_0])
plt.xlabel('Threshold Boundary')
plt.ylabel('Posterior probability')
plt.title('Posterior of Threshold Boundary group means in coherence')
plt.savefig('hddm_demo_fig_ThresholdBoundary.pdf') 


AttributeError: 'float' object has no attribute 'trace'

Although they are different Error messages I am guessing they have the same reason behind them and that its related to the nodes.

All help appreciated and thank you in advance!

Installation on python 3.6

In trying to install on python 3.6 I got the following error:
The error suggests kabuki depends on an older version of openssl that is no longer supported on python 3.6 (https://docs.python.org/3/whatsnew/3.6.html). Do you have any recommendations for this?

UnsatisfiableError: The following specifications were found to be in conflict:
  - hddm -> kabuki -> python 3.3* -> openssl 1.0.1*
  - hddm -> kabuki -> python 3.3* -> xz 5.0.5
  - python 3.6*

*EXTREMELY* slow execution of code

Hi,

I've been using the HDDM package in Jupyter Notebook for several weeks without any problems, then very suddenly (possibly correlated with a forced overnight Windows update?) the hddm.HDDM function began running SO slowly--I'm talking 2-3 seconds PER SAMPLE.

This may not be an issue with the HDDM package, but rather a Python issue--I've had the same issue in Jupyter Lab and Spyder so I don't know. But the other elements of the code (like creating a data frame) work fine and can be executed quite quickly.

Is anyone else having this issue?

Thanks,
Sarah

simple example does not work

IPython 0.10.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: %run simple_model.py

KeyError Traceback (most recent call last)

/Users/isofer/python/hddm/hddm/examples/simple_model.py in ()
5
6 # Create a HDDM model multi object

----> 7 model = hddm.HDDM(data, depends_on={'v':'difficulty'})
8
9 # Create model and start MCMC sampling

/Users/isofer/python/hddm/hddm/model.py in init(self, data, bias, include, wiener_params, *_kwargs)
129 self.params = self.get_params()
130
--> 131 super(hddm.model.HDDM, self).init(data, include=include, *_kwargs)
132
133 def get_params(self):

/Users/isofer/python/kabuki/kabuki/hierarchical.py in init(self, data, is_group_model, depends_on, trace_subjs, plot_subjs, plot_tau, include)
182 for elem in depend_on:
183 if elem not in self.data.dtype.names:
--> 184 raise KeyError, "Column named %s not found in data." % elem
185 self.depends_on = depends_on
186

KeyError: 'Column named difficulty not found in data.'
WARNING: Failure executing file: <simple_model.py>

plot_posterior_predictive

Having trouble using plot_posterior_predictive function (running the hddm tutorial demo script on google colab)
Returning error 'Polygon' object has no property 'normed'.

Package versions:
pandas - 1.0.5
pymc - 2.3.8
matplotlib - 3.2.2
kabuki - 0.6.3
hddm - 0.8.0

Having problems running demo code on v 0.5.5 on a Mac

Here's a Jupyter notebook showing the problem:

https://gist.github.com/rdhyee/50926afc4d6e591e51dd

The conda environment I'm running is:

# packages in environment at /Users/raymondyee/anaconda/envs/hddm_test:
#
appnope                   0.1.0                    py27_0  
backports.ssl-match-hostname 3.4.0.2                   <pip>
certifi                   2015.9.6.2               py27_0  
decorator                 4.0.4                    py27_0  
freetype                  2.5.5                         0  
gdal                      1.11.2                    <pip>
hddm                      0.5.5                np19py27_0  
ipykernel                 4.1.1                    py27_0  
ipython                   4.0.0                    py27_1  
ipython-genutils          0.1.0                     <pip>
ipython_genutils          0.1.0                    py27_0  
ipywidgets                4.1.0                    py27_0  
jinja2                    2.8                      py27_0  
jsonschema                2.4.0                    py27_0  
jupyter                   1.0.0                    py27_0  
jupyter-client            4.1.1                     <pip>
jupyter-console           4.0.3                     <pip>
jupyter-core              4.0.6                     <pip>
jupyter_client            4.1.1                    py27_0  
jupyter_console           4.0.3                    py27_0  
jupyter_core              4.0.6                    py27_0  
kabuki                    0.5.3                np19py27_0  
libpng                    1.6.17                        0  
markupsafe                0.23                     py27_0  
matplotlib                1.4.3                np19py27_3  
mistune                   0.7.1                    py27_0  
mock                      1.0.1                     <pip>
nbconvert                 4.0.0                    py27_0  
nbformat                  4.0.1                    py27_0  
notebook                  4.0.6                    py27_0  
numpy                     1.9.3                    py27_0  
openssl                   1.0.2d                        0  
pandas                    0.16.2               np19py27_0  
path.py                   8.1.2                    py27_0  
patsy                     0.4.0                np19py27_0  
pexpect                   3.3                      py27_0  
pickleshare               0.5                      py27_0  
pip                       7.1.2                    py27_0  
ptyprocess                0.5                      py27_0  
pygments                  2.0.2                    py27_0  
pygobject                 3.16.2                    <pip>
pymc                      2.3.5                np19py27_0  
pyparsing                 2.0.3                    py27_0  
pyqt                      4.11.4                   py27_0  
python                    2.7.10                        2  
python-dateutil           2.4.2                    py27_0  
python.app                1.2                      py27_4  
pytz                      2015.6                   py27_0  
pyzmq                     14.7.0                   py27_1  
qt                        4.8.7                         1  
qtconsole                 4.1.0                    py27_0  
readline                  6.2                           2  
scipy                     0.16.0               np19py27_1  
setuptools                18.4                     py27_0  
simplegeneric             0.8.1                    py27_0  
sip                       4.16.9                   py27_0  
six                       1.10.0                   py27_0  
sqlite                    3.8.4.1                       1  
ssl_match_hostname        3.4.0.2                  py27_0  
terminado                 0.5                      py27_1  
tk                        8.5.18                        0  
tornado                   4.2.1                    py27_0  
traitlets                 4.0.0                    py27_0  
wheel                     0.26.0                   py27_1  
zeromq                    4.1.3                         0  
zlib                      1.2.8                         0  

I'm running Python 2.7.10 on OS X 10.9.5.

403 Error on HDDM Website with "How to" and tutorials

Hello, I am new to using HDDM and am very excited to incorporate this model into my research. However, within the past week I have been attempting to access http://ski.clps.brown.edu/hddm_docs and received a 403 error. I had been able to view the website 1 week prior but no longer have access. Will this issue be resolved? If not, are there alternative websites to access HDDM tutorials?

Thank you!

Ryan

problem with generating posterior preditions

I had trouble running hddm.utils.post_pred_gen on my data.

I got:

    942 
    943         if len(data_nodes) != 1:
--> 944             raise NotImplementedError("Supply a grouping so that at most 1 observed node codes for each group.")
    945 
    946         return data_nodes[0]

NotImplementedError: Supply a grouping so that at most 1 observed node codes for each group.

The intermediate solution is to reset indices of the input data if you filter out some trials.

data.reset_index(inplace = True, drop = True)

Fix gsquare optimization

FloatingPointError: invalid value encountered in log

/home/wiecki/working/projects/hddm/hddm/likelihoods.py(191)gsquare()
190 return -np.inf
--> 191 return 2 * sum(self._freq_obs * np.log(theo_proportion))
192

ipdb> theo_proportion
array([ 0.00005721, 0.00774484, 0.4890562 , 0.00001 , 0.00001 ,
0.00001 , 0.00001 , 0.00001 , 0.26693313, 0.24014853,
0.00001 , -0.0039399 ])

Failing test test_posterior_plots_breakdown

>>nosetests tests/test_models.py:test_posterior_plots_breakdown
/home/whyking/envs/hddm/local/lib/python2.7/site-packages/pandas/core/format.py:1286: FutureWarning: set_printoptions is deprecated, use set_option instead
  FutureWarning)
E
======================================================================
ERROR: hddm.tests.test_models.test_posterior_plots_breakdown
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/whyking/envs/hddm/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/whyking/working/projects/hddm/hddm/tests/test_models.py", line 330, in test_posterior_plots_breakdown
    m.plot_posterior_quantiles()
  File "/home/whyking/working/projects/hddm/hddm/models/base.py", line 512, in plot_posterior_quantiles
    hddm.utils.plot_posterior_quantiles(self, *args, **kwargs)
  File "/home/whyking/working/projects/hddm/hddm/utils.py", line 730, in plot_posterior_quantiles
    **kwargs)
  File "/home/whyking/working/projects/kabuki/kabuki/analyze.py", line 498, in plot_posterior_predictive
    plot_func(bottom_node['node'], ax, **kwargs)
  File "/home/whyking/working/projects/hddm/hddm/utils.py", line 651, in _plot_posterior_quantiles_node
    sample_values = node.random()
  File "/home/whyking/envs/hddm/local/lib/python2.7/site-packages/pymc/PyMCObjects.py", line 914, in random
    r = self._random(**self.parents.value)
  File "/home/whyking/working/projects/hddm/hddm/likelihoods.py", line 62, in random
    **param_dict)
  File "/home/whyking/working/projects/hddm/hddm/generate.py", line 224, in gen_rts
    size, range_[0], range_[1], dt)
  File "wfpt.pyx", line 102, in wfpt.gen_rts_from_cdf (src/wfpt.c:5566)
    double st, int samples=1000, double cdf_lb=-6, double cdf_ub=6, double dt=1e-2):
TypeError: an integer is required
-------------------- >> begin captured stdout << ---------------------
[****************100%******************]  100 of 100 complete
--------------------- >> end captured stdout << ----------------------

Introduced by commit: 516441c by @isofer. Please fix.

HDDMRegression.approx_map() throws key error

When I tested it with a within-subject model (hddmRegressor) I got the optimisation results but then this error:

Traceback (most recent call last):
  File "<pyshell#55>", line 1, in <module>
    m.find_starting_values()
  File "/Library/Python/2.7/site-packages/kabuki/hierarchical.py", line 775, in find_starting_values
    self.approximate_map()
  File "/Library/Python/2.7/site-packages/kabuki/hierarchical.py", line 835, in approximate_map
    for name, value in self.values.iteritems():
  File "/Library/Python/2.7/site-packages/kabuki/hierarchical.py", line 759, in values
    return {name: node['node'].value[()] for (name, node) in self.iter_non_observeds()}
  File "/Library/Python/2.7/site-packages/kabuki/hierarchical.py", line 759, in <dictcomp>
    return {name: node['node'].value[()] for (name, node) in self.iter_non_observeds()}
  File "/Library/Python/2.7/site-packages/pandas/core/frame.py", line 1928, in __getitem__
    return self._get_item_cache(key)
  File "/Library/Python/2.7/site-packages/pandas/core/generic.py", line 570, in _get_item_cache
    values = self._data.get(item)
  File "/Library/Python/2.7/site-packages/pandas/core/internals.py", line 1383, in get
    _, block = self._find_block(item)
  File "/Library/Python/2.7/site-packages/pandas/core/internals.py", line 1525, in _find_block
    self._check_have(item)
  File "/Library/Python/2.7/site-packages/pandas/core/internals.py", line 1532, in _check_have
    raise KeyError('no item named %s' % com.pprint_thing(item))
KeyError: u'no item named ()'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.