find_starting_values() error

158 views
Skip to first unread message

Adriana Schoenhaut

unread,
Jan 14, 2021, 2:49:19 PM1/14/21
to hddm-users
Hi all,
I keep getting the same error when trying to run my using find_starting_values() on accuracy-coded between-subjects HDDM. It's the "Deterministic z's value cannot be set." error.

I'm hoping to get it to work, because my model fit isn't great without it regardless of my sample and burn in, and the values I'm getting for drift rate when running a new model on simulated data generated using the parameters I got from my original model are a decent bit off. I've tried adding p_outlier=0.05, changing is_group_model=True and std_depends=True, and so far none of these things have helped me get better values on my posterior predictive check. Finding_starting_values() seems like the first thing I need to get working in order to get to the bottom of my mediocre model fits. Anyone have any suggestions? 

I've seen this same error brought up previously in this group, but from what I can tell a real explanation/solution hasn't been found. 

Here is my data: 
visual_only_acc.head(10)

  Vis_Dir Vis_Coh rt key_pressed SubjNum Condition Block_Type Stim_v response
12 1.0 2.0 0.990238 37.0 8 1 3.0 1.0 1.0
84 1.0 2.0 0.877036 37.0 8 1 3.0 1.0 1.0
105 1.0 2.0 0.879028 37.0 8 1 3.0 1.0 1.0
124 1.0 4.0 0.852450 37.0 8 1 3.0 1.0 1.0
129 0.0 2.0 0.936309 39.0 8 1 3.0 0.0 1.0
133 0.0 4.0 0.843640 39.0 8 1 3.0 0.0 1.0
148 0.0 5.0 0.797043 39.0 8 1 3.0 0.0 1.0
149 1.0 3.0 0.852950 37.0 8 1 3.0 1.0 1.0
159 0.0 1.0 1.277599 39.0 8 1 3.0 0.0 1.0
167 1.0 5.0 0.770246 37.0 8 1 3.0 1.0 1.0

Here is my code:
m_visonly_vcoh_acc = hddm.HDDM(visual_only_acc, depends_on={'v': 'Vis_Coh'},include=('a','v','z','sv'))
m_visonly_vcoh_acc.find_starting_values()
m_visonly_vcoh_acc.sample(n_samples,burn=n_burn,dbname='traces.db',db='pickle')

Here is the output:
-2705.339966241216
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-26-cab8d3a07476> in <module>()
      1 #model Congruent AV trials only with drift rate depending on aud coherence
      2 m_visonly_vcoh_acc_more = hddm.HDDM(visual_only_acc, depends_on={'v': 'Vis_Coh'},include=('a','v','z','sv'),group_only_nodes=['sv', 'st','a'])
----> 3 m_visonly_vcoh_acc_more.find_starting_values()
      4 m_visonly_vcoh_acc_more.sample(10000,burn=5000,thin=5,dbname='traces.db',db='pickle')
      5 stats = m_visonly_vcoh_acc_more.gen_stats()

/opt/conda/lib/python3.6/site-packages/kabuki/hierarchical.py in find_starting_values(self, *args, **kwargs)
    976             self.approximate_map(*args, **kwargs)
    977         else:
--> 978             self.map(*args, **kwargs)
    979 
    980     def _partial_optimize(self, optimize_nodes, evaluate_nodes, fall_to_simplex=True, minimizer='Powell', use_basin=False, debug=False, minimizer_kwargs=None, basin_kwargs=None):

/opt/conda/lib/python3.6/site-packages/kabuki/hierarchical.py in map(self, runs, warn_crit, method, **kwargs)
    503             self.mc = pm.MAP(self.nodes_db.node)
    504             if i != 0:
--> 505                 self.draw_from_prior()
    506 
    507             self.mc.fit(method, **kwargs)

/opt/conda/lib/python3.6/site-packages/kabuki/hierarchical.py in draw_from_prior(self, update)
    464         if not update:
    465             # restore original values
--> 466             self.set_values(values)
    467 
    468         return draw

/opt/conda/lib/python3.6/site-packages/kabuki/hierarchical.py in set_values(self, new_values)
    965         """
    966         for (name, value) in new_values.items():
--> 967             self.nodes_db.loc[name]['node'].set_value(value)
    968 
    969     def find_starting_values(self, *args, **kwargs):

/opt/conda/lib/python3.6/site-packages/pymc/PyMCObjects.py in set_value(self, value)
    477             'Deterministic ' +
    478             self.__name__ +
--> 479             '\'s value cannot be set.')
    480 
    481     value = property(

AttributeError: Deterministic z's value cannot be set.

Thank you in advance, I really appreciate any tips or suggestions relating to solving this error or improving the results of posterior predictive check statistics! 

Best,

Adriana Schoenhaut
Vanderbilt University
Graduate Student - Neuroscience Graduate Program
Wallace/Ramachandran Labs

Tim Sandhu

unread,
Aug 20, 2021, 11:16:40 AM8/20/21
to hddm-users
Hi Adriana,

I've had this error before - I switched my column name for subject ID to 'subj_idx' as in the tutorial and that worked. Not sure if this is the actual reason but it did the job!

Best,

Tim

Reply all
Reply to author
Forward
0 new messages