Simple code for the probability weighting function according to prospect theory

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

Prospect theory made its debut back in 1979 and was one of the first major attempts to address empirical deviations from expected utility theory. One of the key ingredients in operationalizing prospect theory involve conversion of probabilities to “weighted probabilities”.

It should be noted that while there are more advanced libraries which are designed to implement prospect theoretic models (like the pt library ), my objective here was to write a function which takes a vector of probabilities and converts them into a list of weights.

The Code

The actual code for the function pt_weights() is simple and at its core is just two for loops. I wrapped these for loops in a if else statement.

#Prospect Theory Weighting Function (Circa 1979)

for(p in prob){
for(p in prob){
    print("Error: probability vector must sum to 1")


The utility of this simple code can be seen in the following example. It should be noted that this code embodies the 1979 version of prospect theory as opposed to the 1992 version which requires the probability weights to sum to one (Though the functional form is from the 1992 paper). In this case we have subadditivity of these weights.


[1] 0.1057201 0.2066338 0.1613563 0.2462715

#Note: subadditivity of weighted probabilities

[1] 0.7199816

Future Work

The next project of mine would be to compute weighted probabilities which sum to one. This requires some looking into how Rank Dependent Utility works as this was the primary springboard which transformed the 1979 version of prospect theory into an operable model of decision making as shown in the 1992 version.

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)