# Load necessary libraries
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.2.3
# Define the range of x
x <- seq(-2, 2, length.out = 400)
# Define mu(x) for each error distribution
mu_normal <- pnorm(x)
mu_logistic <- plogis(pi * x / sqrt(3))
mu_uniform <- (x / (2 * sqrt(3))) + 0.5
# Create a data frame for plotting
df <- data.frame(
x = rep(x, 3),
mu = c(mu_normal, mu_logistic, mu_uniform),
distribution = factor(rep(c("Normal", "Logistic", "Uniform"), each = length(x)))
)
# Plotting mu(x)
ggplot(df, aes(x = x, y = mu, color = distribution)) +
geom_line() +
labs(title = expression(mu(x) ~ "for Different Error Distributions"),
y = expression(mu(x)), x = "x") +
theme_minimal() +
scale_color_manual(values = c("blue", "green", "red")) +
theme(legend.title = element_blank())

# Plotting logit(mu(x))
df$logit_mu <- log(df$mu / (1 - df$mu))
## Warning in log(df$mu/(1 - df$mu)): NaNs produced
ggplot(df, aes(x = x, y = logit_mu, color = distribution)) +
geom_line() +
labs(title = expression(logit(mu(x)) ~ "for Different Error Distributions"),
y = expression(logit(mu(x))), x = "x") +
theme_minimal() +
scale_color_manual(values = c("blue", "green", "red")) +
theme(legend.title = element_blank())
## Warning: Removed 54 rows containing missing values or values outside the scale range
## (`geom_line()`).
