library(ggplot2)# ParamètresH <-16w <-1R <-10F_max <-24# Domaine pour la penteF_vals <-seq(0, H, length.out =300)C_vals <- w*H + R - w*F_vals # pente -wdf_pente <-data.frame(F = F_vals, C = C_vals)# Point EF_E <- HC_E <- R # = w*H + R - w*H# C intercept (F = 0)C_max <- w*H + R# Tracéggplot() +# Droite de la contrainte (pente -w)geom_line(data = df_pente, aes(x = F, y = C), color ="blue", size =1.2) +# Segment vertical bleu de E jusqu'à l'axe horizontal (C=0)geom_segment(aes(x = F_E, xend = F_E, y =0, yend = C_E), color ="blue", size =1.2) +# Segment horizontal pointillé rouge de E jusqu'à l'axe vertical (F=0, C=R)geom_segment(aes(x =0, xend = F_E, y = C_E, yend = C_E), color ="red", linetype ="dotted", size =1) +# Point Egeom_point(aes(x = F_E, y = C_E), color ="red", size =3) +# Annotation pour point Eannotate("text", x = F_E +0.5, y = C_E, label =paste0("E: F = H, C = R"), color ="red", hjust =0) +# Annotation pour C interceptannotate("text", x =0, y = C_max +0.5, label =paste0("C_max = wH + R "), color ="blue", hjust =0) +# Optionnel : un petit segment pour marquer C_maxgeom_segment(aes(x =-0.5, xend =0, y = C_max, yend = C_max), color ="blue", size =1) +labs(title ="Contrainte budgétaire : pente puis segment vertical",x ="Loisirs",y ="Consommation" ) +scale_x_continuous(limits =c(0, F_max)) +theme_minimal()
Déplacement de la contraite quand w augmente
Show the code
library(ggplot2)# ParamètresH <-16R <-10F_max <-24# Domaine pour la penteF_vals <-seq(0, H, length.out =300)# Contrainte pour w = 1w1 <-1C_vals1 <- w1*H + R - w1*F_valsdf_pente1 <-data.frame(F = F_vals, C = C_vals1)F_E1 <- HC_E1 <- R # = w1*H + R - w1*HC_max1 <- w1*H + R# Contrainte pour w = 2w2 <-2C_vals2 <- w2*H + R - w2*F_valsdf_pente2 <-data.frame(F = F_vals, C = C_vals2)F_E2 <- HC_E2 <- R # = w2*H + R - w2*HC_max2 <- w2*H + R# Tracéggplot() +# Droite de la contrainte w=1geom_line(data = df_pente1, aes(x = F, y = C), color ="blue", size =1.2) +# Segment vertical bleu w=1geom_segment(aes(x = F_E1, xend = F_E1, y =0, yend = C_E1), color ="blue", size =1.2) +# Segment horizontal pointillé rouge w=1geom_segment(aes(x =0, xend = F_E1, y = C_E1, yend = C_E1), color ="red", linetype ="dotted", size =1) +# Point E1geom_point(aes(x = F_E1, y = C_E1), color ="red", size =3) +annotate("text", x = F_E1 +0.5, y = C_E1, label =paste0("E1: F = H, C = R"), color ="red", hjust =0) +# Droite de la contrainte w=2geom_line(data = df_pente2, aes(x = F, y = C), color ="purple", size =1.2) +# Segment vertical violet w=2geom_segment(aes(x = F_E2, xend = F_E2, y =0, yend = C_E2), color ="purple", size =1.2) +# Segment horizontal pointillé rouge w=2geom_segment(aes(x =0, xend = F_E2, y = C_E2, yend = C_E2), color ="red", linetype ="dotted", size =1) +# Point E2geom_point(aes(x = F_E2, y = C_E2), color ="purple", size =3) +annotate("text", x = F_E2 +0.5, y = C_E2, label =paste0("E2: F = H, C = R"), color ="purple", hjust =0) +# Annotation pour C intercept w=1annotate("text", x =0, y = C_max1 +0.5, label =paste0("C_max w=1 = ", C_max1), color ="blue", hjust =0) +# Annotation pour C intercept w=2annotate("text", x =0, y = C_max2 +0.5, label =paste0("C_max w=2 = ", C_max2), color ="purple", hjust =0) +labs(title ="Contrainte budgétaire pour w=1 et w=2",x ="Loisirs",y ="Consommation" ) +scale_x_continuous(limits =c(0, F_max)) +theme_minimal()
Show the code
library(ggplot2)# ParamètresH <-16R <-10F_max <-24beta <-0.5# Contraintesw1 <-1w2 <-2# Droites de contrainteF_vals1 <-seq(0, H, length.out =300)C_vals1 <- w1*H + R - w1*F_vals1df_pente1 <-data.frame(F = F_vals1, C = C_vals1)F_vals2 <-seq(0, H, length.out =300)C_vals2 <- w2*H + R - w2*F_vals2df_pente2 <-data.frame(F = F_vals2, C = C_vals2)# Points EF_E1 <- H; C_E1 <- RF_E2 <- H; C_E2 <- R# Optimums Cobb-DouglasC_max1 <- w1*H + RC_A <- beta * C_max1F_A <- (1-beta) * C_max1 / w1U_A <- C_A^beta * F_A^(1-beta)C_max2 <- w2*H + RC_B <- beta * C_max2F_B <- (1-beta) * C_max2 / w2U_B <- C_B^beta * F_B^(1-beta)# Mini segments convexe autour des optimumsdelta <-2# largeur en LoisirsF_indiff_A <-seq(F_A - delta, F_A + delta, length.out =50)C_indiff_A <- (U_A / F_indiff_A^(1-beta))^(1/beta)df_indiff_A <-data.frame(F = F_indiff_A, C = C_indiff_A)F_indiff_B <-seq(F_B - delta, F_B + delta, length.out =50)C_indiff_B <- (U_B / F_indiff_B^(1-beta))^(1/beta)df_indiff_B <-data.frame(F = F_indiff_B, C = C_indiff_B)# Tracéggplot() +# Contraintesgeom_line(data = df_pente1, aes(x = F, y = C), color ="blue", size =1.2) +geom_segment(aes(x = F_E1, xend = F_E1, y =0, yend = C_E1), color ="blue", size =1.2) +geom_segment(aes(x =0, xend = F_E1, y = C_E1, yend = C_E1), color ="red", linetype ="dotted", size =1) +geom_line(data = df_pente2, aes(x = F, y = C), color ="purple", size =1.2) +geom_segment(aes(x = F_E2, xend = F_E2, y =0, yend = C_E2), color ="purple", size =1.2) +geom_segment(aes(x =0, xend = F_E2, y = C_E2, yend = C_E2), color ="red", linetype ="dotted", size =1) +# Points Egeom_point(aes(x = F_E1, y = C_E1), color ="red", size =3) +geom_point(aes(x = F_E2, y = C_E2), color ="purple", size =3) +# Courbes d'indifférence convexes (mini segments)geom_line(data = df_indiff_A, aes(x = F, y = C), color ="black", size =1.5) +geom_line(data = df_indiff_B, aes(x = F, y = C), color ="black" , size =1.5) +# Points optimumgeom_point(aes(x = F_A, y = C_A), color ="green", size =3) +geom_point(aes(x = F_B, y = C_B), color ="darkgreen", size =3) +# Annotationsannotate("text", x = F_A +0.5, y = C_A, label ="A (Optimum w=1)", color ="green") +annotate("text", x = F_B +0.5, y = C_B, label ="B (Optimum w=2)", color ="darkgreen") +labs(title ="Courbes d'indifférences et Contrainte budgétaire",x ="Loisirs", y ="Consommation") +scale_x_continuous(limits =c(0, F_max)) +theme_minimal()