Simple code for the probability weighting function according to prospect theory
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_weight
s() 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) pt_weights<-function(prob,gamma){ if(sum(prob)==1){ b<-0 wvec<-NULL for(p in prob){ d<-p^gamma+b b<-d } for(p in prob){ w<-(p^gamma)/(b^(1/gamma)) wvec<-rbind(wvec,w)} return(as.numeric(wvec)) } else{ print("Error: probability vector must sum to 1") }}
Example
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.
#Example p_vec<-c(0.1,0.3,0.2,0.4) pt_weights(p_vec,0.61) #Output: [1] 0.1057201 0.2066338 0.1613563 0.2462715 #Note: subadditivity of weighted probabilities sum(pt_weights(p_vec,0.61)) [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!
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.