Computing Rank Dependent Utility in R: Getting More out with RDU_Data()

[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.

In a previous blog post I discussed how we can compute rank dependent utility in R. Though this function was quite exciting for myself as computing rank dependent utilty by hand is quite labor intensive, I saw the function as limiting in the sense that I was suppressing all the information generated in the process of computing rank dependent utility. This inspired me to modify the original RDU_Compute() to RDU_Data(). Lets see some of the features and output of this newer function.

Getting more with RDU_Data()

The function RDU_Data() is built as follows:

    #Step 0 organize outcomes and probabilities into a single vector
    #Step 1 Organize Probabilities by outcome.
    #Step 2  Define vector of ranks
    #Step 3 compute pweights
    #Step 4 Take difference between pw_vec to compute decision weights
    #Check if weights sum to 1
    #Add to dataframe
    #Step 5 drop the first "helper" row
                     "Weighted Ranks", "Decision Weights")
    return(df6)} else{
      print("Outcomes and vector of probabilities must be the same length")

After generating this function we can apply it to valuing a set of uncertain outcomes defined by a vector of outcomes and a corresponding vector of probabilities.

#Define outcomes, probabilities and probability weighting function.


#Compute results

  Outcomes Probabilities      Rank Weighted Ranks Decision Weights
2        2     0.3333333 0.3333333      0.3359522       0.33595216
3        1     0.1666667 0.5000000      0.4206394       0.08468719
4       -1     0.5000000 1.0000000      1.0000000       0.57936065

This framework is desirable when you want to get information on your decision weights and more information on how its computed. You can easily compute the rank dependent utility from this valuation by running the following code:

#Computing Rank Dependent Utility
payoffs%*%RDU_Data(payoffs,probs,p_0.61)$`Decision Weights`

[1,] 0.1772309


The goal of this R function was to make the computing and valuing of uncertain outcomes under rank dependent utility theory accessible and easy to implement, while giving all the “behind the scenes” information on what goes into the valuation. Perhaps I’ll think about writing an R package if I keep working on these types of models. We’ll see.

If you found this blog interesting, let me know your thoughts in the comments below!

To leave a comment for the author, please follow the link and comment on their blog: R – Jacob Smith Economics. 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)