#Base de Dados:
library(haven)
setwd("/cloud/project")
pesticidas = read_dta(file="pesticidas.dta")
cereais = read.csv("producao_cereais.csv", sep = ";")
pop_rural = read.csv("pop_rural.csv", sep = ";")
#Filtrar a Base:
library(dplyr)
colunas = c('countryname','countrycode', 'Year_ban1','Year_ban2', 'Pub_expend','IMR_total', 'treated')
pesticidas = filter(pesticidas, year == 2004) %>%
select(colunas)
cereais = filter(cereais, Year == 2004) %>%
select(countryname, production__tonnes__per_capita)
pop_rural = select(pop_rural, countryname, RP.TAX)
#Manipular a Base:
library(tidyr)
library(knitr)
pesticidas$treated[which(is.na(pesticidas$treated))] = 0
pesticidas = arrange(pesticidas,IMR_total)
pesticidas = pesticidas[1:190,]
cereais$production__tonnes__per_capita = as.numeric(cereais$production__tonnes__per_capita)
producao_cereais = cereais$production__tonnes__per_capita
cereais$ton_prod_per_capita = producao_cereais
cereais$ton_prod = cereais$production__tonnes__per_capita * 100000 + 1
cereais$log_ton_prod = log(cereais$ton_prod)
pop_rural_ratio = pop_rural$RP.TAX
pop_rural$pop_rural_ratio = pop_rural_ratio
base = inner_join(pesticidas, cereais) %>%
inner_join(pop_rural) %>%
select(-production__tonnes__per_capita,-ton_prod, -Year_ban1, -Year_ban2, -RP.TAX) %>%
select(countryname, countrycode, IMR_total, treated, Pub_expend, ton_prod_per_capita, log_ton_prod,pop_rural_ratio)
kable(base, caption = "Base de Dados")
| countryname | countrycode | IMR_total | treated | Pub_expend | ton_prod_per_capita | log_ton_prod | pop_rural_ratio |
|---|---|---|---|---|---|---|---|
| Japan | JPN | 2.8 | 1 | 3.48307 | 0.0000012 | 0.1110844 | 0.1536000 |
| Luxembourg | LUX | 3.1 | 0 | NA | 0.0078878 | 6.6717491 | 0.1382290 |
| Slovenia | SVN | 3.7 | 1 | 5.64426 | 0.1791032 | 9.7931884 | 0.4869200 |
| Spain | ESP | 3.9 | 1 | 4.15786 | 0.1124577 | 9.3278364 | 0.2297800 |
| France | FRA | 3.9 | 0 | NA | 0.2724388 | 10.2126207 | 0.2311700 |
| Italy | ITA | 3.9 | 0 | 4.38520 | 0.1964721 | 9.8857416 | 0.3238000 |
| Portugal | PRT | 3.9 | 0 | 5.04638 | 0.0756861 | 8.9318964 | 0.4309300 |
| Germany | DEU | 4.0 | 1 | NA | 0.0516799 | 8.5504334 | 0.2422100 |
| Belgium | BEL | 4.1 | 0 | NA | 0.0609982 | 8.7161782 | 0.0265000 |
| Austria | AUT | 4.2 | 1 | 5.30243 | 0.2380163 | 10.0775512 | 0.4090600 |
| Denmark | DNK | 4.3 | 0 | 8.20763 | 0.0000000 | 0.0000000 | 0.1443400 |
| Greece | GRC | 4.3 | 0 | 3.66719 | 0.2209126 | 10.0029825 | 0.2592700 |
| Switzerland | CHE | 4.4 | 1 | 5.44573 | 0.0245084 | 7.8045927 | 0.2654800 |
| Netherlands | NLD | 4.6 | 1 | 5.06297 | 0.0117313 | 7.0682798 | 0.1848600 |
| Israel | ISR | 4.7 | 0 | 5.94440 | 0.0108126 | 6.9868095 | 0.0854400 |
| Australia | AUS | 4.8 | 1 | NA | 0.0198238 | 7.5925567 | 0.1553700 |
| Canada | CAN | 5.2 | 1 | NA | 0.2769144 | 10.2289146 | 0.1995500 |
| New Zealand | NZL | 5.6 | 1 | 6.51203 | 0.0573938 | 8.6552810 | 0.1371900 |
| Cuba | CUB | 5.9 | 1 | 10.26823 | 0.0355180 | 8.1754911 | 0.2395900 |
| Croatia | HRV | 6.1 | 0 | 3.81904 | 0.4347230 | 10.6799023 | 0.4585299 |
| Hungary | HUN | 6.7 | 1 | 5.33586 | 0.8254445 | 11.3211043 | 0.3410400 |
| Poland | POL | 6.8 | 0 | 5.35574 | 0.0607323 | 8.7118108 | 0.3843600 |
| United States | USA | 6.8 | 0 | NA | 1.0201659 | 11.5329005 | 0.2024300 |
| Belarus | BLR | 7.1 | 0 | 5.71226 | 0.0038775 | 5.9629393 | 0.2811300 |
| Malaysia | MYS | 7.1 | 1 | 5.92389 | 0.0028421 | 5.6532308 | 0.3430600 |
| Lithuania | LTU | 7.5 | 0 | 5.16916 | 0.0008765 | 4.4847281 | 0.3335401 |
| Bosnia and Herzegovina | BIH | 7.9 | 0 | NA | 0.2390690 | 10.0819643 | 0.5635201 |
| Chile | CHL | 7.9 | 1 | 3.53839 | 0.0824453 | 9.0174265 | 0.1327500 |
| United Arab Emirates | ARE | 8.6 | 1 | NA | 0.0005485 | 4.0226918 | 0.1812899 |
| Qatar | QAT | 9.3 | 1 | 3.46259 | 0.0014937 | 5.0130772 | 0.0291001 |
| Costa Rica | CRI | 9.9 | 1 | 4.91218 | 0.0029743 | 5.6985266 | 0.3561201 |
| Kuwait | KWT | 10.0 | 1 | 5.53507 | 0.0032775 | 5.7952909 | 0.0000000 |
| Oman | OMN | 11.4 | 1 | 4.02838 | 0.0074907 | 6.6201638 | 0.2817298 |
| Antigua and Barbuda | ATG | 11.5 | 1 | NA | 0.0007599 | 4.3437101 | 0.7016317 |
| Bulgaria | BGR | 11.8 | 1 | 2.31995 | 0.2699221 | 10.2033406 | 0.2976700 |
| Grenada | GRD | 12.5 | 0 | NA | 0.0028776 | 5.6655938 | 0.6409925 |
| North Macedonia | MKD | 12.5 | 0 | NA | 0.0703822 | 8.8592531 | 0.4228902 |
| Lebanon | LBN | 13.1 | 1 | 2.64095 | 0.0007213 | 4.2922977 | 0.1350600 |
| Ukraine | UKR | 13.1 | 0 | 5.31351 | 0.1876097 | 9.8395870 | 0.3240300 |
| Uruguay | URY | 13.1 | 1 | 2.49954 | 0.0672943 | 8.8143937 | 0.0692199 |
| Mauritius | MUS | 13.5 | 1 | 4.31307 | 0.0002951 | 3.4180820 | 0.5777701 |
| Barbados | BRB | 14.4 | 0 | 6.02428 | 0.0009311 | 4.5444114 | 0.6696309 |
| Saudi Arabia | SAU | 14.9 | 0 | 6.27747 | 0.0022626 | 5.4261097 | 0.1924600 |
| Argentina | ARG | 15.3 | 1 | 3.48652 | 0.3866380 | 10.5626849 | 0.1014000 |
| Sri Lanka | LKA | 15.4 | 1 | NA | 0.0018060 | 5.2018143 | 0.8168100 |
| Thailand | THA | 15.5 | 1 | 4.03089 | 0.0664737 | 8.8021268 | 0.6383100 |
| Dominica | DMA | 16.1 | 1 | NA | 0.0026537 | 5.5848867 | 0.3370083 |
| Romania | ROU | 16.4 | 0 | 3.31273 | 0.6830459 | 11.1317469 | 0.4695700 |
| Jamaica | JAM | 17.2 | 1 | 3.91255 | 0.0006010 | 4.1124626 | 0.4737501 |
| Moldova | MDA | 18.0 | 0 | 6.77104 | 0.4434089 | 10.6996851 | 0.5700999 |
| Belize | BLZ | 18.1 | 0 | 5.33631 | 0.1298959 | 9.4719805 | 0.5466989 |
| Colombia | COL | 18.8 | 1 | 4.07935 | 0.0389743 | 8.2683302 | 0.2438000 |
| Albania | ALB | 19.1 | 0 | 3.22752 | 0.0705930 | 8.8622421 | 0.5434900 |
| Fiji | FJI | 19.3 | 0 | 6.16493 | 0.0000450 | 1.7047175 | 0.5052099 |
| Panama | PAN | 19.9 | 1 | 3.57866 | 0.0280652 | 7.9400552 | 0.3661299 |
| Ecuador | ECU | 20.1 | 1 | NA | 0.0580136 | 8.6660203 | 0.3848600 |
| Mexico | MEX | 20.1 | 1 | 4.72671 | 0.2084759 | 9.9450417 | 0.2400300 |
| Jordan | JOR | 20.4 | 1 | NA | 0.0000000 | 0.0000000 | 0.2167899 |
| Vietnam | VNM | 20.4 | 1 | NA | 0.0416820 | 8.3354804 | 0.7331700 |
| Libya | LBY | 20.9 | 0 | NA | 0.0006330 | 4.1634978 | 0.2308100 |
| Maldives | MDV | 20.9 | 0 | 4.66160 | 0.0002780 | 3.3604274 | 0.6751000 |
| El Salvador | SLV | 22.1 | 1 | NA | 0.1073695 | 9.2815394 | 0.3889300 |
| China | CHN | 22.2 | 1 | NA | 0.1004691 | 9.2151198 | 0.5885600 |
| Peru | PER | 22.2 | 1 | 2.95787 | 0.0430218 | 8.3671100 | 0.2535600 |
| Armenia | ARM | 22.3 | 1 | 2.48673 | 0.0063025 | 6.4477083 | 0.3596200 |
| Georgia | GEO | 23.2 | 0 | 2.91420 | 0.1029399 | 9.2394127 | 0.4678199 |
| Brazil | BRA | 23.5 | 1 | 3.97448 | 0.2262186 | 10.0267161 | 0.1747900 |
| Vanuatu | VUT | 23.7 | 1 | NA | 0.0035576 | 5.8770705 | 0.7719120 |
| Trinidad and Tobago | TTO | 23.8 | 1 | NA | 0.0022040 | 5.3999575 | 0.4484499 |
| Turkey | TUR | 23.9 | 1 | 3.02020 | 0.0442575 | 8.3954215 | 0.3277500 |
| Suriname | SUR | 24.1 | 1 | NA | 0.0001430 | 2.7276726 | 0.3326304 |
| Botswana | BWA | 24.2 | 0 | NA | 0.0040498 | 6.0063132 | 0.4451200 |
| Honduras | HND | 25.5 | 1 | NA | 0.0602852 | 8.7044222 | 0.5207300 |
| Paraguay | PRY | 25.6 | 1 | 2.86990 | 0.2067822 | 9.9368846 | 0.4269500 |
| Nicaragua | NIC | 26.0 | 1 | NA | 0.0823824 | 9.0166640 | 0.4421800 |
| Philippines | PHL | 26.9 | 1 | 2.46983 | 0.0639823 | 8.7639336 | 0.5420500 |
| Kazakhstan | KAZ | 29.0 | 1 | 2.25591 | 0.0294931 | 7.9896664 | 0.4361000 |
| Algeria | DZA | 30.1 | 0 | NA | 0.0000209 | 1.1277103 | 0.3693900 |
| Dominican Republic | DOM | 30.3 | 1 | NA | 0.0041698 | 6.0354240 | 0.3399700 |
| Iraq | IRQ | 32.8 | 1 | NA | 0.0149324 | 7.3093706 | 0.3128800 |
| Guyana | GUY | 34.0 | 0 | 5.51294 | 0.0072328 | 6.5851738 | 0.7193595 |
| Morocco | MAR | 35.3 | 1 | NA | 0.0074628 | 6.6164346 | 0.4535600 |
| Guatemala | GTM | 35.5 | 1 | NA | 0.0996440 | 9.2068746 | 0.5338400 |
| Indonesia | IDN | 36.2 | 1 | 2.74847 | 0.0496827 | 8.5110286 | 0.5485100 |
| Uzbekistan | UZB | 42.7 | 0 | NA | 0.0059615 | 6.3921715 | 0.5194600 |
| Namibia | NAM | 42.8 | 0 | NA | 0.0145632 | 7.2843565 | 0.6433403 |
| Sao Tome and Principe | STP | 45.1 | 0 | 3.23471 | 0.0168026 | 7.4272968 | 0.4202789 |
| Bolivia | BOL | 45.3 | 1 | NA | 0.0583848 | 8.6723975 | 0.3628900 |
| Turkmenistan | TKM | 46.6 | 0 | NA | 0.0031122 | 5.7436975 | 0.5318799 |
| Bhutan | BTN | 47.0 | 0 | 6.60907 | 0.1357410 | 9.5159928 | 0.7016495 |
| Azerbaijan | AZE | 47.2 | 0 | 3.44770 | 0.0178733 | 7.4890378 | 0.4781100 |
| Eritrea | ERI | 47.8 | 0 | 3.14897 | 0.0008291 | 4.4297785 | 0.6983601 |
| Nepal | NPL | 49.3 | 1 | 3.17194 | 0.0611482 | 8.7186348 | 0.8515900 |
| Gabon | GAB | 49.4 | 1 | NA | 0.0213307 | 7.6657854 | 0.1822198 |
| Papua New Guinea | PNG | 50.0 | 0 | NA | 0.0009534 | 4.5678981 | 0.8687300 |
| Tajikistan | TJK | 50.6 | 0 | 2.77203 | 0.0166079 | 7.4156528 | 0.7349199 |
| Kenya | KEN | 50.7 | 1 | 6.79693 | 0.0749354 | 8.9219296 | 0.7869000 |
| Bangladesh | BGD | 52.0 | 0 | 1.94014 | 0.0017398 | 5.1646454 | 0.7388600 |
| Zimbabwe | ZWE | 52.0 | 1 | NA | 0.1938306 | 9.8722065 | 0.6570600 |
| Senegal | SEN | 56.1 | 0 | 3.04488 | 0.0374396 | 8.2281662 | 0.5869400 |
| Ghana | GHA | 56.2 | 1 | 7.53558 | 0.0528438 | 8.5727007 | 0.5337000 |
| Cambodia | KHM | 57.0 | 0 | 1.71982 | 0.0197186 | 7.5872406 | 0.8094500 |
| India | IND | 57.8 | 1 | 3.35254 | 0.0124724 | 7.1294936 | 0.7109700 |
| Madagascar | MDG | 57.9 | 1 | 2.81262 | 0.0191579 | 7.5584056 | 0.7178900 |
| Myanmar | MMR | 58.8 | 0 | NA | 0.0162891 | 7.3962793 | 0.7224000 |
| Tanzania | TZA | 62.2 | 1 | 3.56123 | 0.1212529 | 9.4031314 | 0.7577700 |
| Haiti | HTI | 66.8 | 0 | NA | 0.0220945 | 7.7009526 | 0.5832100 |
| Togo | TGO | 67.3 | 1 | 3.10963 | 0.0940929 | 9.1495591 | 0.6527601 |
| Mauritania | MRT | 68.0 | 0 | 1.95080 | 0.0024225 | 5.4940761 | 0.5877099 |
| Eswatini | SWZ | 68.8 | 0 | 5.40161 | 0.0638849 | 8.7624099 | 0.7783398 |
| Zambia | ZMB | 68.8 | 1 | 2.46343 | 0.1085087 | 9.2920926 | 0.6357000 |
| Malawi | MWI | 70.1 | 0 | NA | 0.1295870 | 9.4696000 | 0.8503600 |
| Uganda | UGA | 70.4 | 1 | 4.95237 | 0.0397847 | 8.2889051 | 0.8349300 |
| Comoros | COM | 70.7 | 0 | NA | 0.0071379 | 6.5719866 | 0.7209701 |
| Ethiopia | ETH | 73.0 | 0 | NA | 0.0385959 | 8.2585763 | 0.8449600 |
| Djibouti | DJI | 73.1 | 0 | 9.26467 | 0.0000122 | 0.7956210 | 0.2328399 |
| Rwanda | RWA | 75.3 | 1 | NA | 0.0100330 | 6.9120497 | 0.8309200 |
| Lesotho | LSO | 76.8 | 0 | 11.10901 | 0.0407961 | 8.3140017 | 0.7831101 |
| Pakistan | PAK | 77.8 | 1 | 1.76759 | 0.0163904 | 7.4024762 | 0.6621900 |
| Benin | BEN | 78.9 | 1 | 2.56690 | 0.1066579 | 9.2748905 | 0.5996100 |
| Afghanistan | AFG | 79.6 | 0 | NA | 0.0169826 | 7.4379467 | 0.7750000 |
| Cameroon | CMR | 79.8 | 1 | 3.01364 | 0.0574741 | 8.6566791 | 0.5206000 |
| Burundi | BDI | 82.1 | 1 | 3.74496 | 0.0173020 | 7.4565707 | 0.9086100 |
| Niger | NER | 82.4 | 1 | NA | 0.0002970 | 3.4242710 | 0.8375300 |
| Burkina Faso | BFA | 83.4 | 0 | NA | 0.0358080 | 8.1836214 | 0.7924300 |
| Guinea | GIN | 86.7 | 0 | 2.21000 | 0.0514442 | 8.5458626 | 0.6802300 |
| Cote d’Ivoire | CIV | 87.5 | 1 | 4.12786 | 0.0334233 | 8.1147214 | 0.5518300 |
| Mali | MLI | 90.6 | 0 | 3.85922 | 0.0360307 | 8.1898182 | 0.6870000 |
| Mozambique | MOZ | 91.0 | 1 | 3.34515 | 0.0538425 | 8.5914186 | 0.7018200 |
| Guinea-Bissau | GNB | 92.0 | 0 | NA | 0.0236583 | 7.7693064 | 0.6222802 |
| Chad | TCD | 94.4 | 1 | 1.59295 | 0.0111741 | 7.0196605 | 0.7823200 |
| Nigeria | NGA | 98.1 | 1 | NA | 0.0407073 | 8.3118229 | 0.6178800 |
| Somalia | SOM | 103.6 | 0 | NA | 0.0200121 | 7.6020088 | 0.6446900 |
| Angola | AGO | 105.4 | 0 | NA | 0.0307387 | 8.0310178 | 0.4517300 |
| Central African Republic | CAF | 107.8 | 0 | 1.62453 | 0.0303756 | 8.0191387 | 0.6203400 |
| Sierra Leone | SLE | 128.2 | 0 | 3.10713 | 0.0058057 | 6.3657361 | 0.6340400 |
#Criando uma Identificação para Continentes:
europa = c("Albania", "Germany", "Andorra", "Austria", "Belgium", "Belarus", "Bosnia and Herzegovina", "Bulgaria", "Croatia", "Denmark", "Slovakia", "Slovenia", "Spain", "Estonia", "Finland", "France", "Greece", "Hungary", "Ireland", "Iceland", "Italy", "Kosovo", "Latvia", "Liechtenstein", "Lithuania", "Luxembourg", "North Macedonia", "Malta", "Moldova", "Monaco", "Montenegro", "Norway", "Netherlands", "Poland", "Portugal", "United Kingdom", "Czech Republic", "Romania", "Russia", "San Marino", "Serbia", "Sweden", "Switzerland", "Ukraine", "Vatican City")
v_europa = c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
africa = c("Sao Tome and Principe","South Africa", "Algeria", "Angola", "Benin", "Botswana", "Burkina Faso", "Burundi", "Cabo Verde", "Cameroon", "Chad", "Comoros", "Congo", "Cote d'Ivoire", "Djibouti", "Egypt", "Eritrea", "Eswatini", "Ethiopia", "Gabon", "Gambia", "Ghana", "Guinea", "Guinea-Bissau", "Equatorial Guinea", "Lesotho", "Liberia", "Libya", "Madagascar", "Malawi", "Mali", "Morocco", "Mauritania", "Mauritius", "Mozambique", "Namibia", "Niger", "Nigeria", "Kenya", "Central African Republic", "Democratic Republic of the Congo", "Rwanda", "São Tomé and Príncipe", "Senegal", "Seychelles", "Sierra Leone", "Somalia", "Sudan", "South Sudan", "Tanzania", "Togo", "Tunisia", "Uganda", "Zambia", "Zimbabwe")
v_africa = c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
oceania = c("Australia", "Fiji", "Marshall Islands", "Solomon Islands", "Kiribati", "Micronesia", "Nauru", "New Zealand", "Palau", "Papua New Guinea", "Samoa", "Timor-Leste", "Tonga", "Tuvalu", "Vanuatu")
v_oceania = c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
asia = c("Afghanistan", "Armenia", "Azerbaijan", "Bahrain", "Bangladesh", "Bhutan", "Brunei", "Cambodia", "China", "Cyprus", "Georgia", "India", "Indonesia", "Iran", "Iraq", "Israel", "Japan", "Jordan", "Kazakhstan", "Kuwait", "Kyrgyzstan", "Laos", "Lebanon", "Malaysia", "Maldives", "Mongolia", "Myanmar", "Nepal", "North Korea", "Oman", "Pakistan", "Palestine", "Philippines", "Qatar", "Saudi Arabia", "Singapore", "South Korea", "Sri Lanka", "Syria", "Taiwan", "Tajikistan", "Thailand", "Timor-Leste", "Turkey", "Turkmenistan", "United Arab Emirates", "Uzbekistan", "Vietnam", "Yemen")
v_asia = c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
america = c("Canada", "United States", "Mexico", "Belize", "Costa Rica", "El Salvador", "Guatemala", "Honduras", "Mexico", "Nicaragua", "Panama", "Antigua and Barbuda", "Bahamas", "Barbados", "Cuba", "Dominica", "Dominican Republic", "Grenada", "Haiti", "Jamaica", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent and the Grenadines", "Trinidad and Tobago", "Argentina", "Bolivia", "Brazil", "Chile", "Colombia", "Ecuador", "Guyana", "Paraguay", "Peru", "Suriname", "Uruguay", "Venezuela")
v_america = c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
df_europa = data.frame(País = europa,
Europa = v_europa)
df_africa = data.frame(País = africa,
Africa = v_africa)
df_oceania = data.frame(País = oceania,
Oceania = v_oceania)
df_asia = data.frame(País = asia,
Asia = v_asia)
df_america = data.frame(País = america,
America = v_america)
aux1 = base$countryname
aux1 = data.frame(aux1)
c_europeu = inner_join(aux1, df_europa, by = c("aux1" = "País"))
c_africano = inner_join(aux1, df_africa, by = c("aux1" = "País"))
c_oceania = inner_join(aux1, df_oceania, by = c("aux1" = "País"))
c_asiatico = inner_join(aux1, df_asia, by = c("aux1" = "País"))
c_americano = inner_join(aux1, df_america, by = c("aux1" = "País"))
base = left_join(base, c_europeu, by = c("countryname" = "aux1"))
base = left_join(base, c_africano, by = c("countryname" = "aux1"))
base = left_join(base, c_oceania, by = c("countryname" = "aux1"))
base = left_join(base, c_asiatico, by = c("countryname" = "aux1"))
base = left_join(base, c_americano, by = c("countryname" = "aux1"))
base$Europa <- ifelse(is.na(base$Europa), 0, 1)
base$Africa <- ifelse(is.na(base$Africa), 0, 1)
base$Oceania <- ifelse(is.na(base$Oceania), 0, 1)
base$Asia <- ifelse(is.na(base$Asia), 0, 1)
base$America <- ifelse(is.na(base$America), 0, 1)
base$continente <- ifelse(base$Europa == 1, "Europa", 0)
base$continente <- ifelse(base$Africa == 1, "Africa", base$continente)
base$continente <- ifelse(base$Oceania == 1, "Oceania", base$continente)
base$continente <- ifelse(base$Asia == 1, "Asia", base$continente)
base$continente <- ifelse(base$America == 1, "America", base$continente)
#Análise Descritiva:
library(data.table)
base = as.data.table(base)
library(stargazer)
stargazer(base,type = "text",omit=c("Europa", "Africa", "Oceania", "Asia", "America"), digits=4)
##
## ========================================================
## Statistic N Mean St. Dev. Min Max
## --------------------------------------------------------
## IMR_total 137 35.9277 30.0061 2.8000 128.2000
## treated 137 0.5620 0.4980 0 1
## Pub_expend 86 4.2662 1.8554 1.5929 11.1090
## ton_prod_per_capita 137 0.0790 0.1449 0.0000 1.0202
## log_ton_prod 137 7.4373 2.3697 0.0000 11.5329
## pop_rural_ratio 137 0.4762 0.2271 0.0000 0.9086
## --------------------------------------------------------
IMR_medio = group_by(base, treated) %>%
summarise(média = mean(IMR_total), contagem=n())
kable(round(IMR_medio,4), caption = "Índice de Mortalidade Infatil Médio - Tratado x Não Tratado")
| treated | média | contagem |
|---|---|---|
| 0 | 41.2383 | 60 |
| 1 | 31.7896 | 77 |
#Análise das Distribuições (Histogramas):
library(ggplot2)
ggplot(base, aes(x = IMR_total)) +
geom_histogram(fill = "red", bins = 30) +
labs(x = "Índice de Mortalidade Infantil", y = "Contagem", title = "Distribuição do IMR")
ggplot(base, aes(x = treated)) +
geom_histogram(fill = "orange", bins = 30) +
labs(x = "Tratamento", y = "Contagem", title = "Distribuição do Tratamento")
ggplot(base, aes(x = Pub_expend)) +
geom_histogram(fill = "blue", bins = 30) +
labs(x = "Gasto Público em Saúde", y = "Contagem", title = "Distribuição do Gasto Público em Saúde")
ggplot(base, aes(x = ton_prod_per_capita)) +
geom_histogram(fill = "green", bins = 30) +
labs(x = "Quantidade de Cereais Produzida per Capita", y = "Contagem", title = "Distribuição da Produção per Capita de Cereais")
ggplot(base, aes(x = log_ton_prod)) +
geom_histogram(fill = "green", bins = 30) +
labs(x = "Quantidade Produzida ton/100.000 hab", y = "Contagem", title = "Distribuição da Produção de Cereais")
ggplot(base, aes(x = pop_rural_ratio)) +
geom_histogram(fill = "black", bins = 30) +
labs(x = "Taxa de População Rural", y = "Contagem", title = "Distribuição da Taxa de População Rural")
#Análise da Correlação (Gráfico de Dispersão):
ggplot(base, aes(x = treated, y = IMR_total)) +
geom_point(aes(color = continente)) +
labs(title = "Relação entre Mortalidade Infatil e Pesticidas",
x = "Decisão de Banir ou Não os Pesticidas",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base$IMR_total,base$treated)
## [1] -0.1568029
ggplot(base, aes(x = Pub_expend, y = IMR_total)) +
geom_point(aes(color = continente)) +
labs(title = "Relação entre Mortalidade Infatil e Gasto Público em Saúde",
x = "Gastos Público de Saúde",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
ggplot(base, aes(x = ton_prod_per_capita, y = IMR_total)) +
geom_point(aes(color = continente)) +
labs(title = "Relação entre Mortalidade Infatil e Produção per Capita de Cereais",
x = "Produção per Capita de Cerais",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base$IMR_total,base$ton_prod_per_capita)
## [1] -0.2411835
ggplot(base, aes(x = log_ton_prod, y = IMR_total)) +
geom_point(aes(color = continente)) +
labs(title = "Relação entre Mortalidade Infatil e Produção de Cereais",
x = "Ln(Produção de Cerais - 100.000/Habitantes)",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base$IMR_total,base$log_ton_prod)
## [1] 0.02203438
ggplot(base, aes(x = pop_rural_ratio, y = IMR_total)) +
geom_point(aes(color = continente)) +
labs(title = "Relação entre Mortalidade Infatil e Taxa de População Rural",
x = "Taxa de População Rural",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base$IMR_total,base$pop_rural_ratio)
## [1] 0.6515809
#Modelagem Econométrica I (Regressão):
modelo1 = lm(IMR_total ~ treated , data = base)
resumo1 = summary(modelo1); resumo1
##
## Call:
## lm(formula = IMR_total ~ treated, data = base)
##
## Residuals:
## Min 1Q Median 3Q Max
## -38.14 -23.24 -9.49 20.21 86.96
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 41.238 3.840 10.739 <2e-16 ***
## treated -9.449 5.122 -1.845 0.0673 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 29.74 on 135 degrees of freedom
## Multiple R-squared: 0.02459, Adjusted R-squared: 0.01736
## F-statistic: 3.403 on 1 and 135 DF, p-value: 0.06727
#Teste para Heterocedasticidade:
library(lmtest)
bptest(modelo1,
varformula = ~ rstudent(modelo1),
studentize=TRUE, data=base)
##
## studentized Breusch-Pagan test
##
## data: modelo1
## BP = 52.322, df = 1, p-value = 4.71e-13
#Modelagem: Robust Standard Errors
library(sandwich)
#HOMOSKEDASTICITY-ONLY:
se_homo_df1 = as.data.frame(resumo1$coefficients) %>%
rename(Estimativa = Estimate, SE_Homo = `Std. Error`, Estatistica_t_homo = `t value`, Valor_p_homo = `Pr(>|t|)`)
#ROBUST STANDARD ERRORS
se_hete1 = coeftest(modelo1, vcov = vcovHC(modelo1, type = "HC1"))
se_hete_df1 = as.data.frame(se_hete1[,]) %>%
rename(Estimativa = Estimate, SE_Hete = `Std. Error`, Estatistica_t_hete = `t value`, Valor_p_hete = `Pr(>|t|)`)
#COMPARAÇÃO:
se_df1 = left_join(se_homo_df1,se_hete_df1)
betas1 = c('B0', 'B1')
se_df1$Coeficientes = betas1
se_df1 = data.frame(se_df1, row.names = 8)
kable(round(se_df1,4), caption = "Erro Padrão x Erro Padrão Robusto")
| Estimativa | SE_Homo | Estatistica_t_homo | Valor_p_homo | SE_Hete | Estatistica_t_hete | Valor_p_hete | |
|---|---|---|---|---|---|---|---|
| B0 | 41.2383 | 3.8400 | 10.7391 | 0.0000 | 4.2775 | 9.6408 | 0.0000 |
| B1 | -9.4487 | 5.1221 | -1.8447 | 0.0673 | 5.2565 | -1.7975 | 0.0745 |
#Modelagem Econométrica II (Adição de Controle):
modelo2 = lm(IMR_total ~ treated + Pub_expend, data = base)
resumo2 = summary(modelo2); resumo2
##
## Call:
## lm(formula = IMR_total ~ treated + Pub_expend, data = base)
##
## Residuals:
## Min 1Q Median 3Q Max
## -38.21 -20.98 -12.88 19.57 83.02
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 59.958 9.472 6.330 1.19e-08 ***
## treated -8.616 6.524 -1.321 0.19026
## Pub_expend -4.757 1.745 -2.726 0.00781 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 29.39 on 83 degrees of freedom
## (51 observations deleted due to missingness)
## Multiple R-squared: 0.08959, Adjusted R-squared: 0.06765
## F-statistic: 4.084 on 2 and 83 DF, p-value: 0.02034
#HOMOSKEDASTICITY-ONLY:
se_homo_df2 = as.data.frame(resumo2$coefficients) %>%
rename(Estimativa = Estimate, SE_Homo = `Std. Error`, Estatistica_t_homo = `t value`, Valor_p_homo = `Pr(>|t|)`)
#ROBUST STANDARD ERRORS
se_hete2 = coeftest(modelo2, vcov = vcovHC(modelo2, type = "HC1"))
se_hete_df2 = as.data.frame(se_hete2[,]) %>%
rename(Estimativa = Estimate, SE_Hete = `Std. Error`, Estatistica_t_hete = `t value`, Valor_p_hete = `Pr(>|t|)`)
#COMPARAÇÃO:
se_df2 = left_join(se_homo_df2,se_hete_df2)
betas2 = c('B0', 'B1', "B2")
se_df2$Coeficientes = betas2
se_df2 = data.frame(se_df2, row.names = 8)
kable(round(se_df2,4), caption = "Erro Padrão x Erro Padrão Robusto")
| Estimativa | SE_Homo | Estatistica_t_homo | Valor_p_homo | SE_Hete | Estatistica_t_hete | Valor_p_hete | |
|---|---|---|---|---|---|---|---|
| B0 | 59.9577 | 9.4717 | 6.3302 | 0.0000 | 11.2249 | 5.3415 | 0.0000 |
| B1 | -8.6156 | 6.5239 | -1.3206 | 0.1903 | 6.4870 | -1.3281 | 0.1878 |
| B2 | -4.7569 | 1.7448 | -2.7263 | 0.0078 | 2.3363 | -2.0361 | 0.0449 |
#Modelagem Econométrica III (Adição de Novo Controle):
modelo3 = lm(IMR_total ~ treated + Pub_expend + log_ton_prod, data = base)
resumo3 = summary(modelo3); resumo3
##
## Call:
## lm(formula = IMR_total ~ treated + Pub_expend + log_ton_prod,
## data = base)
##
## Residuals:
## Min 1Q Median 3Q Max
## -38.26 -20.99 -12.89 19.57 83.04
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 59.8123 14.6071 4.095 9.86e-05 ***
## treated -8.6278 6.6287 -1.302 0.19670
## Pub_expend -4.7535 1.7740 -2.680 0.00891 **
## log_ton_prod 0.0181 1.3773 0.013 0.98955
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 29.57 on 82 degrees of freedom
## (51 observations deleted due to missingness)
## Multiple R-squared: 0.08959, Adjusted R-squared: 0.05628
## F-statistic: 2.69 on 3 and 82 DF, p-value: 0.05164
#HOMOSKEDASTICITY-ONLY:
se_homo_df3 = as.data.frame(resumo3$coefficients) %>%
rename(Estimativa = Estimate, SE_Homo = `Std. Error`, Estatistica_t_homo = `t value`, Valor_p_homo = `Pr(>|t|)`)
#ROBUST STANDARD ERRORS
se_hete3 = coeftest(modelo3, vcov = vcovHC(modelo3, type = "HC1"))
se_hete_df3 = as.data.frame(se_hete3[,]) %>%
rename(Estimativa = Estimate, SE_Hete = `Std. Error`, Estatistica_t_hete = `t value`, Valor_p_hete = `Pr(>|t|)`)
#COMPARAÇÃO:
se_df3 = left_join(se_homo_df3,se_hete_df3)
betas3 = c('B0', 'B1', "B2", "B3")
se_df3$Coeficientes = betas3
se_df3 = data.frame(se_df3, row.names = 8)
kable(round(se_df3,4), caption = "Erro Padrão x Erro Padrão Robusto")
| Estimativa | SE_Homo | Estatistica_t_homo | Valor_p_homo | SE_Hete | Estatistica_t_hete | Valor_p_hete | |
|---|---|---|---|---|---|---|---|
| B0 | 59.8123 | 14.6071 | 4.0947 | 0.0001 | 15.4640 | 3.8678 | 0.0002 |
| B1 | -8.6278 | 6.6287 | -1.3016 | 0.1967 | 6.6465 | -1.2981 | 0.1979 |
| B2 | -4.7535 | 1.7740 | -2.6795 | 0.0089 | 2.3655 | -2.0095 | 0.0478 |
| B3 | 0.0181 | 1.3773 | 0.0131 | 0.9895 | 1.3441 | 0.0135 | 0.9893 |
#Análise Econométrica IV (Adição de Novo Controle):
modelo4 = lm(IMR_total ~ treated + Pub_expend + log_ton_prod + pop_rural_ratio, data = base)
resumo4 = summary(modelo4); resumo4
##
## Call:
## lm(formula = IMR_total ~ treated + Pub_expend + log_ton_prod +
## pop_rural_ratio, data = base)
##
## Residuals:
## Min 1Q Median 3Q Max
## -36.443 -14.705 -3.748 10.062 75.163
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.3600 12.6119 0.742 0.4601
## treated 1.7941 5.1340 0.349 0.7277
## Pub_expend -2.4319 1.3605 -1.787 0.0776 .
## log_ton_prod -0.9293 1.0390 -0.894 0.3738
## pop_rural_ratio 90.1348 11.1836 8.060 5.73e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 22.16 on 81 degrees of freedom
## (51 observations deleted due to missingness)
## Multiple R-squared: 0.4948, Adjusted R-squared: 0.4698
## F-statistic: 19.83 on 4 and 81 DF, p-value: 2.064e-11
#HOMOSKEDASTICITY-ONLY:
se_homo_df4 = as.data.frame(resumo4$coefficients) %>%
rename(Estimativa = Estimate, SE_Homo = `Std. Error`, Estatistica_t_homo = `t value`, Valor_p_homo = `Pr(>|t|)`)
#ROBUST STANDARD ERRORS
se_hete4 = coeftest(modelo4, vcov = vcovHC(modelo4, type = "HC1"))
se_hete_df4 = as.data.frame(se_hete4[,]) %>%
rename(Estimativa = Estimate, SE_Hete = `Std. Error`, Estatistica_t_hete = `t value`, Valor_p_hete = `Pr(>|t|)`)
#COMPARAÇÃO:
se_df4 = left_join(se_homo_df4,se_hete_df4)
betas4 = c('B0', 'B1', "B2", "B3", "B4")
se_df4$Coeficientes = betas4
se_df4 = data.frame(se_df4, row.names = 8)
kable(round(se_df4,4), caption = "Erro Padrão x Erro Padrão Robusto")
| Estimativa | SE_Homo | Estatistica_t_homo | Valor_p_homo | SE_Hete | Estatistica_t_hete | Valor_p_hete | |
|---|---|---|---|---|---|---|---|
| B0 | 9.3600 | 12.6119 | 0.7422 | 0.4601 | 12.2598 | 0.7635 | 0.4474 |
| B1 | 1.7941 | 5.1340 | 0.3495 | 0.7277 | 5.1669 | 0.3472 | 0.7293 |
| B2 | -2.4319 | 1.3605 | -1.7875 | 0.0776 | 1.6416 | -1.4814 | 0.1424 |
| B3 | -0.9293 | 1.0390 | -0.8944 | 0.3738 | 1.1863 | -0.7834 | 0.4357 |
| B4 | 90.1348 | 11.1836 | 8.0596 | 0.0000 | 8.7538 | 10.2967 | 0.0000 |
#ANÁLISE DOS RESÍDUOS - Avaliação da Distribuição:
base$res1 = modelo1$residuals
base_res = data.frame(res2 = modelo2$residuals,
res3 = modelo3$residuals,
res4 = modelo4$residuals)
ggplot(base, aes(x=res1)) +
geom_histogram(fill = "brown", bins = 30) +
labs(x = "Resíduos - Modelo I", y = "Contagem", title = "Distribuição dos Resíduos")
ggplot(base_res, aes(x=res2)) +
geom_histogram(fill = "brown", bins = 30) +
labs(x = "Resíduos - Modelo II", y = "Contagem", title = "Distribuição dos Resíduos")
ggplot(base_res, aes(x=res3)) +
geom_histogram(fill = "brown", bins = 30) +
labs(x = "Resíduos - Modelo III", y = "Contagem", title = "Distribuição dos Resíduos")
ggplot(base_res, aes(x=res4)) +
geom_histogram(fill = "brown", bins = 30) +
labs(x = "Resíduos - Modelo IV", y = "Contagem", title = "Distribuição dos Resíduos")
base = select(base, -res1)
#ANÁLISE GRÁFICA DOS COEFICIENTES ESTIMADOS:
library(coefplot)
coefplot(modelo4, ylab = "Parâmetros", lab.min.cex = 0.3, xlab = "IC", col = "black",title = "Análise Gráfica do Intervalo de Confiança dos Coeficientes Estimados", horizontal = TRUE)
#TABELA STARGAZER:
#SEM CORRECAO DE HETEROCEDASTICIDADE:
stargazer(modelo1, modelo2, modelo3, modelo4, type="text",title = "Resultados das Regressões sem Correção de Heterocedasticidade",file = "/cloud/project/Resultado.txt",align=TRUE,no.space=TRUE)
##
## Resultados das Regressões sem Correção de Heterocedasticidade
## ========================================================================================================
## Dependent variable:
## ------------------------------------------------------------------------------------
## IMR_total
## (1) (2) (3) (4)
## --------------------------------------------------------------------------------------------------------
## treated -9.449* -8.616 -8.628 1.794
## (5.122) (6.524) (6.629) (5.134)
## Pub_expend -4.757*** -4.754*** -2.432*
## (1.745) (1.774) (1.361)
## log_ton_prod 0.018 -0.929
## (1.377) (1.039)
## pop_rural_ratio 90.135***
## (11.184)
## Constant 41.238*** 59.958*** 59.812*** 9.360
## (3.840) (9.472) (14.607) (12.612)
## --------------------------------------------------------------------------------------------------------
## Observations 137 86 86 86
## R2 0.025 0.090 0.090 0.495
## Adjusted R2 0.017 0.068 0.056 0.470
## Residual Std. Error 29.745 (df = 135) 29.387 (df = 83) 29.565 (df = 82) 22.160 (df = 81)
## F Statistic 3.403* (df = 1; 135) 4.084** (df = 2; 83) 2.690* (df = 3; 82) 19.830*** (df = 4; 81)
## ========================================================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
## Resultados das Regressões sem Correção de Heterocedasticidade
## ============================
## /cloud/project/Resultado.txt
## ----------------------------
#COM CORRECAO DE HETEROCEDASTICIDADE:
stargazer(se_hete1, se_hete2, se_hete3, se_hete4,type="text", title = "Resultados das Regressões com Correção de Heterocedasticidade",file = "/cloud/project/Resultado.txt",align=TRUE,no.space=TRUE)
##
## Resultados das Regressões com Correção de Heterocedasticidade
## =======================================================
## Dependent variable:
## ---------------------------------------
##
## (1) (2) (3) (4)
## -------------------------------------------------------
## treated -9.449* -8.616 -8.628 1.794
## (5.256) (6.487) (6.646) (5.167)
## Pub_expend -4.757** -4.754** -2.432
## (2.336) (2.366) (1.642)
## log_ton_prod 0.018 -0.929
## (1.344) (1.186)
## pop_rural_ratio 90.135***
## (8.754)
## Constant 41.238*** 59.958*** 59.812*** 9.360
## (4.277) (11.225) (15.464) (12.260)
## =======================================================
## =======================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
## Resultados das Regressões com Correção de Heterocedasticidade
## ============================
## /cloud/project/Resultado.txt
## ----------------------------
#SUGETÕES - OLHANDO PARA RESULTADO:
modelo_extra = lm(IMR_total ~ treated + Pub_expend + log_ton_prod + pop_rural_ratio + Europa + Africa + Oceania + Asia, data = base)
resumo_extra = summary(modelo_extra); resumo_extra
##
## Call:
## lm(formula = IMR_total ~ treated + Pub_expend + log_ton_prod +
## pop_rural_ratio + Europa + Africa + Oceania + Asia, data = base)
##
## Residuals:
## Min 1Q Median 3Q Max
## -49.124 -7.314 0.264 5.202 51.882
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 13.5434 9.4613 1.431 0.156349
## treated -6.3725 3.5666 -1.787 0.077916 .
## Pub_expend -2.1251 0.9285 -2.289 0.024836 *
## log_ton_prod 0.9619 0.7592 1.267 0.208985
## pop_rural_ratio 34.1864 9.1033 3.755 0.000334 ***
## Europa -13.3471 5.1695 -2.582 0.011724 *
## Africa 41.5792 5.4863 7.579 6.56e-11 ***
## Oceania -0.4007 11.1079 -0.036 0.971315
## Asia 5.6750 5.0561 1.122 0.265174
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 14.44 on 77 degrees of freedom
## (51 observations deleted due to missingness)
## Multiple R-squared: 0.7961, Adjusted R-squared: 0.7749
## F-statistic: 37.58 on 8 and 77 DF, p-value: < 2.2e-16
#HOMOSKEDASTICITY-ONLY:
se_homo_df_extra = as.data.frame(resumo_extra$coefficients) %>%
rename(Estimativa = Estimate, SE_Homo = `Std. Error`, Estatistica_t_homo = `t value`, Valor_p_homo = `Pr(>|t|)`)
#ROBUST STANDARD ERRORS
se_hete_extra = coeftest(modelo_extra, vcov = vcovHC(modelo_extra, type = "HC1"))
se_hete_df_extra = as.data.frame(se_hete_extra[,]) %>%
rename(Estimativa = Estimate, SE_Hete = `Std. Error`, Estatistica_t_hete = `t value`, Valor_p_hete = `Pr(>|t|)`)
#COMPARACAO:
se_df_extra = left_join(se_homo_df_extra,se_hete_df_extra)
betas_extra = c('B0', 'B1', "B2", "B3", "B4", "B5", "B6", "B7", "B8")
se_df_extra$Coeficientes = betas_extra
se_df_extra = data.frame(se_df_extra, row.names = 8)
kable(round(se_df_extra,4), caption = "Erro Padrão x Erro Padrão Robusto")
| Estimativa | SE_Homo | Estatistica_t_homo | Valor_p_homo | SE_Hete | Estatistica_t_hete | Valor_p_hete | |
|---|---|---|---|---|---|---|---|
| B0 | 13.5434 | 9.4613 | 1.4314 | 0.1563 | 9.6143 | 1.4087 | 0.1630 |
| B1 | -6.3725 | 3.5666 | -1.7867 | 0.0779 | 4.2842 | -1.4875 | 0.1410 |
| B2 | -2.1251 | 0.9285 | -2.2887 | 0.0248 | 0.9258 | -2.2955 | 0.0244 |
| B3 | 0.9619 | 0.7592 | 1.2670 | 0.2090 | 0.9157 | 1.0505 | 0.2968 |
| B4 | 34.1864 | 9.1033 | 3.7554 | 0.0003 | 8.6005 | 3.9749 | 0.0002 |
| B5 | -13.3471 | 5.1695 | -2.5819 | 0.0117 | 3.0359 | -4.3964 | 0.0000 |
| B6 | 41.5792 | 5.4863 | 7.5788 | 0.0000 | 5.3908 | 7.7130 | 0.0000 |
| B7 | -0.4007 | 11.1079 | -0.0361 | 0.9713 | 3.5100 | -0.1142 | 0.9094 |
| B8 | 5.6750 | 5.0561 | 1.1224 | 0.2652 | 3.3099 | 1.7146 | 0.0904 |
##TALVEZ O EFEITO SEJA HETEROGÊNEO PARA OS CONTINENTES:##
#EUROPA:
#FILTRANDO A BASE DE DADOS
base_europa = filter(base, continente=="Europa") %>%
select(-Europa, -Africa, -Oceania, -Asia, - America, -continente) %>%
as.data.table()
#ANALISE DESCRITIVA:
stargazer(base_europa, type="text", digits=4)
##
## =====================================================
## Statistic N Mean St. Dev. Min Max
## -----------------------------------------------------
## IMR_total 25 7.4120 4.8345 3.1000 19.1000
## treated 25 0.3200 0.4761 0 1
## Pub_expend 19 4.9082 1.3392 2.3200 8.2076
## ton_prod_per_capita 25 0.1897 0.2130 0.0000 0.8254
## log_ton_prod 25 8.7153 2.4469 0.0000 11.3211
## pop_rural_ratio 25 0.3345 0.1400 0.0265 0.5701
## -----------------------------------------------------
#ANALISE DAS DISTRIBUICOES:
ggplot(base_europa, aes(x = IMR_total)) +
geom_histogram(fill = "red", bins = 30) +
labs(x = "Índice de Mortalidade Infantil", y = "Contagem", title = "Distribuição do IMR na Europa")
ggplot(base_europa, aes(x = treated)) +
geom_histogram(fill = "orange", bins = 30) +
labs(x = "Tratamento", y = "Contagem", title = "Distribuição do Tratamento na Europa")
ggplot(base_europa, aes(x = Pub_expend)) +
geom_histogram(fill = "blue", bins = 30) +
labs(x = "Gasto Público em Saúde", y = "Contagem", title = "Distribuição do Gasto Público em Saúde na Europa")
ggplot(base_europa, aes(x = ton_prod_per_capita)) +
geom_histogram(fill = "green", bins = 30) +
labs(x = "Quantidade de Cereais Produzida per Capita", y = "Contagem", title = "Distribuição da Produção per Capita de Cereais na Europa")
ggplot(base_europa, aes(x = pop_rural_ratio)) +
geom_histogram(fill = "black", bins = 30) +
labs(x = "Taxa de População Rural", y = "Contagem", title = "Distribuição da Taxa de População Rural na Europa")
#ANALISE DAS CORRELACOES:
ggplot(base_europa, aes(x = treated, y = IMR_total)) +
geom_point(color = "#00A9FF") +
labs(title = "Relação entre Mortalidade Infatil e Pesticidas na Europa",
x = "Decisão de Banir ou Não os Pesticidas",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base_europa$IMR_total,base_europa$treated)
## [1] -0.2895736
ggplot(base_europa, aes(x = Pub_expend, y = IMR_total)) +
geom_point(color = "#00A9FF") +
labs(title = "Relação entre Mortalidade Infatil e Gasto Público em Saúde na Europa",
x = "Gastos Público de Saúde",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
ggplot(base_europa, aes(x = ton_prod_per_capita, y = IMR_total)) +
geom_point(color = "#00A9FF") +
labs(title = "Relação entre Mortalidade Infatil e Produção per Capita de Cereais na Europa",
x = "Produção per Capita de Cerais",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base_europa$IMR_total,base_europa$ton_prod_per_capita)
## [1] 0.3336213
ggplot(base_europa, aes(x = pop_rural_ratio, y = IMR_total)) +
geom_point(color = "#00A9FF") +
labs(title = "Relação entre Mortalidade Infatil e Taxa de População Rural na Europa",
x = "Taxa de População Rural",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base_europa$IMR_total,base_europa$pop_rural_ratio)
## [1] 0.5890204
#AFRICA:
base_africa = filter(base, continente=="Africa") %>%
select(-Europa, -Africa, -Oceania, -Asia, - America, -continente) %>%
as.data.table()
#ANALISE DESCRITIVA:
stargazer(base_africa, type="text", digits=4)
##
## ========================================================
## Statistic N Mean St. Dev. Min Max
## --------------------------------------------------------
## IMR_total 42 69.4857 24.8560 13.5000 128.2000
## treated 42 0.4762 0.5055 0 1
## Pub_expend 25 4.0757 2.3414 1.5929 11.1090
## ton_prod_per_capita 42 0.0394 0.0423 0.00001 0.1938
## log_ton_prod 42 7.2753 2.1110 0.7956 9.8722
## pop_rural_ratio 42 0.6302 0.1731 0.1822 0.9086
## --------------------------------------------------------
#ANALISE DAS DISTRIBUICOES:
ggplot(base_africa, aes(x = IMR_total)) +
geom_histogram(fill = "red", bins = 30) +
labs(x = "Índice de Mortalidade Infantil", y = "Contagem", title = "Distribuição do IMR na África")
ggplot(base_africa, aes(x = treated)) +
geom_histogram(fill = "orange", bins = 30) +
labs(x = "Tratamento", y = "Contagem", title = "Distribuição do Tratamento na África")
ggplot(base_africa, aes(x = Pub_expend)) +
geom_histogram(fill = "blue", bins = 30) +
labs(x = "Gasto Público em Saúde", y = "Contagem", title = "Distribuição do Gasto Público em Saúde na África")
ggplot(base_africa, aes(x = ton_prod_per_capita)) +
geom_histogram(fill = "green", bins = 30) +
labs(x = "Quantidade de Cereais Produzida per Capita", y = "Contagem", title = "Distribuição da Produção per Capita de Cereais na África")
ggplot(base_africa, aes(x = pop_rural_ratio)) +
geom_histogram(fill = "black", bins = 30) +
labs(x = "Taxa de População Rural", y = "Contagem", title = "Distribuição da Taxa de População Rural na África")
#ANALISE DAS CORRELACOES:
ggplot(base_africa, aes(x = treated, y = IMR_total)) +
geom_point(color = "#F8766D") +
labs(title = "Relação entre Mortalidade Infatil e Pesticidas na África",
x = "Decisão de Banir ou Não os Pesticidas",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base_africa$IMR_total,base_africa$treated)
## [1] -0.07088246
ggplot(base_africa, aes(x = Pub_expend, y = IMR_total)) +
geom_point(color = "#F8766D") +
labs(title = "Relação entre Mortalidade Infatil e Gasto Público em Saúde na África",
x = "Gastos Público de Saúde",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
ggplot(base_africa, aes(x = ton_prod_per_capita, y = IMR_total)) +
geom_point(color = "#F8766D") +
labs(title = "Relação entre Mortalidade Infatil e Produção per Capita de Cereais na África",
x = "Produção per Capita de Cerais",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base_africa$IMR_total,base_africa$ton_prod_per_capita)
## [1] 0.05663316
ggplot(base_africa, aes(x = pop_rural_ratio, y = IMR_total)) +
geom_point(color = "#F8766D") +
labs(title = "Relação entre Mortalidade Infatil e Taxa de População Rural na África",
x = "Taxa de População Rural",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base_africa$IMR_total,base_africa$pop_rural_ratio)
## [1] 0.3637893
#OCEANIA:
base_oceania = filter(base, continente=="Oceania") %>%
select(-Europa, -Africa, -Oceania, -Asia, - America, -continente) %>%
as.data.table()
#ANALISE DESCRITIVA:
stargazer(base_oceania,type="text", digits=4)
##
## ======================================================
## Statistic N Mean St. Dev. Min Max
## ------------------------------------------------------
## IMR_total 5 20.6800 18.3730 4.8000 50.0000
## treated 5 0.6000 0.5477 0 1
## Pub_expend 2 6.3385 0.2454 6.1649 6.5120
## ton_prod_per_capita 5 0.0164 0.0243 0.00004 0.0574
## log_ton_prod 5 5.6795 2.7198 1.7047 8.6553
## pop_rural_ratio 5 0.4877 0.3390 0.1372 0.8687
## ------------------------------------------------------
#ANALISE DAS DISTRIBUICOES:
ggplot(base_oceania, aes(x = IMR_total)) +
geom_histogram(fill = "red", bins = 30) +
labs(x = "Índice de Mortalidade Infantil", y = "Contagem", title = "Distribuição do IMR na Oceania")
ggplot(base_oceania, aes(x = treated)) +
geom_histogram(fill = "orange", bins = 30) +
labs(x = "Tratamento", y = "Contagem", title = "Distribuição do Tratamento na Oceania")
ggplot(base_oceania, aes(x = Pub_expend)) +
geom_histogram(fill = "blue", bins = 30) +
labs(x = "Gasto Público em Saúde", y = "Contagem", title = "Distribuição do Gasto Público em Saúde na Oceania")
ggplot(base_oceania, aes(x = ton_prod_per_capita)) +
geom_histogram(fill = "green", bins = 30) +
labs(x = "Quantidade de Cereais Produzida per Capita", y = "Contagem", title = "Distribuição da Produção per Capita de Cereais na Oceania")
ggplot(base_oceania, aes(x = pop_rural_ratio)) +
geom_histogram(fill = "black", bins = 30) +
labs(x = "Taxa de População Rural", y = "Contagem", title = "Distribuição da Taxa de População Rural na Oceania")
#ANALISE DAS CORRELACOES:
ggplot(base_oceania, aes(x = treated, y = IMR_total)) +
geom_point(color = "#ED68ED") +
labs(title = "Relação entre Mortalidade Infatil e Pesticidas na Oceania",
x = "Decisão de Banir ou Não os Pesticidas",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base_oceania$IMR_total,base_oceania$treated)
## [1] -0.694106
ggplot(base_oceania, aes(x = Pub_expend, y = IMR_total)) +
geom_point(color = "#ED68ED") +
labs(title = "Relação entre Mortalidade Infatil e Gasto Público em Saúde na Oceania",
x = "Gastos Público de Saúde",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
ggplot(base_oceania, aes(x = ton_prod_per_capita, y = IMR_total)) +
geom_point(color = "#ED68ED") +
labs(title = "Relação entre Mortalidade Infatil e Produção per Capita de Cereais na Oceania",
x = "Produção per Capita de Cerais",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base_oceania$IMR_total,base_oceania$ton_prod_per_capita)
## [1] -0.6391118
ggplot(base_oceania, aes(x = pop_rural_ratio, y = IMR_total)) +
geom_point(color = "#ED68ED") +
labs(title = "Relação entre Mortalidade Infatil e Taxa de População Rural na Oceania",
x = "Taxa de População Rural",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base_oceania$IMR_total,base_oceania$pop_rural_ratio)
## [1] 0.9060009
#ASIA:
base_asia = filter(base, continente=="Asia") %>%
select(-Europa, -Africa, -Oceania, -Asia, - America, -continente) %>%
as.data.table()
#ANALISE DESCRITIVA:
stargazer(base_asia, type="text", digits=4)
##
## ======================================================
## Statistic N Mean St. Dev. Min Max
## ------------------------------------------------------
## IMR_total 34 31.1000 20.8451 2.8000 79.6000
## treated 34 0.6176 0.4933 0 1
## Pub_expend 24 3.6110 1.4710 1.7198 6.6091
## ton_prod_per_capita 34 0.0258 0.0341 0.0000 0.1357
## log_ton_prod 34 6.5555 2.2817 0.0000 9.5160
## pop_rural_ratio 34 0.4795 0.2527 0.0000 0.8516
## ------------------------------------------------------
#ANALISE DAS DISTRIBUICOES:
ggplot(base_asia, aes(x = IMR_total)) +
geom_histogram(fill = "red", bins = 30) +
labs(x = "Índice de Mortalidade Infantil", y = "Contagem", title = "Distribuição do IMR na Ásia")
ggplot(base_asia, aes(x = treated)) +
geom_histogram(fill = "orange", bins = 30) +
labs(x = "Tratamento", y = "Contagem", title = "Distribuição do Tratamento na Ásia")
ggplot(base_asia, aes(x = Pub_expend)) +
geom_histogram(fill = "blue", bins = 30) +
labs(x = "Gasto Público em Saúde", y = "Contagem", title = "Distribuição do Gasto Público em Saúde na Ásia")
ggplot(base_asia, aes(x = ton_prod_per_capita)) +
geom_histogram(fill = "green", bins = 30) +
labs(x = "Quantidade de Cereais Produzida per Capita", y = "Contagem", title = "Distribuição da Produção per Capita de Cereais na Ásia")
ggplot(base_asia, aes(x = pop_rural_ratio)) +
geom_histogram(fill = "black", bins = 30) +
labs(x = "Taxa de População Rural", y = "Contagem", title = "Distribuição da Taxa de População Rural na Ásia")
#ANALISE DAS CORRELACOES:
ggplot(base_asia, aes(x = treated, y = IMR_total)) +
geom_point(color = "#00C19A") +
labs(title = "Relação entre Mortalidade Infatil e Pesticidas na Ásia",
x = "Decisão de Banir ou Não os Pesticidas",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base_asia$IMR_total,base_asia$treated)
## [1] -0.4152492
ggplot(base_asia, aes(x = Pub_expend, y = IMR_total)) +
geom_point(color = "#00C19A") +
labs(title = "Relação entre Mortalidade Infatil e Gasto Público em Saúde na Ásia",
x = "Gastos Público de Saúde",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
ggplot(base_asia, aes(x = ton_prod_per_capita, y = IMR_total)) +
geom_point(color = "#00C19A") +
labs(title = "Relação entre Mortalidade Infatil e Produção per Capita de Cereais na Ásia",
x = "Produção per Capita de Cerais",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base_asia$IMR_total,base_asia$ton_prod_per_capita)
## [1] 0.1112601
ggplot(base_asia, aes(x = pop_rural_ratio, y = IMR_total)) +
geom_point(color = "#00C19A") +
labs(title = "Relação entre Mortalidade Infatil e Taxa de População Rural na Ásia",
x = "Taxa de População Rural",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base_asia$IMR_total,base_asia$pop_rural_ratio)
## [1] 0.7022314
#AMERICA:
base_america = filter(base, continente=="America") %>%
select(-Europa, -Africa, -Oceania, -Asia, - America, -continente) %>%
as.data.table()
#ANALISE DESCRITIVA:
stargazer(base_america, type="text", digits=4)
##
## ======================================================
## Statistic N Mean St. Dev. Min Max
## ------------------------------------------------------
## IMR_total 31 21.2129 12.3499 5.2000 66.8000
## treated 31 0.8065 0.4016 0 1
## Pub_expend 16 4.5253 1.8298 2.4995 10.2682
## ton_prod_per_capita 31 0.1120 0.1942 0.0001 1.0202
## log_ton_prod 31 7.8768 2.2069 2.7277 11.5329
## pop_rural_ratio 31 0.3766 0.1774 0.0692 0.7194
## ------------------------------------------------------
#ANALISE DAS DISTRIBUICOES:
ggplot(base_america, aes(x = IMR_total)) +
geom_histogram(fill = "red", bins = 30) +
labs(x = "Índice de Mortalidade Infantil", y = "Contagem", title = "Distribuição do IMR na América")
ggplot(base_america, aes(x = treated)) +
geom_histogram(fill = "orange", bins = 30) +
labs(x = "Tratamento", y = "Contagem", title = "Distribuição do Tratamento na América")
ggplot(base_america, aes(x = Pub_expend)) +
geom_histogram(fill = "blue", bins = 30) +
labs(x = "Gasto Público em Saúde", y = "Contagem", title = "Distribuição do Gasto Público em Saúde na América")
ggplot(base_america, aes(x = ton_prod_per_capita)) +
geom_histogram(fill = "green", bins = 30) +
labs(x = "Quantidade de Cereais Produzida per Capita", y = "Contagem", title = "Distribuição da Produção per Capita de Cereais na América")
ggplot(base_america, aes(x = pop_rural_ratio)) +
geom_histogram(fill = "black", bins = 30) +
labs(x = "Taxa de População Rural", y = "Contagem", title = "Distribuição da Taxa de População Rural na América")
#ANALISE DAS CORRELACOES:
ggplot(base_america, aes(x = treated, y = IMR_total)) +
geom_point(color = "#ABA300") +
labs(title = "Relação entre Mortalidade Infatil e Pesticidas na América",
x = "Decisão de Banir ou Não os Pesticidas",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base_america$IMR_total,base_america$treated)
## [1] -0.1701835
ggplot(base_america, aes(x = Pub_expend, y = IMR_total)) +
geom_point(color = "#ABA300") +
labs(title = "Relação entre Mortalidade Infatil e Gasto Público em Saúde na América",
x = "Gastos Público de Saúde",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
ggplot(base_america, aes(x = ton_prod_per_capita, y = IMR_total)) +
geom_point(color = "#ABA300") +
labs(title = "Relação entre Mortalidade Infatil e Produção per Capita de Cereais na América",
x = "Produção per Capita de Cerais",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base_america$IMR_total,base_america$ton_prod_per_capita)
## [1] -0.2581099
ggplot(base_america, aes(x = pop_rural_ratio, y = IMR_total)) +
geom_point(color = "#ABA300") +
labs(title = "Relação entre Mortalidade Infatil e Taxa de População Rural na América",
x = "Taxa de População Rural",
y = "Índice de Mortalidade Infantil") +
geom_smooth(method = lm)
cor(base_america$IMR_total,base_america$pop_rural_ratio)
## [1] 0.357869