Tomamos los datos en: https://www.inegi.org.mx/temas/pib/#Tabulados
setwd("~/Estadistica")
library(readr)
PIB <- read_csv("~/Estadistica/PIB.csv")
##
## -- Column specification --------------------------------------------------------
## cols(
## primarias = col_double(),
## manufactura = col_double(),
## inmobiliarias = col_double()
## )
head(PIB)
## # A tibble: 6 x 3
## primarias manufactura inmobiliarias
## <dbl> <dbl> <dbl>
## 1 371390. 1698488. 998787.
## 2 369425. 1678576. 1010400.
## 3 377071. 1671630. 1017815.
## 4 362920. 1681706. 1027499.
## 5 363635. 1698171. 1040847.
## 6 393408. 1737834. 1052990.
mean(PIB$primarias)
## [1] 471505.8
median(PIB$primarias)
## [1] 470182.3
library(modeest)
mlv(PIB$primarias, method = "mfv")
## [1] 351036.5 358108.6 362920.4 363634.9 368845.8 369424.7 371390.2 371847.3
## [9] 377070.8 377685.1 385071.9 386531.7 387759.8 387893.5 388504.7 390053.8
## [17] 391824.9 392134.9 392264.4 393407.9 394887.2 396696.7 397191.0 398155.0
## [25] 398629.1 402645.9 407587.3 409415.4 411035.7 415778.9 416318.7 421223.1
## [33] 422867.3 425053.4 427278.5 429969.9 431401.3 435588.0 436274.2 437004.5
## [41] 438472.6 438656.2 439030.0 441998.5 442317.4 442739.9 446117.2 446375.0
## [49] 450220.8 456849.3 459959.5 460202.8 462744.9 462822.4 466886.5 467940.9
## [57] 472423.6 472699.0 473111.7 474005.5 474238.0 476841.0 476917.1 477514.1
## [65] 477587.1 478576.3 478896.8 484933.3 485481.7 486657.3 487170.5 489061.0
## [73] 491190.6 493474.1 494162.2 495701.6 498927.5 500117.8 501393.4 502625.0
## [81] 508378.5 510001.4 512843.2 518674.9 524088.8 528627.5 533250.8 538724.4
## [89] 539983.4 540421.2 541769.2 544433.2 545250.2 557704.1 568053.2 568808.0
## [97] 568853.0 575101.2 576255.0 581070.6 587197.5 587682.0 587878.1 590808.7
## [105] 592659.0 592912.4 593758.2 594163.6 596741.9 604903.4 616544.1 631653.3
summary(PIB$primarias)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 351037 410631 470182 471506 520028 631653
max(PIB$primarias)
## [1] 631653.3
min(PIB$primarias)
## [1] 351036.5
boxplot(PIB$primarias)
library(fdth)
##
## Attaching package: 'fdth'
## The following object is masked from 'package:modeest':
##
## mfv
## The following objects are masked from 'package:stats':
##
## sd, var
dist <- fdt(PIB$primarias, breaks = "Sturges")
dist
## Class limits f rf rf(%) cf cf(%)
## [347526.129,383831.592) 10 0.09 8.93 10 8.93
## [383831.592,420137.055) 21 0.19 18.75 31 27.68
## [420137.055,456442.518) 18 0.16 16.07 49 43.75
## [456442.518,492747.981) 24 0.21 21.43 73 65.18
## [492747.981,529053.444) 13 0.12 11.61 86 76.79
## [529053.444,565358.907) 8 0.07 7.14 94 83.93
## [565358.907,601664.37) 15 0.13 13.39 109 97.32
## [601664.37,637969.833) 3 0.03 2.68 112 100.00
hist(PIB$primarias)
#Absoluta
plot(dist, type = "fh")
plot(dist, type = "fp", col = "black")
#Acumulada
plot(dist, type = "cfh")
plot(dist, type = "cfp", col = "black")
#Relativa
plot(dist, type = "rfh")
plot(dist, type = "rfp", col = "black")
min(PIB$primarias)
## [1] 351036.5
max(PIB$primarias)
## [1] 631653.3
max(PIB$primarias)- min(PIB$primarias)
## [1] 280616.8
plot(PIB$primarias)
lm.dist.speed <- lm(PIB$primarias ~ PIB$inmobiliarias)
lm.dist.speed
##
## Call:
## lm(formula = PIB$primarias ~ PIB$inmobiliarias)
##
## Coefficients:
## (Intercept) PIB$inmobiliarias
## 1.532e+05 2.027e-01
plot(lm.dist.speed)
cor(PIB)
## primarias manufactura inmobiliarias
## primarias 1.0000000 0.8979538 0.9614170
## manufactura 0.8979538 1.0000000 0.9115337
## inmobiliarias 0.9614170 0.9115337 1.0000000
pairs(PIB)
mean(PIB$inmobiliarias)
## [1] 1570802
median(PIB$inmobiliarias)
## [1] 1582417
library(modeest)
mlv(PIB$inmobiliarias, method = "mfv")
## [1] 998786.5 1010400.0 1017815.1 1027499.3 1040846.8 1052990.5 1061997.4
## [8] 1071085.9 1081899.1 1090147.5 1100050.2 1108722.8 1121553.8 1130838.5
## [15] 1140772.0 1148461.8 1152976.5 1162436.3 1169150.5 1176209.7 1180001.7
## [22] 1188178.1 1194145.0 1202344.2 1214119.5 1227782.5 1241755.1 1252100.9
## [29] 1265115.5 1277347.8 1289301.5 1300858.7 1315843.3 1328261.4 1336191.8
## [36] 1345491.7 1346509.0 1354713.5 1368670.8 1378940.5 1395531.7 1402297.5
## [43] 1420959.0 1435916.0 1449865.7 1466334.0 1471072.0 1471404.9 1484691.7
## [50] 1496019.1 1501011.5 1515406.3 1539661.1 1560846.7 1568628.7 1578234.6
## [57] 1586600.3 1608974.7 1626808.6 1637882.7 1645685.8 1665057.0 1672874.1
## [64] 1673078.5 1678430.7 1679159.3 1699994.1 1702526.6 1713141.9 1728565.7
## [71] 1752428.3 1762721.3 1777521.0 1779450.1 1792507.4 1813614.3 1822601.4
## [78] 1829997.1 1842771.2 1843496.9 1847655.2 1852728.3 1857708.6 1867323.0
## [85] 1880929.2 1886702.1 1901156.9 1912307.3 1918526.3 1942484.3 1946775.7
## [92] 1957807.3 1958684.1 1977714.4 1985272.8 1997899.6 1998123.1 1998584.3
## [99] 2006775.5 2018933.9 2029323.8 2029454.1 2038797.5 2043916.1 2045017.9
## [106] 2052070.5 2059907.9 2062074.7 2069001.6 2071895.5 2073988.6 2074242.0
summary(PIB$inmobiliarias)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 998787 1261862 1582417 1570802 1870725 2074242
max(PIB$inmobiliarias)
## [1] 2074242
min(PIB$inmobiliarias)
## [1] 998786.5
boxplot(PIB$inmobiliarias)
library(fdth)
dist <- fdt(PIB$inmobiliarias, breaks = "Sturges")
dist
## Class limits f rf rf(%) cf cf(%)
## [988798.6608,1127071.883) 13 0.12 11.61 13 11.61
## [1127071.883,1265345.105) 16 0.14 14.29 29 25.89
## [1265345.105,1403618.328) 13 0.12 11.61 42 37.50
## [1403618.328,1541891.55) 11 0.10 9.82 53 47.32
## [1541891.55,1680164.772) 13 0.12 11.61 66 58.93
## [1680164.772,1818437.995) 10 0.09 8.93 76 67.86
## [1818437.995,1956711.217) 15 0.13 13.39 91 81.25
## [1956711.217,2094984.439) 21 0.19 18.75 112 100.00
hist(PIB$inmobiliarias)
#Absoluta
plot(dist, type = "fh")
plot(dist, type = "fp", col = "black")
#Acumulada
plot(dist, type = "cfh")
plot(dist, type = "cfp", col = "black")
#Relativa
plot(dist, type = "rfh")
plot(dist, type = "rfp", col = "black")
min(PIB$inmobiliarias)
## [1] 998786.5
max(PIB$inmobiliarias)
## [1] 2074242
max(PIB$inmobiliarias)- min(PIB$inmobiliarias)
## [1] 1075455
plot(PIB$inmobiliarias)
lm.dist.speed <- lm(PIB$inmobiliarias ~ PIB$primarias)
lm.dist.speed
##
## Call:
## lm(formula = PIB$inmobiliarias ~ PIB$primarias)
##
## Coefficients:
## (Intercept) PIB$primarias
## -5.797e+05 4.561e+00
plot(lm.dist.speed)
cor(PIB)
## primarias manufactura inmobiliarias
## primarias 1.0000000 0.8979538 0.9614170
## manufactura 0.8979538 1.0000000 0.9115337
## inmobiliarias 0.9614170 0.9115337 1.0000000
pairs(PIB)