datos <- data.frame(
aƱo = c(2006, 2007, 2008, 2009, 2010, 2011, 2012),
Q = c(35,49,81,156,255,277,400),
K = c(1,1,4,4,8,12,15),
L = c(2,3,4,9,14,14,20)
)
datos
## aƱo Q K L
## 1 2006 35 1 2
## 2 2007 49 1 3
## 3 2008 81 4 4
## 4 2009 156 4 9
## 5 2010 255 8 14
## 6 2011 277 12 14
## 7 2012 400 15 20
modelo_cd <- lm(log(Q) ~ log(K) + log(L), data = datos)
summary(modelo_cd)
##
## Call:
## lm(formula = log(Q) ~ log(K) + log(L), data = datos)
##
## Residuals:
## 1 2 3 4 5 6 7
## 0.0006220 0.0062909 -0.0001398 -0.0063396 -0.0125818 -0.0100704 0.0222187
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.98921 0.01983 150.74 1.16e-08 ***
## log(K) 0.19790 0.01646 12.02 0.000274 ***
## log(L) 0.81586 0.02040 39.99 2.34e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.01444 on 4 degrees of freedom
## Multiple R-squared: 0.9998, Adjusted R-squared: 0.9998
## F-statistic: 1.252e+04 on 2 and 4 DF, p-value: 2.55e-08
Resultados estimados por MCO:
\[ \ln(Q) = 2.9892 + 0.1979\ln(K) + 0.8159\ln(L) \]
A <- exp(coef(modelo_cd)[1])
a <- coef(modelo_cd)[2]
b <- coef(modelo_cd)[3]
resultados <- data.frame(
Parametro = c("A (Intercepto)", "a (Capital)", "b (Trabajo)"),
Valor = round(c(A, a, b), 4)
)
library(kableExtra)
knitr::kable(resultados, digits = 4, col.names = c("ParƔmetro", "Valor")) %>%
kableExtra::kable_styling(full_width = FALSE)
| ParƔmetro | Valor | |
|---|---|---|
| (Intercept) | A (Intercepto) | 19.8701 |
| log(K) | a (Capital) | 0.1979 |
| log(L) | b (Trabajo) | 0.8159 |
Función Cobb-Douglas estimada:
\[ \hat{Q} = 19.87K^{0.1979}L^{0.8159} \]
modelo_restringido <- lm(
I(log(Q) - log(L)) ~ I(log(K) - log(L)),
data = datos
)
modelo_restringido
##
## Call:
## lm(formula = I(log(Q) - log(L)) ~ I(log(K) - log(L)), data = datos)
##
## Coefficients:
## (Intercept) I(log(K) - log(L))
## 3.0224 0.2102
RSSu <- sum(resid(modelo_cd)^2)
RSSr <- sum(resid(modelo_restringido)^2)
n <- nrow(datos)
k <- length(coef(modelo_cd))
q <- 1
F_calculada <- ((RSSr - RSSu) / q) / (RSSu / (n - k))
p_valor <- pf(F_calculada, q, n - k, lower.tail = FALSE)
F_calculada
## [1] 3.635872
p_valor
## [1] 0.1292222
# Coeficientes estimados previamente
A <- 19.8701
alpha <- 0.1979
beta <- 0.8159
# Precios de los factores
w <- 25000 # salario anual por trabajador
r <- 15000 # renta anual por unidad de capital
# Senda de expansión:
# K / L = (alpha / beta) * (w / r)
ratio_KL_optimo <- (alpha / beta) * (w / r)
ratio_KL_optimo
## [1] 0.4042571
# Ecuación de la senda de expansión:
# K = ratio_KL_optimo * L
Q_objetivo <- 400
L_optimo <- (Q_objetivo / (A * ratio_KL_optimo^alpha))^(1 / (alpha + beta))
K_optimo <- ratio_KL_optimo * L_optimo
L_optimo
## [1] 23.06187
K_optimo
## [1] 9.322922
L_real <- 20
K_real <- 15
ratio_real <- K_real / L_real
ratio_real
## [1] 0.75
ratio_KL_optimo
## [1] 0.4042571
# Costos
costo_real <- w * L_real + r * K_real
costo_optimo <- w * L_optimo + r * K_optimo
costo_real
## [1] 725000
costo_optimo
## [1] 716390.5
ahorro <- costo_real - costo_optimo
ahorro
## [1] 8609.503
# =====================================
# GRAFICA: ISOCUANTA + ISOCOSTOS
# =====================================
library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following object is masked from 'package:kableExtra':
##
## group_rows
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
# Rango de trabajo (zona relevante)
L_seq <- seq(from = 15, to = 30, length.out = 250)
# =========================
# Isoquanta (Q = 400)
# =========================
K_iso <- (Q_objetivo / (A * (L_seq^beta)))^(1 / alpha)
df_iso <- tibble(
trabajo = L_seq,
capital = K_iso
)
# =========================
# Isocostos
# =========================
K_opt_line <- (costo_optimo - w * L_seq) / r
K_real_line <- (costo_real - w * L_seq) / r
df_costos <- tibble(
trabajo = rep(L_seq, 2),
capital = c(K_opt_line, K_real_line),
grupo = rep(c("Ćptimo", "Real 2012"), each = length(L_seq))
) %>%
filter(capital >= 0)
# =========================
# Puntos clave
# =========================
df_puntos <- tibble(
tipo = c("Ćptimo", "Real 2012"),
trabajo = c(L_optimo, L_real),
capital = c(K_optimo, K_real)
)
# =========================
# Etiquetas ajustadas
# =========================
df_labels <- df_puntos %>%
mutate(
trabajo = trabajo + c(1, -1.5),
capital = capital + c(2, 4),
texto = paste("Mezcla", tipo)
)
# =========================
# GRĆFICA
# =========================
ggplot() +
# Isoquanta
geom_line(
data = df_iso,
aes(x = trabajo, y = capital),
color = "#2C3E50",
size = 1.3
) +
# Isocostos
geom_line(
data = df_costos,
aes(x = trabajo, y = capital, color = grupo),
linetype = "dashed",
size = 1
) +
# Puntos
geom_point(
data = df_puntos,
aes(x = trabajo, y = capital, color = tipo),
size = 4
) +
# Etiquetas
geom_text(
data = df_labels,
aes(x = trabajo, y = capital, label = texto),
size = 4
) +
# LĆmites
coord_cartesian(
xlim = c(15, 30),
ylim = c(0, 40)
) +
# TĆtulos
labs(
title = "Comparación entre combinación óptima y observada (2012)",
x = "Trabajo (L)",
y = "Capital (K)",
color = "Tipo"
) +
# Tema visual mejorado
theme_minimal(base_size = 12) +
theme(
plot.title = element_text(face = "bold"),
legend.position = "bottom" ) +
scale_color_manual(
values = c(
"Real 2012" = "blue",
"Ćptimo" = "green"
)
)
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ā¹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.