Want to share your content on R-bloggers? click here if you have a blog, or here if you don’t.
Exploring graphs is always a fun. Attaching the edges and nodes with real examples of psychological effects and accompany them with useless mental shortcuts is beyond fun. This is why we will call it a “cognitive bias” explorer using DAG.
Here are the graphs edges and nodes and we are calling them biases and weird links. Because, yes Let’s mix the math with psychology.
biases <- c( "Confirmation Bias", "Anchoring Bias", "Availability Heuristic", "Dunning-Kruger Effect", "Survivorship Bias", "Recency Bias", "Sunk Cost Fallacy", "Bandwagon Effect", "Framing Effect", "Self-Serving Bias", "Negativity Bias", "Halo Effect" ) # useless links weird_links <- c( "You saw it on Reddit", "Too lazy to verify", "Sounds familiar", "Because Elon tweeted it", "Grandma said so", "Wikipedia said maybe", "Your gut feeling", "Cited by no one", "Used in a TED talk", "Found in fortune cookie", "Might be science", "Feels statistically valid" )
With this real life useless connections we can build a data.frame:
edges <- data.frame( from = sample(biases, n_links, replace = TRUE), to = sample(biases, n_links, replace = TRUE), reason = sample(weird_links, n_links, replace = TRUE), stringsAsFactors = FALSE )
And finally, let’s glue all the pieces together:
library(igraph) library(ggraph) library(ggplot2) bias_explorer <- function(seed = 2908, n_links = 25) { set.seed(seed) # Some psych effects from RL biases <- c( "Confirmation Bias", "Anchoring Bias", "Availability Heuristic", "Dunning-Kruger Effect", "Survivorship Bias", "Recency Bias", "Sunk Cost Fallacy", "Bandwagon Effect", "Framing Effect", "Self-Serving Bias", "Negativity Bias", "Halo Effect" ) # useless links weird_links <- c( "You saw it on Reddit", "Too lazy to verify", "Sounds familiar", "Because Elon tweeted it", "Grandma said so", "Wikipedia said maybe", "Your gut feeling", "Cited by no one", "Used in a TED talk", "Found in fortune cookie", "Might be science", "Feels statistically valid" ) edges <- data.frame( from = sample(biases, n_links, replace = TRUE), to = sample(biases, n_links, replace = TRUE), reason = sample(weird_links, n_links, replace = TRUE), stringsAsFactors = FALSE ) edges <- edges[edges$from != edges$to, ] g <- graph_from_data_frame(edges, vertices = data.frame(name = biases), directed = TRUE) ggraph(g, layout = "drl") + geom_edge_link( aes(label = reason), arrow = arrow(length = unit(3, 'mm')), end_cap = circle(2, 'mm'), start_cap = circle(2, 'mm'), label_colour = "darkgray", edge_width = 1.2, colour = "skyblue" ) + geom_node_point(color = "darkred", size = 6) + geom_node_text(aes(label = name), repel = TRUE, fontface = "bold", size = 3.5) + labs( title = "Bias_explorer(): The Absurd Web of Biases", subtitle = "Visualizing ridiculous mental shortcuts.", caption = "Edges represent irrational and useless connections." ) + theme_void() }
Just to get a graph of random connections that can spark useless or useful imagination when examining your or one’s head.

As always, the complete code is available on GitHub in Useless_R_function repository. The sample file in this repository is here (filename: Cognitive bias.R). Check the repository for future updates.
Carry on with R-coding and stay healthy!
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.
Continue reading: Little useless-useful R functions – Absurd bias DAG with useless mental shortcuts
Long-term Implications and Potential Future Developments from Graph Analysis
This text discusses the exploration of graphs through a unique perspective, profiling psychological biases and mental shortcuts as nodes and edges. This method combines mathematical and psychological elements to create a cognitive bias exploration tool using Directed Acyclic Graphs (DAG).
Cognitive Bias Analysis using Graphs
The approach thrives on the conceptual illustration of 12 biases, including “Confirmation Bias”,
“Anchoring Bias”, “Dunning-Kruger Effect”, “Survivorship Bias”, amongst others. These biases are linked with what the author humorously refers to as ‘useless links’, representing potential mental shortcuts or baseless reasoning, such as “You saw it on Reddit”, “Too lazy to verify”, “Sounds familiar”, “Grandma said so”, and more.
Construction of Data Frame and Integration of Elements
By constructing a data frame, the biases and their irrational correlations can be visualized, creating a map of how these psychological effects may interact in real-world situations. This approach makes use of R libraries like igraph, ggraph, and ggplot2, generating a graphical representation of biased cognitive networks.
Implications and Future Developments
The long-term implications of this approach could be significant in understanding the interconnectedness of cognitive biases. As it helps visualize and discover unexpected or irrational connections between different biases and behavior – it could be used by researchers or practitioners in fields as diverse as psychology, behavioral economics and marketing to anticipate human decisions and behaviours.
Actionable Advice
For those in the mentioned fields, integrating this method into their analysis process may yield surprising insights into the irrational behavior patterns that govern significant areas of human thought and decision-making. Furthermore, future research, refining this approach, could potentially incorporate deeper psychological insights or additional biases for a more comprehensive simulation.
Concluding Remarks
The complete R code for the discussed approach is made available on GitHub, enabling open-source development and further research. Exploring this could inspire innovative research designs, comprehensive bias studies, and advances in understanding the complexity of human psyche. On a lighter note, it also paves the way for interactive sessions in educational setups, making the understanding of cognitive biases more engaging and simplified.