| title: “LABOTARIO_BONUS” |
| author: “JESSICA PAOLA AGUILAR SERVIN” |
| date: “2023-03-11” |
| output: html_document |
LABORATORIO PLOT HOOVER CURVE ##############################
INSTALAR PREVIAMENTE install.packages(“devtools”) install.packages(“devtools”, type = “win.binary”)
library(devtools)
## Loading required package: usethis
library(EconGeo)
##
## Please cite EconGeo in publications as:
## Balland, P.A. (2017) Economic Geography in R: Introduction to the EconGeo Package, Papers in Evolutionary Economic Geography, 17 (09): 1-75
generate vectors industrial
ind <- c(0, 10, 10, 30, 50)
pop <- c(10, 15, 20, 25, 30)
CHECK VECTOR
ind
## [1] 0 10 10 30 50
CHECK VECTOR POP
pop
## [1] 10 15 20 25 30
RUN THE FUNTION (30% de la poblacion produce 50% de los resultados industriales)
Hoover.curve (ind, pop)
COMPUTE HOOVER GINI
Hoover.Gini (ind, pop)
## [1] 0.31
| ################################# LABORTARIO GINI ################################# |
|---|
| ############################ LABORATORIO HOOVER GINI ############################ |
| USAGE Hoover.Gini(MAT,POP) |
| GENERATE VECTORS OF INDUSTRIAL COUNT |
r ind <- c(0, 10, 10, 30, 50) pop <- c(10, 15, 20, 25, 30) |
| RUN THE FUNCTION |
r Hoover.Gini (ind,pop) |
## [1] 0.31 |
| GENERATE A REGION-INDUSTRY MATRIX |
r mat = matrix ( c (0, 10, 0, 0, 0, 15, 0, 0, 0, 20, 0, 0, 0, 25, 0, 1, 0, 30, 1, 1), ncol = 4, byrow = T) rownames(mat) <- c ("R1", "R2", "R3", "R4", "R5") colnames(mat) <- c ("I1", "I2", "I3", "I4") |
| RUN THE FUNCTION |
r Hoover.Gini (mat,pop) |
## Industry Hoover.Gini ## 1 I1 NaN ## 2 I2 0.000 ## 3 I3 0.700 ## 4 I4 0.475 |
| RUN THE FUNCTION BY AGGREGATING ALL INDUSTRIES |
r Hoover.Gini (rowSums(mat),pop) |
## [1] 0.015 |
| RUN THE FUNCTION #1 ONLY |
r Hoover.Gini (mat[,1],pop) |
## [1] NaN |
| RUN THE FUNCTION #2 ONLY (perfectamente proporcional) |
r Hoover.Gini (mat[,2],pop) |
## [1] 0 |
| RUN THE FUNCTION #3 ONLY (30% produce el 100% de la producción) |
r Hoover.Gini (mat[,3], pop) |
## [1] 0.7 |
| RUN THE FUNCTION #4 ONLY (55% produce el 100% de la producción) |
r Hoover.Gini (mat[,4], pop) |
## [1] 0.475 |
LABORATORIO LOCATIONAL GINI ##############################
GENERATE REGION- INDUSTRI MATRIX
mat = matrix (
c (100, 0, 0, 0, 0,
0, 15, 5, 70, 10,
0, 20, 10, 20, 50,
0, 25, 30, 5, 40,
0, 40, 55, 5, 0), ncol = 5, byrow = T)
rownames(mat) <- c ("R1", "R2", "R3", "R4", "R5")
colnames(mat) <- c ("I1", "I2", "I3", "I4", "I5")
RUN THE FUNCTION
locational.Gini (mat)
## Industry Loc.Gini
## 1 I1 0.40
## 2 I2 0.18
## 3 I3 0.27
## 4 I4 0.31
## 5 I5 0.28
| ############################## LOCATIONAL.GINI_CURVE ############################## |
| GENERATE A RECION-INDUSTRI MATRIX |
r mat = matrix ( c (100, 0, 0, 0, 0, 0, 15, 5, 70, 10, 0, 20, 10, 20, 50, 0, 25, 30, 5, 40, 0, 40, 55, 5, 0), ncol = 5, byrow = T) rownames(mat) <- c ("R1", "R2", "R3", "R4", "R5") colnames(mat) <- c ("I1", "I2", "I3", "I4", "I5") |
| RUN THE FUNCTION (SHOWS INDUSTRY #5) |
r locational.Gini.curve (mat) |
r locational.Gini.curve (mat, pdf = TRUE) |
## [1] "locational.Gini.curve.pdf has been saved to your current working directory" |
LABORATORIO LORENZ.CURVE
#################################
GENERATE VECTORS OF INDUSTRIAL COUNT
ind <- c(0, 10, 10, 30, 50)
RUN THE FUNCTION
Lorenz.curve (ind)
Lorenz.curve (ind, pdf = TRUE)
## [1] "Lorenz.curve.pdf has been saved to your current working directory"
Lorenz.curve (ind, plot = FALSE)
## $cum.reg
## [1] 0.0 0.2 0.4 0.6 0.8 1.0
##
## $cum.out
## [1] 0.0 0.0 0.1 0.2 0.5 1.0
GENERATE A REGION- INDUSTRY MATRIX
mat= matrix (
c (0, 1, 0, 0,
0, 1, 0, 0,
0, 1, 0, 0,
0, 1, 0, 1,
0, 1, 1, 1), ncol = 4, byrow = T)
rownames(mat) <- c ("R1", "R2", "R3", "R4", "R5")
colnames(mat) <- c ("I1", "I2", "I3", "I4")
RUN THE FUNCTION
Lorenz.curve (mat)
Lorenz.curve (mat, pdf = TRUE)
## [1] "Lorenz.curve.pdf has been saved to your current working directory"
Lorenz.curve (mat, plot = FALSE)
## $cum.reg
## [1] 0.0 0.2 0.4 0.6 0.8 1.0
##
## $cum.out
## R1 R2 R3 R4 R5
## 0 NaN NaN NaN NaN NaN
RUN THE FUNCTION BY AGGREGATION ALL INDUSTRIES
Lorenz.curve (rowSums(mat))
Lorenz.curve (rowSums(mat), pdf = TRUE)
## [1] "Lorenz.curve.pdf has been saved to your current working directory"
Lorenz.curve (rowSums(mat), plot = FALSE)
## $cum.reg
## [1] 0.0 0.2 0.4 0.6 0.8 1.0
##
## $cum.out
## R1 R2 R3 R4 R5
## 0.000 0.125 0.250 0.375 0.625 1.000
RUN THE FUNCTION FOR INDUSTRIY #1 ONLY (PERFECT EQUALITY)
Lorenz.curve (mat[,1])
Lorenz.curve (mat[,1], pdf = TRUE)
## [1] "Lorenz.curve.pdf has been saved to your current working directory"
Lorenz.curve (mat[,1], plot = FALSE)
## $cum.reg
## [1] 0.0 0.2 0.4 0.6 0.8 1.0
##
## $cum.out
## R1 R2 R3 R4 R5
## 0 NaN NaN NaN NaN NaN
RUN THE FUNCTION FOR INDUSTRIY #2 ONLY (PERFECT EQUALITY)
Lorenz.curve (mat[,2])
Lorenz.curve (mat[,2], pdf = TRUE)
## [1] "Lorenz.curve.pdf has been saved to your current working directory"
Lorenz.curve (mat[,2], plot = FALSE)
## $cum.reg
## [1] 0.0 0.2 0.4 0.6 0.8 1.0
##
## $cum.out
## R1 R2 R3 R4 R5
## 0.0 0.2 0.4 0.6 0.8 1.0
RUN THE FUNCTION FOR INDUSTRIY #3 ONLY (PERFECT UNEQUALITY)
Lorenz.curve (mat[,3])
Lorenz.curve (mat[,3], pdf = TRUE)
## [1] "Lorenz.curve.pdf has been saved to your current working directory"
Lorenz.curve (mat[,3], plot = FALSE)
## $cum.reg
## [1] 0.0 0.2 0.4 0.6 0.8 1.0
##
## $cum.out
## R1 R2 R3 R4 R5
## 0 0 0 0 0 1
RUN THE FUNCTION FOR INDUSTRIY #4 ONLY (PERFECT UNEQUALITY)
Lorenz.curve (mat[,4])
Lorenz.curve (mat[,4], pdf = TRUE)
## [1] "Lorenz.curve.pdf has been saved to your current working directory"
Lorenz.curve (mat[,4], plot = FALSE)
## $cum.reg
## [1] 0.0 0.2 0.4 0.6 0.8 1.0
##
## $cum.out
## R1 R2 R3 R4 R5
## 0.0 0.0 0.0 0.0 0.5 1.0
COMPARE THE DISTRIBUTION OF THE INDUSTRIES
par(mfrow=c(2,2))
Lorenz.curve (mat[,1])
Lorenz.curve (mat[,2])
Lorenz.curve (mat[,3])
Lorenz.curve (mat[,4])