## Code

```
library(ggplot2)
<- function(x){
u ifelse (x >= 0, x^0.5, -2*(-x)^0.5)
}
<- data.frame(
df x = seq(-220, 220, 0.1),
y = u(seq(-220, 220, 0.1))
)
#Variables for plot (may not match labels as not done to scale)
#Payoffs from gamble
<- -200 #loss
x1 <- 220 #win
x2 <- 10 #expected value of gamble
ev <- 0 #certain outcome
xc <-(ev-x1)/(x2-x1)
px2
ggplot(mapping = aes(x, y)) +
#Plot the utility curve
geom_line(data = df) +
geom_vline(xintercept = 0, linewidth=0.25)+
geom_hline(yintercept = 0, linewidth=0.25)+
labs(x = "x", y = "v(x)")+
# Set the theme
theme_minimal()+
#remove numbers on each axis
theme(axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.title=element_text(size=14,face="bold"),
axis.title.y = element_text(angle=0, vjust=0.5))+
#limit to y greater than zero and x greater than -8 (need -8 so space for y-axis labels)
coord_cartesian(xlim = c(-220, 220), ylim = c(-30, 15))+
#Add labels -100, v(-100) and line to curve indicating each
annotate("text", x = x1, y = 0, label = "-100", size = 4, hjust = 0.5, vjust = -0.5)+
annotate("segment", x = x1, y = 0, xend = x1, yend = u(x1), linewidth = 0.5, colour = "black", linetype="dotted")+
annotate("segment", x = 0, y = u(x1), xend = x1, yend = u(x1), linewidth = 0.5, colour = "black", linetype="dotted")+
annotate("text", x = 0, y = u(x1), label = "v(-100)", size = 4, hjust = -0.1, vjust = 0.45)+
#Add expected utility line
annotate("segment", x = x1, xend = x2, y = u(x1), yend = u(x2), linewidth = 0.5, colour = "black", linetype="dotdash")+
#Add labels 110, v(110) and line to curve indicating each
annotate("text", x = x2, y = 0, label = "110", size = 4, hjust = 0.4, vjust = 1.5)+
annotate("segment", x = x2, y = 0, xend = x2, yend = u(x2), linewidth = 0.5, colour = "black", linetype="dotted")+
annotate("segment", x = 0, y = u(x2), xend = x2, yend = u(x2), linewidth = 0.5, colour = "black", linetype="dotted")+
annotate("text", x = 0, y = u(x2), label = "v(110)", size = 4, hjust = 1.05, vjust = 0.45)+
#Add labels E[A], V(A) and curve indicating each
annotate("text", x = ev, y = 0, label = "E[A]", size = 4, hjust = 0.3, vjust = -0.5)+
annotate("segment", x = ev, y = 0, xend = ev, yend = u(x1)+(u(x2)-u(x1))*px2, linewidth = 0.5, colour = "black", linetype="dashed")+
annotate("segment", x = 0, y = u(x1)+(u(x2)-u(x1))*px2, xend = ev, yend = u(x1)+(u(x2)-u(x1))*px2, linewidth = 0.5, colour = "black", linetype="dashed")+
annotate("text", x = 0, y = u(x1)+(u(x2)-u(x1))*px2, label = "V(A)", size = 4, hjust = 1.05, vjust = 0.45)
```