Model the Data Generation Process ********* .. article-info:: :avatar: UCLA_Suit.jpg :avatar-link: https://www.decisionneurosciencelab.com/elijahgalvan :author: Elijah Galvan :date: September 1, 2023 :read-time: 12 min read :class-container: sd-p-2 sd-outline-muted sd-rounded-1 Lesson ================ Goal During this Stage --------------- We want to mathematically model the data generation process - in other words, develop an equation that predicts what all people will decide in each trial. .. Warning:: Mathematically modeling the data generation process is the most difficult step in the computational modeling process: there is no objectively correct way to go about it. With that said, I believe that this is achievable in a timely manner when given the correct goals and a useful framework. How to Achieve this Goal ------------ 1. Create `Construct Value` Functions - for each motive you have identified, create a function which takes :bdg-danger:`Decisions`, :bdg-primary:`Independent Variables`, and :bdg-primary:`Constants` as inputs, and outputs a value which reflects the :bdg-secondary:`Construct Value` of such a motive based on :bdg-danger:`Decisions`. .. dropdown:: Conceptual Examples of :bdg-secondary:`Construct Value` Formulations Here the :bdg-danger:`Decision` (the chosen option) is represented as Decision, the option which most closely follows the norm is represented as Norm, and the option which most strongly violates the norm is represented as Maximum Norm Violation. .. Note:: All differences are set to the absolute value. The logic of this choice is that the direction of the norm violation is not important: violating a norm in either direction results in disutility. If norm violation in one direction could result in a positive utility, this should not be done. However, in most cases this is appropriate (albiet unnecessary from a design perspective since usually such deviations are not possible). :bdg-secondary:`Raw Norm Violation` = (|Norm - Decision|)/(Maximum Norm Violation) * If any violation of the norm results in disutility :bdg-secondary:`Unidirectional Norm Violation` = (|max((Norm - Decision), 0)|)/(Maximum Norm Violation) * If the Norm is violated in one direction but not another * Could also use min * The second argument (0 here) can be anything, though 0 is usually the most meaningful :bdg-secondary:`Normalized Norm Violation` = ((|Norm - Decision|)/(|Maximum Norm Violation - Norm|)) * If all choices result in a norm being violated to some extent, disutility is not experienced by choosing the closest value to the norm :bdg-secondary:`Squared Normalized Norm Violation` = ((Norm - Decision)/(Maximum Norm Violation - Norm))² * If smaller norm violations are less significant than a linear relationship would suggest :bdg-secondary:`Square Root Normalized Norm Violation` = sqrt((Norm - Decision)/(Maximum Norm Violation - Norm)) * If smaller norm violations are more significant than a linear relationship would suggest .. Note:: Adherance = 1 - Violation If you plot the output (let's call this our :bdg-secondary:`Construct Values` ) against :bdg-danger:`Decisions` for a few trials (with a few example combinations of :bdg-primary:`Independent Variables` ) and it makes sense to you, then great job! Otherwise, think about how you can fix it so that it will make sense. 2. Identify Relevant :bdg-success:`Free Parameters` for each :bdg-secondary:`Construct Value` - identify which :bdg-success:`Free Parameters` are relevant for each :bdg-secondary:`Construct Value` in determining :bdg-warning:`Utility` 3. Propose a :bdg-warning:`Utility` Equation - identify how each :bdg-secondary:`Construct Value` mathematically interacts with the relevant :bdg-success:`Free Parameters` to determine :bdg-warning:`Utility`. .. dropdown:: General :bdg-warning:`Utility` Equation Formulation .. Note:: In most cases, you should not apply a nonlinear transformation to your :bdg-success:`Free Parameters`. This is because the value of :bdg-success:`Free Parameters` becomes uninterpretable. :bdg-warning:`Utility` = ( :bdg-secondary:`Utility Source 1` × :bdg-success:`Relevant Free Parameters` ) + ( :bdg-secondary:`Utility Source 2` × :bdg-success:`Relevant Free Parameters` ) + ... + ( :bdg-secondary:`Utility Source N` × :bdg-success:`Relevant Free Parameters` ) .. dropdown:: Examples of :bdg-warning:`Utility` Equations .. Note:: SN is shorthand for Social Norm - when there are multiple social norms we use numbers to demarcate. Adh is shorthand for Adherance. Vio is shorthand for Violation. 1 Parameter .. dropdown:: :bdg-warning:`Utility` = :bdg-secondary:`Payout Adh` × :bdg-success:`Θ` - (1 - :bdg-success:`Θ` ) × :bdg-secondary:`SN Vio` :bdg-success:`Θ` = [0, 1] :bdg-secondary:`Payout Adh` = `Normalized Norm Adherance` = [0, 1] :bdg-secondary:`SN1 Vio` = `Squared Normalized Norm Violation` = [0, 0.25] 2 Parameter .. dropdown:: :bdg-warning:`Utility` = :bdg-secondary:`Payout Adh` × :bdg-success:`Θ` + (1 - :bdg-success:`Θ` ) × ( :bdg-success:`Φ` × :bdg-secondary:`SN1 Adh` + (1 - :bdg-success:`Φ` ) × :bdg-secondary:`SN2 Adh` ) :bdg-success:`Θ` = [0, 1] :bdg-success:`Φ` = [0, 1] :bdg-secondary:`Payout Adh` = `Squared Normalized Norm Adherance` = [0, 1] :bdg-secondary:`SN1 Adh` = `Squared Normalized Norm Adherance` = [0, 1] :bdg-secondary:`SN2 Adh` = `Squared Normalized Norm Adherance` = [0, 1] .. Note:: This model was used in multiplayer choice. Thus, SN1 Adh and SN2 Adh were computed as ``1 - (sum(Norm Violation for Each Player²)/sum(Maximum Norm Violation for Each Player²))``. .. dropdown:: :bdg-warning:`Utility` = :bdg-secondary:`Payout Adh` × :bdg-success:`Θ` - (1 - :bdg-success:`Θ` ) × ( :bdg-success:`Φ` × :bdg-secondary:`SN1 Vio` + (1 - :bdg-success:`Φ` ) × :bdg-secondary:`SN2 Vio` ) :bdg-success:`Θ` = [0, 0.5] :bdg-success:`Φ` = [0, 1] :bdg-secondary:`Payout Adh` = `Normalized Norm Adherance` = [0, 1] :bdg-secondary:`SN1 Vio` = `Squared Normalized Norm Violation` = [0, 0.25] :bdg-secondary:`SN2 Vio` = `Squared Normalized Norm Violation` = [0, 0.25] .. dropdown:: :bdg-warning:`Utility` = :bdg-secondary:`Payout Adh` × :bdg-success:`Θ` - (1 - :bdg-success:`Θ` ) × min( :bdg-secondary:`SN1 Vio` + :bdg-success:`Φ` , :bdg-secondary:`SN2 Vio` - :bdg-success:`Φ` ) :bdg-success:`Θ` = [0, 0.5] :bdg-success:`Φ` = [-0.1, 0.1] :bdg-secondary:`Payout Adh` = `Normalized Norm Adherance` = [0, 1] :bdg-secondary:`SN1 Vio` = `Squared Normalized Norm Violation` = [0, 0.25] :bdg-secondary:`SN2 Vio` = `Squared Normalized Norm Violation` = [0, 0.25] Tutorials ================ .. Note:: If you want to have practice finding the correct model, leave the first two dropdowns alone and skip to the third dropdown to compare your :bdg-warning:`Utility` equation to those used in the existing papers. Otherwise, check the answers in the dropdowns below. Please be aware that no examples are given in the documentation for alternative models. Tutorial 1 - van Baar, Chang, & Sanfey, 2019 ------------------- .. dropdown:: Create :bdg-secondary:`Construct Value` Functions .. dropdown:: Greed .. tab-set:: .. tab-item:: Plain English The extent to which one has behaved greedily can be expressed as the proportion of how much they decided to keep for themselves out of how much they *could* have kept for themselves (i.e the extent to which they maximized their payout). In the Trust Game, the maximum amount that the Trustee can keep for themselves is what they received, namely: :bdg-primary-line:`Investment` × :bdg-primary-line:`Multiplier`. And, therefore, what they :bdg-danger-line:`Keep` is ( :bdg-primary-line:`Investment` × :bdg-primary-line:`Multiplier` ) - :bdg-danger-line:`Returned` Thus, the extent to which one has maximized their payout is: :bdg-secondary-line:`Payout Maximization` = :bdg-danger-line:`Keep` / (:bdg-primary-line:`Investment` × :bdg-primary-line:`Multiplier` ) Since :bdg-danger-line:`Keep` can range from 0 to :bdg-primary-line:`Investment` × :bdg-primary-line:`Multiplier`, it ranges from 0 to 1, inclusive. .. tab-item:: R :: payout_maximization = function(investment, multiplier, returned){ return(((investment * multiplier) - returned)/(investment * multiplier)) } .. tab-item:: MatLab :: function value = payout_maximization(investment, multiplier, returned) value = ((investment * multiplier) - returned) / (investment * multiplier); end .. tab-item:: Python :: def payout_maximization(investment, multiplier, returned): return ((investment * multiplier) - returned) / (investment * multiplier) .. dropdown:: Inequity Aversion .. tab-set:: .. tab-item:: Plain English Equity is creating an equal division of money in the game. Thus, the extent to the principle of equity has been violated can be expressed as the difference between perfect equity (the norm) and the actual division. In the Trust Game, the Trustee's payout is what they :bdg-danger-line:`Keep` which is ( :bdg-primary-line:`Investment` × :bdg-primary-line:`Multiplier` ) - :bdg-danger-line:`Returned` while the Investor's payout is what they did not invest which is ( :bdg-primary-line:`Endowment` - :bdg-primary-line:`Investment` ). If the Trustee has half of the money in the game, :bdg-danger-line:`Keep` is half of all of the money in the game - the sum of the multiplied investment ( :bdg-primary-line:`Investment` × :bdg-primary-line:`Multiplier` ) and what the Investor did not invest ( :bdg-primary-line:`Endowment` - :bdg-primary-line:`Investment` ). .. Note:: There are cases where the Investor does not invest enough for the Trustee to achieve Equity: in the paper they elected for the raw norm violation rather than the normalized norm violation so we'll do the same (although I can confirm that this doesn't affect the results). They also chose a squared formulation based on previous literature. Thus, the extent to which inequity was created (i.e. one violated the principle of equity) is: :bdg-secondary-line:`Inequity` = (0.5 - ( :bdg-danger-line:`Keep` / ( :bdg-primary-line:`Endowment` - :bdg-primary-line:`Investment` + :bdg-primary-line:`Investment` × :bdg-primary-line:`Multiplier` )))² Since :bdg-danger-line:`Keep` can range from 0 to :bdg-primary-line:`Investment` × :bdg-primary-line:`Multiplier` (when :bdg-primary-line:`Endowment` - :bdg-primary-line:`Investment` = 0), the maximum difference can be 0.5 which when squared is 0.25. Thus, :bdg-secondary-line:`Inequity` can range from 0 to 0.25, inclusive. .. tab-item:: R :: inequity = function(investment, multiplier, returned, endowment){ return((((investment * multiplier - returned)/(investment * multiplier + endowment - investment)) - 0.5)**2) } .. tab-item:: MatLab :: function value = inequity(investment, multiplier, returned, endowment) value = (((investment * multiplier - returned)/(investment * multiplier + endowment - investment)) - 0.5)^2; end .. tab-item:: Python :: def inequity(investment, multiplier, returned, endowment): return((((investment * multiplier - returned)/(investment * multiplier + endowment - investment)) - 0.5)**2) .. dropdown:: Guilt Aversion .. tab-set:: .. tab-item:: Plain English Guilt is experienced by violating expectations: in this case, the norm is to give half of what one receives. Thus, the extent to which one has violated the social norm can be expressed as the difference between the expected return on investment and the actual return on investment. In the experiment, :bdg-primary-line:`Believed Multiplier` was a constant - it was always 4 and let's adopt the assumption (which was supported in the data) that Trustees believed that Investor's expected to received half of the multiplied investment. Thus, the expectation can be expressed as ( :bdg-primary-line:`Investment` × :bdg-primary-line:`Believed Multiplier` )/2. .. Note:: Theoretically, giving more than ( :bdg-primary-line:`Investment` × :bdg-primary-line:`Believed Multiplier` )/2 is represented as a disutility - theoretically caused by an experience of guilt. Of course this seems unreasonable but let's play this out further - (( :bdg-primary-line:`Investment` × :bdg-primary-line:`Believed Multiplier` )/2) - :bdg-danger-line:`Returned` can actually be equal to :bdg-primary-line:`Investment` × :bdg-primary-line:`Believed Multiplier`. This could be very problematic: :bdg-secondary-line:`Guilt` can only range from 0 to 0.25 but :bdg-secondary-line:`Guilt` can range from 0 to 1. Obviously, this is not a huge problem because the model entirely overlooks the possibility that guilt averse people would give more than half of :bdg-primary-line:`Investment` × :bdg-primary-line:`Believed Multiplier` or that inequity averse people would give more than half of :bdg-primary-line:`Investment` × :bdg-primary-line:`Multiplier` which seems reasonable. But still, let's think of what an alternative formulation would be. .. dropdown:: What's a reasonable alternative formulation? The answer would be to apply a unidirectional formulation: max(((( :bdg-primary-line:`Investment` × :bdg-primary-line:`Believed Multiplier` )/2) - :bdg-danger-line:`Returned` ), 0) .. dropdown:: What's wrong with this alternative formulation? The answer would be that it is nonspecific: any return value greater than or equal to ( :bdg-primary-line:`Investment` × :bdg-primary-line:`Believed Multiplier` )/2 results in the exact same disutility (i.e. 0). Specificity is a highly, highly important feature of these models: you need to ensure than models make distinct predictions as much as is possible. Remember that there is always often tradeoff between specificty, parsimony, and theoretical correctness. We can fix this by changing the denominator from :bdg-primary-line:`Investment` × :bdg-primary-line:`Believed Multiplier` to :bdg-primary-line:`Investment` × :bdg-primary-line:`Multiplier` - guilt can now only range from 0 to 0.25 Thus with this representation of the norm, then the extent to which it was violated is: :bdg-secondary-line:`Guilt` = (((( :bdg-primary-line:`Investment` × :bdg-primary-line:`Believed Multiplier` )/2) - :bdg-danger-line:`Returned` ) /( :bdg-primary-line:`Investment` × :bdg-primary-line:`Multiplier` ))² .. tab-item:: R :: guilt = function(investment, believed_multiplier, returned, multiplier){ return((((investment * believed_multiplier * 0.5) - returned)/(investment * believed_multiplier))**2) } .. tab-item:: MatLab :: function value = guilt(investment, believed_multiplier, returned, multiplier) value = (((investment * believed_multiplier)/2 - returned) / (investment * believed_multiplier))^2; end .. tab-item:: Python :: def guilt(investment, believed_multiplier, returned, multiplier): return ((((investment * believed_multiplier)/2 - returned) / (investment * believed_multiplier))**2) .. dropdown:: Identify Relevant :bdg-success:`Free Parameters` for each :bdg-secondary:`Construct Value` 1. :bdg-secondary-line:`Payout Maximization` - :bdg-success-line:`D1` 2. :bdg-secondary-line:`Equity Achieved` - :bdg-success-line:`D1` & :bdg-success-line:`D2` 3. :bdg-secondary-line:`Expectation Meeting` - :bdg-success-line:`D1` & :bdg-success-line:`D2` .. Note:: Why do we use (1-:bdg-success-line:`D1` ) and (1-:bdg-success-line:`D2` )? Each dimension we have created is mathematically arbitrary: the fact that greed is endorsed at high values of :bdg-success-line:`D1` is a consequence of our choice. It could just as reasonably be that greed is endorsed at low values of :bdg-success-line:`D1`. The dimension we created dichtomize one preference against another: thus, we can just as reasonably take the inverse. .. dropdown:: Propose a :bdg-warning:`Utility` Equation :bdg-warning-line:`Utility` = :bdg-secondary-line:`Payout_Maximization` × :bdg-success-line:`Θ` - (1 - :bdg-success-line:`Θ` ) × min( :bdg-secondary-line:`Guilt` + :bdg-success-line:`Φ` , :bdg-secondary-line:`Inequity` - :bdg-success-line:`Φ` ) Tutorial 2 - Galvan & Sanfey, 2024 ------------------- .. dropdown:: Create :bdg-secondary:`Construct Value` Functions .. Note:: As you may have noticed, our conceptions of redistribution preferences treats redistribution itself (i.e. the selected tax rate) as a *means* by which people achieve certain outcomes - maximizing payout, producing equality, or producing equity. Thus, we need to write a function called new_value which computes each person's outcome under a given tax rate, given their :bdg-primary-line:`Initial Allocation`. .. tab-set:: .. tab-item:: Plain English First, we take this player's :bdg-primary-line:`Initial Allocation` and we subtract it from the amount that they lose to taxation under a given :bdg-danger-line:`Tax Rate`. Then, we add this to what they receive as a redistributed amount under a given :bdg-danger-line:`Tax Rate` - this is their :bdg-danger-line:`Outcome`. What they receive as a redistributed amount under a given :bdg-danger-line:`Tax Rate` is the :bdg-danger-line:`Tax Rate` times the :bdg-primary-line:`Number of Tokens in Game`, divided by the :bdg-primary-line:`Number of Players in Game`. The :bdg-primary-line:`Number of Tokens in Game` is a constant (100) as is the :bdg-primary-line:`Number of Players in Game` (10). And, since we are only dealing in whole tokens, we need to round this number to the nearest integer. .. tab-item:: R :: new_value = function(initial_allocation, tax_rate_decimal, number_tokens_game = 100, number_players_game = 10){ return(round(initial_allocation - (tax_rate_decimal * initial_allocation) + ((number_tokens_game * tax_rate_decimal)/(number_players_game)))) } .. tab-item:: MatLab :: function new_value = calculate_new_value(initial_allocation, tax_rate_decimal, number_tokens_game, number_players_game) if nargin < 3 number_tokens_game = 100; end if nargin < 4 number_players_game = 10; end new_value = round(initial_allocation - (tax_rate_decimal * initial_allocation) + ((number_tokens_game * tax_rate_decimal) / number_players_game)); end .. tab-item:: Python :: def calculate_new_value(initial_allocation, tax_rate_decimal, number_tokens_game=100, number_players_game=10): return round(initial_allocation - (tax_rate_decimal * initial_allocation) + ((number_tokens_game * tax_rate_decimal) / number_players_game)) .. dropdown:: Payout-Maximization .. tab-set:: .. tab-item:: Plain English The extent to which one has engaged in :bdg-secondary-line:`Payout-Maximization` can be expressed as the proportion of how much they decided to keep for themselves out of how much they *could* have kept for themselves. We'll take, as an argument, the potential outcomes for oneself for all possible :bdg-danger-line:`Tax Rates`. .. tab-item:: R :: payout_maximization = function(chosen_outcome_self, possible_outcomes_self){ return(chosen_outcome_self/max(possible_outcomes_self)) } .. tab-item:: MatLab :: .. tab-item:: Python :: .. dropdown:: Equality-Seeking .. tab-set:: .. tab-item:: Plain English The extent to which people have engaged in :bdg-secondary-line:`Equality-seeking` is the extent to which they have redistributed with a tax rate of 100%. However, focusing on :bdg-danger-line:`Outcomes` for all players, it is characterized as the extent to which one has minimized inequality for all players. Thus, :bdg-primary-line:`Perfect Equality Outcomes` would be where all players had the same amount - i.e. the :bdg-primary-line:`Number of Tokens in Game` (100) divided by the :bdg-primary-line:`Number of Players in Game` (10). Consequently, produced inequality is formulated as the sum of squared errors between :bdg-danger-line:`Chosen Outcomes` and :bdg-primary-line:`Perfect Equality Outcomes` divded by the sum of squared errors between :bdg-primary-line:`Perfect Inequality Outcomes` and :bdg-danger-line:`Perfect Equity Outcomes`. Then, we conceive of produced equality as the inverse of produced inequality: if produced inequality is 1 (i.e. the highest possible value) then produced equality is 0 while if produced inequality is 0 (i.e. the lowest possible value) then produced equality is 1 (the highest possible value). .. tab-item:: R :: equality = function(chosen_outcomes_all, intial_allocations_all, perfect_equality = 100/10){ return((1 - sum((chosen_outcomes_all - perfect_equality)**2)/sum((intial_allocations_all - perfect_equality)**2))) } .. tab-item:: MatLab :: .. tab-item:: Python :: .. dropdown:: Equity-Seeking .. tab-set:: .. tab-item:: Plain English The extent to which people have engaged in :bdg-secondary-line:`Equity-seeking` is the extent to which they have not redistributed. However, focusing on :bdg-danger-line:`Outcomes` for all players, it is characterized as the extent to which one has minimized inequity for all players. Thus, :bdg-primary-line:`Perfect Equality Outcomes` is equivalent to :bdg-primary-line:`Perfect Inequity Outcomes` would be where all players had the same amount - i.e. the :bdg-primary-line:`Number of Tokens in Game` (100) divided by the :bdg-primary-line:`Number of Players in Game` (10). Consequently, produced inequality is formulated as the sum of squared errors between :bdg-danger-line:`Outcomes` and :bdg-primary-line:`Perfect Equity` (i.e. :bdg-primary-line:`Initial Allocations`) divded by the sum of squared errors between :bdg-primary-line:`Perfect Equity` and the :bdg-primary-line:`Perfect Inequity`. Then, we conceive of produced equity as the inverse of produced inequity: if produced inequity is 1 (i.e. the highest possible value) then produced equity is 0 while if produced inequity is 0 (i.e. the lowest possible value) then produced equity is 1 (the highest possible value). .. tab-item:: R :: equity = function(chosen_outcomes_all, intial_allocations_all, perfect_inequity = 100/10){ return((1 - sum((chosen_outcomes_all - intial_allocations_all)**2)/sum((perfect_equality - intial_allocations_all)**2))) } .. tab-item:: MatLab :: .. tab-item:: Python :: .. dropdown:: Identify Relevant :bdg-success:`Free Parameters` for each :bdg-secondary:`Construct Value` 1. :bdg-secondary-line:`Payout-Maximization` - :bdg-success-line:`D1` 2. :bdg-secondary-line:`Equity-Seeking` - :bdg-success-line:`D1` & :bdg-success-line:`D2` 3. :bdg-secondary-line:`Equality-Seeking` - :bdg-success-line:`D1` & :bdg-success-line:`D2` .. dropdown:: Propose a :bdg-warning:`Utility` Equation :bdg-warning-line:`Utility` = :bdg-secondary-line:`Payout_Maximization` × :bdg-success-line:`Θ` + (1 - :bdg-success-line:`Θ` ) × (( :bdg-secondary-line:`Equality` + :bdg-success-line:`Φ` ) + :bdg-secondary-line:`Equity` × ( 1 - :bdg-success-line:`Φ` )) Tutorial 3 - Crockett et al., 2014 ------------------- .. dropdown:: Create :bdg-secondary:`Construct Value` Functions .. dropdown:: Harm Aversion .. tab-set:: .. tab-item:: Plain English Here, the :bdg-secondary-line:`Harm` caused by a certain choice is the relative change in the number of shocks experienced. .. tab-item:: R :: harm = function(shocksThisChoice, shocksOtherChoice){ return(shocksThisChoice - shocksOtherChoice) } .. tab-item:: MatLab :: .. tab-item:: Python :: .. dropdown:: Payout-Maximization .. tab-set:: .. tab-item:: Plain English Here, the extent to which one has maximized :bdg-secondary-line:`Payout` is the relative change in the amount of money one has received. .. tab-item:: R :: payout = function(moneyThisChoice, moneyOtherChoice){ return(moneyThisChoice - moneyOtherChoice) } .. tab-item:: MatLab :: .. tab-item:: Python :: .. dropdown:: Identify Relevant :bdg-success:`Free Parameters` for each :bdg-secondary:`Construct Value` 1. :bdg-secondary-line:`Harm` - :bdg-success-line:`D1` & :bdg-success-line:`D2` 2. :bdg-secondary-line:`Payout` - :bdg-success-line:`D1` & :bdg-success-line:`D2` .. dropdown:: Propose a :bdg-warning:`Utility` Equation :bdg-warning-line:`Utility Difference` = ( :bdg-success-line:`κ` × :bdg-secondary-line:`Payout`) + ((1 - :bdg-success-line:`κ` ) × :bdg-secondary-line:`Harm`) Tutorial 4 - Li et al., 2022 ------------------- .. dropdown:: Create :bdg-secondary:`Construct Value` Functions .. dropdown:: Inequality Aversion .. tab-set:: .. tab-item:: Plain English Here, :bdg-secondary-line:`Inequality` is the absolute value of the difference between :bdg-primary-line:`Player A`'s and :bdg-primary-line:`Player B`'s payouts for each :bdg-danger:`Choice`. .. tab-item:: R :: inequality = function(a1, b1, a2, b2){ d_Inequality = abs(a2 - b2) - abs(a1 - b1) return(d_Inequality) } .. tab-item:: MatLab :: .. tab-item:: Python :: .. dropdown:: Harm Aversion .. tab-set:: .. tab-item:: Plain English :bdg-secondary-line:`Harm` is defined as the amount taken away from the more advantaged :bdg-primary-line:`Player` for each :bdg-danger:`Choice`. .. tab-item:: R :: harm = function(a0, b0, a1, b1, a2, b2){ initial = c(a0, b0) choice1 = c(a1, b1) choice2 = c(a2, b2) if (a0 == b0){advantaged = 1} else {advantaged = which(initial == max(initial))} d_lossAdvantaged = (initial[advantaged] - choice1[advantaged]) - (initial[advantaged] - choice2[advantaged]) return(d_lossAdvantaged) } .. tab-item:: MatLab :: .. tab-item:: Python :: .. dropdown:: Rank Reversal Aversion .. tab-set:: .. tab-item:: Plain English Finally, :bdg-secondary-line:`Rank Reversal` is defined as whether or not the more initially advantaged :bdg-primary-line:`Player` is less advantaged in the current :bdg-danger:`Choice`. .. tab-item:: R :: rankReverse = function(a0, b0, a1, b1, a2, b2){ if (a0 == b0){return(0)} d_initial = a0 - b0 d_choice1 = a1 - b1 d_choice2 = a2 - b2 if (d_initial > 0){ if (d_choice1 < 0){choice1Reversed = 1} else {choice1Reversed = 0} if (d_choice2 < 0){choice2Reversed = 1} else {choice2Reversed = 0} } else if (d_initial < 0){ if (d_choice1 > 0){choice1Reversed = 1} else {choice1Reversed = 0} if (d_choice2 > 0){choice2Reversed = 1} else {choice2Reversed = 0} } return(choice1Reversed - choice2Reversed) } .. tab-item:: MatLab :: .. tab-item:: Python :: .. dropdown:: Identify Relevant :bdg-success:`Free Parameters` for each :bdg-secondary:`Construct Value` 1. :bdg-secondary:`Inequality Aversion` - :bdg-success-line:`D1` 2. :bdg-secondary:`Harm Aversion` - :bdg-success-line:`D2` 3. :bdg-secondary:`Rank Reversal Aversion` - :bdg-success-line:`D3` .. dropdown:: Propose a :bdg-warning:`Utility` Equation :bdg-warning-line:`Utility Difference` = ( :bdg-success-line:`α` × :bdg-secondary-line:`Inequality`) - ( :bdg-success-line:`δ` × :bdg-secondary-line:`Harm`) - ( :bdg-success-line:`ρ` × :bdg-secondary-line:`Rank Reversal`)