Carregando WebR...
# ============================================ # Equilibrio de longo prazo com entrada/saida # Tres tipos de industria: # custos constantes, crescentes, decrescentes # ============================================ # --- Firma individual: C(q) = CF + c*q + d*q^2 --- CF <- 50; c_par <- 10; d_par <- 1 CMe <- function(q) CF/q + c_par + d_par*q CMg <- function(q) c_par + 2*d_par*q CVMe <- function(q) c_par + d_par*q # CMe minimo (ponto de lucro zero) q_min <- sqrt(CF / d_par) p_min <- CMe(q_min) cat("====== FIRMA INDIVIDUAL ======\n") cat("C(q) =", CF, "+", c_par, "q +", d_par, "q^2\n") cat("CMe_min =", round(p_min, 2), " em q =", round(q_min, 2), "\n\n") # --- Demanda de mercado --- a_dem <- 1000; b_dem <- 10 Qd <- function(p) a_dem - b_dem * p # --- 1. CUSTOS CONSTANTES --- cat("====== 1. INDUSTRIA DE CUSTOS CONSTANTES ======\n") p_LP1 <- p_min Q_LP1 <- Qd(p_LP1) n_LP1 <- Q_LP1 / q_min cat("p_LP =", round(p_LP1, 2), " (= CMe_min, fixo)\n") cat("Q_LP =", round(Q_LP1, 1), "\n") cat("Numero de firmas =", round(n_LP1, 1), "\n") cat("Oferta LP: horizontal em p =", round(p_LP1, 2), "\n\n") # --- 2. CUSTOS CRESCENTES --- # CMe_min sobe com n: p_min(n) = p_min + 0.1*(n - n_LP1) cat("====== 2. INDUSTRIA DE CUSTOS CRESCENTES ======\n") gamma <- 0.1 # sensibilidade do custo ao numero de firmas # No LP: p = p_min + gamma*(Q/q_min - n_LP1) e p = (a - Q)/b # Resolver: # Q/b_dem = a/b_dem - p_min - gamma*(Q/q_min - n_LP1) # Simplificando para oferta LP inclinada positiva # Oferta LP: p = p_min + (gamma/q_min)*(Q - Q_LP1) slope_LP <- gamma / q_min cat("Oferta LP: p =", round(p_LP1, 2), "+", round(slope_LP, 4), "*(Q -", round(Q_LP1,1), ")\n") # Choque de demanda: a' = 1200 a_dem2 <- 1200 # Novo equilibrio LP # a'/b - Q/b = p_min + slope*(Q - Q_LP1) # (a'/b - p_min + slope*Q_LP1) = Q*(1/b + slope) Q_LP2 <- (a_dem2/b_dem - p_LP1 + slope_LP * Q_LP1) / (1/b_dem + slope_LP) p_LP2 <- p_LP1 + slope_LP * (Q_LP2 - Q_LP1) n_LP2 <- Q_LP2 / q_min cat("Pos-choque (demanda +200):\n") cat(" p_LP =", round(p_LP2, 2), " (subiu!)\n") cat(" Q_LP =", round(Q_LP2, 1), "\n") cat(" Firmas =", round(n_LP2, 1), "\n\n") # --- 3. CUSTOS DECRESCENTES --- cat("====== 3. INDUSTRIA DE CUSTOS DECRESCENTES ======\n") gamma_d <- -0.05 slope_LP_d <- gamma_d / q_min cat("Oferta LP: inclinacao negativa =", round(slope_LP_d, 4), "\n") Q_LP3 <- (a_dem2/b_dem - p_LP1 + abs(slope_LP_d)*Q_LP1) / (1/b_dem - abs(slope_LP_d)) p_LP3 <- p_LP1 + slope_LP_d * (Q_LP3 - Q_LP1) cat("Pos-choque: p_LP =", round(p_LP3, 2), " (caiu!)\n") cat(" Q_LP =", round(Q_LP3, 1), "\n\n") # --- Grafico --- par(mfrow = c(1, 2), mar = c(4.5, 4.5, 3, 1), bg = "#f8f9fa") # Painel 1: Firma individual q_seq <- seq(0.5, 20, length = 300) plot(q_seq, CMe(q_seq), type = "l", lwd = 2, col = "#0d6efd", ylim = c(0, 50), xlab = "q (firma)", ylab = "$/unidade", main = "Firma individual") lines(q_seq, CMg(q_seq), lwd = 2, col = "#dc3545") abline(h = p_min, col = "#198754", lwd = 1.5, lty = 2) points(q_min, p_min, pch = 19, col = "#198754", cex = 1.5) text(q_min, p_min, paste0(" CMe_min=", round(p_min, 1)), pos = 4, cex = 0.75, col = "#198754", font = 2) legend("topright", legend = c("CMe", "CMg", "p_LP"), col = c("#0d6efd", "#dc3545", "#198754"), lwd = 2, lty = c(1, 1, 2), cex = 0.7, bg = "white") # Painel 2: Tres tipos de industria Q_seq <- seq(0, 900, length = 300) p_dem1 <- (a_dem - Q_seq) / b_dem p_dem2 <- (a_dem2 - Q_seq) / b_dem plot(Q_seq, p_dem1, type = "l", lwd = 2, col = "#0d6efd", lty = 2, ylim = c(0, 50), xlab = "Q (industria)", ylab = "p", main = "Oferta de longo prazo") lines(Q_seq, p_dem2, lwd = 3, col = "#0d6efd") # Custos constantes (horizontal) abline(h = p_LP1, col = "#198754", lwd = 2.5) # Custos crescentes p_cresc <- p_LP1 + slope_LP * (Q_seq - Q_LP1) lines(Q_seq[p_cresc > 0], p_cresc[p_cresc > 0], lwd = 2.5, col = "#fd7e14") # Custos decrescentes p_decresc <- p_LP1 + slope_LP_d * (Q_seq - Q_LP1) lines(Q_seq[p_decresc > 5], p_decresc[p_decresc > 5], lwd = 2.5, col = "#dc3545", lty = 4) # Equilibrios points(Q_LP1, p_LP1, pch = 19, col = "#198754", cex = 1.5) points(Q_LP2, p_LP2, pch = 17, col = "#fd7e14", cex = 1.5) legend("topright", legend = c("Demanda D", "Demanda D'", "OLP: custos ctes", "OLP: custos cresc.", "OLP: custos decresc."), col = c("#0d6efd", "#0d6efd", "#198754", "#fd7e14", "#dc3545"), lwd = c(2, 3, 2.5, 2.5, 2.5), lty = c(2, 1, 1, 1, 4), cex = 0.6, bg = "white")
▶ Executar
↻ Resetar
(Aguardando WebR...)