Пример #1
0
 def _create_wfpt_knode(self, knodes):
     wfpt_parents = self._create_wfpt_parents_dict(knodes)
     return Knode(self.wfpt_reg_class,
                  'wfpt',
                  observed=True,
                  col_name='rt',
                  reg_outcomes=self.reg_outcomes,
                  **wfpt_parents)
Пример #2
0
 def _create_wfpt_knode(self, knodes):
     wfpt_parents = self._create_wfpt_parents_dict(knodes)
     return Knode(self.wfpt_nn_reg_class,
                  "wfpt",
                  observed=True,
                  col_name=["response", "rt"],
                  reg_outcomes=self.reg_outcomes,
                  **wfpt_parents)
Пример #3
0
    def _create_wfpt_knode(self, knodes):
        wfpt_parents = self._create_wfpt_parents_dict(knodes)

        return Knode(self.wfpt_nn_reg_class,
                     "wfpt",
                     observed=True,
                     col_name=["response", "rt"] +
                     self.model_config["likelihood_relevant_covariates"],
                     reg_outcomes=self.reg_outcomes,
                     **wfpt_parents)
Пример #4
0
 def _create_wfpt_knode(self, knodes):
     wfpt_parents = super(HDDMrlRegressor,
                          self)._create_wfpt_parents_dict(knodes)
     wfpt_parents["alpha"] = knodes["alpha_bottom"]
     return Knode(
         self.wfpt_reg_class,
         "wfpt",
         observed=True,
         col_name=["split_by", "feedback", "response", "rt", "q_init"],
         reg_outcomes=self.reg_outcomes,
         **wfpt_parents)
Пример #5
0
 def _create_wfpt_knode(self, knodes):
     wfpt_parents = super(HDDMrlRegressor,
                          self)._create_wfpt_parents_dict(knodes)
     wfpt_parents['alpha'] = knodes['alpha_bottom']
     return Knode(
         self.wfpt_reg_class,
         'wfpt',
         observed=True,
         col_name=['split_by', 'feedback', 'response', 'rt', 'q_init'],
         reg_outcomes=self.reg_outcomes,
         **wfpt_parents)
Пример #6
0
 def _create_wfpt_knode(self, knodes):
     wfpt_parents = super(HDDMnnRegressor,
                          self)._create_wfpt_parents_dict(knodes)
     wfpt_parents['beta'] = knodes['beta_bottom']
     wfpt_parents['alpha'] = knodes['alpha_bottom'] if self.k else 3.00
     return Knode(self.wfpt_reg_class,
                  'wfpt',
                  observed=True,
                  col_name=['nn_response', 'rt'],
                  reg_outcomes=self.reg_outcomes,
                  **wfpt_parents)
Пример #7
0
    def _create_family_trunc_normal(self, name, value=0, lower=None,
                                   upper=None, std_lower=1e-10,
                                   std_upper=100, std_value=.1):
        """Similar to _create_family_normal() but creates a Uniform
        group distribution and a truncated subject distribution.

        See _create_family_normal() help for more information.

        """
        knodes = OrderedDict()

        if self.is_group_model and name not in self.group_only_nodes:
            g = Knode(pm.Uniform, '%s' % name, lower=lower,
                      upper=upper, value=value, depends=self.depends[name])

            depends_std = self.depends[name] if self.std_depends else ()
            std = Knode(pm.Uniform, '%s_std' % name, lower=std_lower,
                        upper=std_upper, value=std_value, depends=depends_std)
            tau = Knode(pm.Deterministic, '%s_tau' % name,
                        doc='%s_tau' % name, eval=lambda x: x**-2, x=std,
                        plot=False, trace=False, hidden=True)
            subj = Knode(pm.TruncatedNormal, '%s_subj' % name, mu=g,
                         tau=tau, a=lower, b=upper, value=value,
                         depends=('subj_idx',), subj=True, plot=self.plot_subjs)

            knodes['%s'%name] = g
            knodes['%s_std'%name] = std
            knodes['%s_tau'%name] = tau
            knodes['%s_bottom'%name] = subj

        else:
            subj = Knode(pm.Uniform, name, lower=lower,
                         upper=upper, value=value,
                         depends=self.depends[name])
            knodes['%s_bottom'%name] = subj

        return knodes
Пример #8
0
    def create_family_tau(self,
                          name,
                          value=50,
                          mean_gr=40,
                          var_gr=50,
                          lower=1,
                          upper=500,
                          var_lower=1e-10,
                          var_upper=200,
                          var_value=50):
        knodes = OrderedDict()

        if self.is_group_model and name not in self.group_only_nodes:
            tau_gr = var_gr**-2
            g = Knode(pm.TruncatedNormal,
                      '%s' % name,
                      mu=mean_gr,
                      tau=tau_gr,
                      a=lower,
                      b=upper,
                      value=value,
                      depends=self.depends[name])
            var = Knode(pm.Uniform,
                        '%s_var' % name,
                        lower=var_lower,
                        upper=var_upper,
                        value=var_value)
            tau = Knode(pm.Deterministic,
                        '%s_tau' % name,
                        doc='%s_tau' % name,
                        eval=lambda x: x**-2,
                        x=var,
                        plot=False,
                        trace=False,
                        hidden=True)
            subj = Knode(pm.TruncatedNormal,
                         '%s_subj' % name,
                         mu=g,
                         tau=tau,
                         a=lower,
                         b=upper,
                         value=value,
                         depends=('subj_idx', ),
                         subj=True,
                         plot=self.plot_subjs)

            knodes['%s' % name] = g
            knodes['%s_var' % name] = var
            knodes['%s_tau' % name] = tau
            knodes['%s_bottom' % name] = subj

        else:
            subj = Knode(pm.Uniform,
                         name,
                         lower=lower,
                         upper=upper,
                         value=value,
                         depends=self.depends[name])

            knodes['%s_bottom' % name] = subj

        return knodes
Пример #9
0
    def create_knodes(self):
        knodes = OrderedDict()
        knodes.update(
            self.create_family_trunc_normal('mu_go',
                                            lower=mu_go_lower,
                                            upper=mu_go_upper,
                                            value=mu_go_start,
                                            var_lower=mu_go_sd_lower,
                                            var_upper=mu_go_sd_upper,
                                            var_value=mu_go_sd_start))
        knodes.update(
            self.create_family_trunc_normal('sigma_go',
                                            lower=sigma_go_lower,
                                            upper=sigma_go_upper,
                                            value=sigma_go_start,
                                            var_lower=sigma_go_sd_lower,
                                            var_upper=sigma_go_sd_upper,
                                            var_value=sigma_go_sd_start))
        knodes.update(
            self.create_family_trunc_normal('tau_go',
                                            lower=tau_go_lower,
                                            upper=tau_go_upper,
                                            value=tau_go_start,
                                            var_lower=tau_go_sd_lower,
                                            var_upper=tau_go_sd_upper,
                                            var_value=tau_go_sd_start))
        knodes.update(
            self.create_family_trunc_normal('mu_stop',
                                            lower=mu_stop_lower,
                                            upper=mu_stop_upper,
                                            value=mu_stop_start,
                                            var_lower=mu_stop_sd_lower,
                                            var_upper=mu_stop_sd_upper,
                                            var_value=mu_stop_sd_start))
        knodes.update(
            self.create_family_trunc_normal('sigma_stop',
                                            lower=sigma_stop_lower,
                                            upper=sigma_stop_upper,
                                            value=sigma_stop_start,
                                            var_lower=sigma_stop_sd_lower,
                                            var_upper=sigma_stop_sd_upper,
                                            var_value=sigma_stop_sd_start))
        knodes.update(
            self.create_family_trunc_normal('tau_stop',
                                            lower=tau_stop_lower,
                                            upper=tau_stop_upper,
                                            value=tau_stop_start,
                                            var_lower=tau_stop_sd_lower,
                                            var_upper=tau_stop_sd_upper,
                                            var_value=tau_stop_sd_start))

        if abs(shift_stop_lower - shift_stop_upper) < 0.0001:
            shift_knodes = OrderedDict()
            shift_knodes['shift_stop'] = Knode(
                pm.Deterministic,
                'shift_stop',
                eval=lambda: np.array([shift_stop_lower]))
            shift_knodes['shift_stop_var'] = Knode(pm.Deterministic,
                                                   'shift_stop_var',
                                                   eval=lambda: np.array([0]))
            shift_knodes['shift_stop_bottom'] = Knode(
                pm.Deterministic,
                'shift_stop_bottom',
                eval=lambda: np.array([0]))
            knodes.update(shift_knodes)
        else:
            knodes.update(
                self.create_family_trunc_normal('shift_stop',
                                                lower=shift_stop_lower,
                                                upper=shift_stop_upper,
                                                value=shift_stop_start,
                                                var_lower=shift_stop_sd_lower,
                                                var_upper=shift_stop_sd_upper,
                                                var_value=shift_stop_sd_start))

        if abs(shift_go_lower - shift_go_upper) < 0.0001:
            shift_knodes = OrderedDict()
            shift_knodes['shift_go'] = Knode(
                pm.Deterministic,
                'shift_go',
                eval=lambda: np.array([shift_go_lower]))
            shift_knodes['shift_go_var'] = Knode(pm.Deterministic,
                                                 'shift_go_var',
                                                 eval=lambda: np.array([0]))
            shift_knodes['shift_go_bottom'] = Knode(pm.Deterministic,
                                                    'shift_go_bottom',
                                                    eval=lambda: np.array([0]))
            knodes.update(shift_knodes)
        else:
            knodes.update(
                self.create_family_trunc_normal('shift_go',
                                                lower=shift_go_lower,
                                                upper=shift_go_upper,
                                                value=shift_go_start,
                                                var_lower=shift_go_sd_lower,
                                                var_upper=shift_go_sd_upper,
                                                var_value=shift_go_sd_start))

        knodes.update(
            self.create_family_trunc_normal_probit('pf_stop',
                                                   lower_ind=pf_stop_lower,
                                                   upper_ind=pf_stop_upper,
                                                   mean_gr=pf_stop_mean,
                                                   var_gr=pf_stop_sd,
                                                   lower=pf_stop_lower,
                                                   upper=pf_stop_upper,
                                                   value=pf_stop_start,
                                                   var_lower=pf_stop_sd_lower,
                                                   var_upper=pf_stop_sd_upper,
                                                   var_value=pf_stop_sd_start))

        likelihoods = self.create_ss_knode(knodes)

        return knodes.values() + likelihoods