Пример #1
0
    def _build_model(self, data):
        data = _data_df2dict(data)
        with pm.Model() as model:
            # Priors
            # NOTE: we need another variable if we deal with losses, which goes
            # to the value function
            β = pm.Bound(pm.Normal, lower=0)('beta', mu=1, sd=1000)
            γ = pm.Bound(pm.Normal, lower=0)('gamma', mu=0, sd=1000)
            τ = pm.Bound(pm.Normal, lower=0)('tau', mu=0, sd=1000)

            # TODO: pay attention to the choice function & it's params
            α = pm.Exponential('alpha', lam=1)
            ϵ = 0.01

            value_diff = (self._value_function(γ, data['B']) -
                          self._value_function(γ, data['A']))
            time_diff = (self._time_weighing_function(τ, data['DB']) -
                         self._time_weighing_function(τ, data['DA']))
            diff = value_diff - β * time_diff

            # Choice function: psychometric
            P_chooseB = pm.Deterministic('P_chooseB',
                                         choice_func_psychometric2(α, ϵ, diff))
            # Likelihood of observations
            r_likelihood = pm.Bernoulli('r_likelihood',
                                        p=P_chooseB,
                                        observed=data['R'])

        return model
Пример #2
0
    def _build_model(self, data):
        data = _data_df2dict(data)
        with pm.Model() as model:
            # Priors
            k = pm.Normal('k',
                          mu=0.01,
                          sd=1.,
                          shape=2,
                          transform=Ordered(),
                          testval=[0.01, 0.02])
            p = pm.Beta('p', alpha=1 + 4, beta=1 + 4)
            α = pm.Exponential('alpha', lam=1)
            ϵ = 0.01
            # Value functions
            VA = pm.Deterministic('VA', data['A'] * self._df(k, p, data['DA']))
            VB = pm.Deterministic('VB', data['B'] * self._df(k, p, data['DB']))
            # Choice function: psychometric
            P_chooseB = pm.Deterministic(
                'P_chooseB', choice_func_psychometric(α, ϵ, VA, VB))
            # Likelihood of observations
            r_likelihood = pm.Bernoulli('r_likelihood',
                                        p=P_chooseB,
                                        observed=data['R'])

        return model
Пример #3
0
    def _build_model(self, data):
        data = _data_df2dict(data)
        with pm.Model() as model:
            # having p separate from P_chooseB is intentional, to ensure trace
            # of P_chooseB is the same shape as the other models
            p = pm.Beta('p', alpha=1 + 1, beta=1 + 1)  # prior
            P_chooseB = pm.Deterministic('P_chooseB',
                                         p * np.ones(data['R'].shape))
            # Likelihood of observations
            r_likelihood = pm.Bernoulli('r_likelihood',
                                        p=P_chooseB,
                                        observed=data['R'])

        return model
Пример #4
0
    def _build_model(self, data):
        data = _data_df2dict(data)
        with pm.Model() as model:
            # Priors
            k = pm.Bound(pm.Normal, lower=-0.005)('k', mu=0.001, sd=0.5)
            α = pm.Exponential('alpha', lam=1)
            ϵ = 0.01
            # Value functions
            VA = pm.Deterministic('VA', data['A'] * self._df(k, data['DA']))
            VB = pm.Deterministic('VB', data['B'] * self._df(k, data['DB']))
            # Choice function: psychometric
            P_chooseB = pm.Deterministic(
                'P_chooseB', choice_func_psychometric(α, ϵ, VA, VB))
            # Likelihood of observations
            r_likelihood = pm.Bernoulli('r_likelihood',
                                        p=P_chooseB,
                                        observed=data['R'])

        return model
Пример #5
0
    def _build_model(self, data):
        data = _data_df2dict(data)
        with pm.Model() as model:
            # Priors
            logk = pm.Normal('logk', mu=-4, sd=5)
            α = pm.Exponential('alpha', lam=1)
            # ϵ = pm.Beta('epsilon', alpha=1.1, beta=10.9)
            ϵ = 0.01
            # Value functions
            VA = pm.Deterministic('VA', data['A'] * self._df(logk, data['DA']))
            VB = pm.Deterministic('VB', data['B'] * self._df(logk, data['DB']))
            # Choice function: psychometric
            P_chooseB = pm.Deterministic(
                'P_chooseB', choice_func_psychometric(α, ϵ, VA, VB))
            # Likelihood of observations
            r_likelihood = pm.Bernoulli('r_likelihood',
                                        p=P_chooseB,
                                        observed=data['R'])

        return model
Пример #6
0
    def _build_model(self, data):
        data = _data_df2dict(data)
        with pm.Model() as model:
            # Priors
            β = pm.Normal('beta', mu=0, sd=1, shape=5)
            α = pm.Exponential('alpha', lam=1)
            ϵ = 0.01

            A = data['B'] - data['A']
            B = (data['B'] - data['A']) / ((data['B'] + data['A']) / 2)
            C = data['DB'] - data['DA']
            D = (data['DB'] - data['DA']) / ((data['DB'] + data['DA']) / 2)
            diff = β[0] + β[1] * A + β[2] * B + β[3] * C + β[4] * D

            # Choice function: psychometric
            P_chooseB = pm.Deterministic('P_chooseB',
                                         choice_func_psychometric2(α, ϵ, diff))
            # Likelihood of observations
            r_likelihood = pm.Bernoulli('r_likelihood',
                                        p=P_chooseB,
                                        observed=data['R'])

        return model
Пример #7
0
    def _build_model(self, data):
        data = _data_df2dict(data)
        with pm.Model() as model:
            # Priors
            β = pm.Normal('beta', mu=0, sd=10, shape=4)
            α = pm.Exponential('alpha', lam=1)
            ϵ = 0.01

            D = data['B'] - data['A']
            R = (data['B'] - data['A']) / data['A']
            T = data['DB'] - data['DA']
            I = ((data['B'] / data['A'])**(1. /
                                           (data['DB'] - data['DA']))) - 1.
            diff = β[0] + β[0] * D + β[1] * R + β[2] * I + β[3] * T

            # Choice function: psychometric
            P_chooseB = pm.Deterministic('P_chooseB',
                                         choice_func_psychometric2(α, ϵ, diff))
            # Likelihood of observations
            r_likelihood = pm.Bernoulli('r_likelihood',
                                        p=P_chooseB,
                                        observed=data['R'])

        return model