x <- seq(-pi, pi, 0.1)
plot(x, cos(x))
# MATRIZ DE LESLIE
L <- matrix(c(
0, 0.4, 1.5, 2.5,
0.4, 0, 0, 0,
0, 0.6, 0, 0,
0, 0, 0.8, 0
), nrow = 4, byrow = TRUE)
# POBLACIÓN INICIAL
n0 <- c(400, 100, 50, 50)
# 1) Población después de 1 año
n1 <- L %*% n0
# Total de población en t = 1
N1 <- sum(n1)
n1
N1
# 10 AÑOS
n<-matrix(0, nrow=4, ncol=11)
# Población inicial
n[,1] <- n0
# Proyección año por año
for (t in 1:10) {
n[,t+1] <- L%*% n[,t]
}
# Total de población en cada año
N<-colSums(n)
# Cociente N(t+1) / N(t)
crecimiento <- N[2:11] / N[1:10]
# Mostrar resultados
data.frame(
Año = 0:10,
Poblacion_total = N)
crecimiento
# VALOR PROPIO DOMINANTE
valores_propios <- eigen(L)$values
lambda <- max(Re(valores_propios))
lambda
eigen(L)$values
# ESTRUCTURA ESTABLE DE EDADES
eigen_L <- eigen(L)
# Vector propio asociado a lambda = 1
indice <- which.max(Re(eigen_L$values))
estructura_estable <- Re(eigen_L$vectors[, indice])
# Normalizar para que sume 1
estructura_estable <- estructura_estable / sum(estructura_estable)
estructura_estable
# Composición de edades en t=10
n10<-n[,11]
composicion_t10<-n10 /sum(n10)
composicion_t10
# Comparación
comparacion<-data.frame(
Edad = 1:4,
Estructura_estable = estructura_estable,
Composicion_t10 = composicion_t10
)
comparacion
To embed this project on your website, copy the following code and paste it into your website's HTML: