Carregando WebR...
# ============================================ # Equacao de Mincer e Diferenciais Salariais # Exercicio Resolvido 17.3 # ============================================ # ln(w) = b0 + b1*S + b2*X + b3*X^2 + b4*D_fem + b5*D_negro b0 <- 1.20 b1 <- 0.12 # retorno por ano de educacao b2 <- 0.05 # retorno da experiencia b3 <- -0.0007 # concavidade b4 <- -0.18 # penalidade genero feminino b5 <- -0.15 # penalidade raca negra cat("====== EQUACAO DE MINCER ======\n") cat("ln(w) = 1.20 + 0.12*S + 0.05*X - 0.0007*X^2") cat(" - 0.18*D_fem - 0.15*D_negro\n\n") # --- Retorno da educacao --- cat("--- Retorno da educacao ---\n") cat(sprintf("Cada ano adicional: +%.0f%% no salario\n", b1*100)) cat(sprintf("Ensino superior (16a) vs. medio (11a): +%.0f%%\n\n", (exp(b1*5) - 1)*100)) # --- Experiencia otima --- X_star <- -b2 / (2*b3) cat("--- Experiencia otima ---\n") cat(sprintf("X* = %.1f anos\n", X_star)) cat(sprintf("Se comecou aos 18: pico salarial aos %.0f anos\n\n", 18 + X_star)) # --- Diferenciais de genero e raca --- cat("--- Diferenciais (mesma educacao e experiencia) ---\n") gap_fem <- b4 gap_negro <- b5 gap_total <- b4 + b5 cat(sprintf("Mulher vs. Homem (branco): %.1f%% (exp: %.1f%%)\n", gap_fem*100, (exp(gap_fem)-1)*100)) cat(sprintf("Negro vs. Branco (homem): %.1f%% (exp: %.1f%%)\n", gap_negro*100, (exp(gap_negro)-1)*100)) cat(sprintf("Mulher negra vs. Homem branco: %.1f%% (exp: %.1f%%)\n\n", gap_total*100, (exp(gap_total)-1)*100)) # --- Perfis salariais para 4 grupos --- cat("--- Perfis salariais (S=12, variando X) ---\n") S <- 12 X_vals <- seq(0, 45, by = 5) cat(sprintf("%-5s %-12s %-12s %-12s %-12s\n", "X", "H. Branco", "H. Negro", "M. Branca", "M. Negra")) cat(strrep("-", 56), "\n") for (X in X_vals) { w_HB <- exp(b0 + b1*S + b2*X + b3*X^2) w_HN <- exp(b0 + b1*S + b2*X + b3*X^2 + b5) w_MB <- exp(b0 + b1*S + b2*X + b3*X^2 + b4) w_MN <- exp(b0 + b1*S + b2*X + b3*X^2 + b4 + b5) cat(sprintf("%-5.0f %-12.2f %-12.2f %-12.2f %-12.2f\n", X, w_HB, w_HN, w_MB, w_MN)) } # --- Grafico --- par(mfrow = c(1, 2), mar = c(4.5, 4.5, 3, 1), bg = "#f8f9fa") # Painel 1: Perfil experiencia-salario por grupo X_seq <- seq(0, 45, length = 300) cols <- c("#0d6efd", "#dc3545", "#198754", "#6f42c1") grupos <- c("H. Branco", "H. Negro", "M. Branca", "M. Negra") dummies <- list(c(0,0), c(0,1), c(1,0), c(1,1)) w_mat <- matrix(NA, length(X_seq), 4) for (k in 1:4) { df <- dummies[[k]] w_mat[, k] <- exp(b0 + b1*S + b2*X_seq + b3*X_seq^2 + b4*df[1] + b5*df[2]) } plot(X_seq, w_mat[,1], type = "l", lwd = 3, col = cols[1], ylim = c(0, max(w_mat)*1.1), xlab = "Experiencia (anos)", ylab = "Salario-hora (R$)", main = paste0("Perfis salariais (S=", S, ")")) for (k in 2:4) { lines(X_seq, w_mat[,k], lwd = 3, col = cols[k], lty = ifelse(k > 2, 2, 1)) } abline(v = X_star, col = "#adb5bd", lty = 3) text(X_star + 1, max(w_mat)*0.3, paste0("X* = ", round(X_star,1)), col = "#adb5bd", cex = 0.7, font = 2) legend("topright", legend = grupos, col = cols, lwd = 3, lty = c(1,1,2,2), cex = 0.6, bg = "white") # Painel 2: Retorno da educacao S_seq <- seq(0, 20, length = 200) X_fixo <- 10 w_educ <- exp(b0 + b1*S_seq + b2*X_fixo + b3*X_fixo^2) plot(S_seq, w_educ, type = "l", lwd = 3, col = "#0d6efd", xlab = "Anos de escolaridade (S)", ylab = "Salario-hora (R$)", main = paste0("Retorno da educacao (X=", X_fixo, ")")) # Marcos educacionais S_marcos <- c(9, 12, 16) nomes <- c("Fund.", "Medio", "Superior") w_marcos <- exp(b0 + b1*S_marcos + b2*X_fixo + b3*X_fixo^2) points(S_marcos, w_marcos, pch = 19, col = "#dc3545", cex = 1.5) for (i in seq_along(S_marcos)) { text(S_marcos[i], w_marcos[i] * 1.1, nomes[i], col = "#dc3545", cex = 0.7, font = 2) } # Premio do superior vs medio arrows(12, w_marcos[2], 16, w_marcos[3], col = "#198754", lwd = 2, length = 0.08) text(14, (w_marcos[2]+w_marcos[3])/2 * 1.05, paste0("+", round((w_marcos[3]/w_marcos[2]-1)*100), "%"), col = "#198754", cex = 0.8, font = 2)
▶ Executar
↻ Resetar
(Aguardando WebR...)