Computing Rank Dependent Utility in R

[This article was first published on R – Jacob Smith Economics, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Probability weighting without rules can make no sense. Fortunately we have some guidance.

Introduction: What is Rank Dependent Utility?

Rank dependent utility theory made its debut in John Quiggin’s 1982 paper “A Theory of Anticipated Utility” with the mission, similar to other papers at the time, to come up with a model which addressed the Allais Paradox which was a major problem for expected utility theory. what all prior attempts had in common was replacing probabilities of specific outcomes occuring with “decision weights” or “weighted probabilities” which expressed how individuals use information regarding the probability of outcomes occuring. What made this attempt different was the fact that Quiggin came up with a formulation which required these decision weights to add up to one and preserve dominance (something which usually is not preserved in usual probability weighting).

To illustrate the problem with usual probability weighting suppose an individual faces the choice between being given a dollar with certainty and facing a 50-50 gamble between winning one dollar or two dollars. If our individual weights their probabilities according to the function w(p)=p^2 we end up with a scenario where:

1>1*(1/2)^2+2*(1/2)^2
1>1*1/4+2*1/4
1>3/4

While the math checks out, the decision is ridiculous as the gamble is clearly better than just getting dollar with certainty. To rule out these cases, we need to put some rules on how they are computed. The steps for computing rank dependent utility is given in Peter Wakker’s 2010 text “Prospect Theory: For Risk and Ambiguity” .

Building RDU_Compute()

While there is likely a more efficient code for generating a function which computes rank dependent utility, I have come up with the following to compute these the rank dependent utility of a gamble.

RDU_Compute<-function(outcomes,p_vec,pw){

if(length(outcomes)==length(p_vec)){  
#Step 0 organize outcomes and probabilities into a single vector
df<-data.frame(outcomes,p_vec)

#Step 1 Organize Probabilities by outcome, inserting a row of zeros in your data frame.
df1<-df[order(-outcomes),]
zerorow<-c(0,0)
df2<-rbind(zerorow,df1)

#Step 2  Define vector of ranks
rank<-cumsum(df2[,2])
df3<-data.frame(df2,rank)

#Step 3 compute pweights
pw_vec<-pw(df3$rank)
df4<-data.frame(df3,pw_vec)

#Step 4 Take difference between pw_vec to compute decision weights
d_weights<-diff(df4$pw_vec)
#Check if weights sum to 1
sum(d_weights)
#Add to dataframe
d_weights1<-c(0,d_weights)
df5<-data.frame(df4,d_weights1)

#Step 5: Compute Rank Dependent Utility
RDU<-df5$outcomes%*%df5$d_weights1
return(data.frame(RDU,sum(d_weights1)))} else{
  print("Outcomes and vector of probabilities must be the same length")
}
}

It should be noted:

  • RDU_Compute() requires a list of outcomes or payoffs, list of probabilities and probability weighting function (denoted by pw in the code).
  • The number of probabilities and outcomes must be the same, if not an error message will show.
  • The function is designed in a way to display two outputs, the first being the computed rank dependent utility of the gamble and if the sum of decision weights add up to 1. while this is satisfied in most cases, there are circumstances where you can break it as we will see below.

A Computed Example

Considering the rank dependent utility with a prospect that has four different outcomes we get the following:

rewards<-c(100,70,80,120)
probs<-c(0.25,0.1,0.6,0.05)
p2<-function(p){p^2}

RDU_Compute(rewards,probs,p2)

#Output:
    RDU sum.d_weights1.
1 1.091               1

Further its simple to illustrate how we can solve the initial issue of dominance. When valuing a 50-50 gamble between one dollar and two dollars we get:

rewards<-c(1,2)
probs<-c(0.5,0.5)
p2<-function(p){p^2}

RDU_Compute(c(1,2),c(0.5,0.5),p2)

#Output:
   RDU sum.d_weights1.
1 1.25               1

Probability Weighting Functions that Break Rank Dependent Utility

For reasons that are not entirely clear to me (at the time of writing this article) we can easily violate this condition of having our decision weights summing to one. To illustrate consider the case of where w(p)=p^2+0.01*p, this gives us the following:

rewards<-c(1,2)
probs<-c(0.5,0.5)
pbreak<-function(p){p^2+0.01*p}

RDU_Compute(c(1,2),c(0.5,0.5),pbreak)

#Output:
    RDU sum.d_weights1.
1 1.265            1.01

There must be some structure required of these probability weighting functions, but at this time I cant quite figure it out. If you know anything on this be sure to let me know in the comments below!

To leave a comment for the author, please follow the link and comment on their blog: R – Jacob Smith Economics.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)