practica DIRIGIDA de EXPLORACIÓN BIVARIADA. 1) descargar la tabla de aqui: https://en.wikipedia.org/wiki/Democracy_Index ahi esta la tabla de paises.

  1. Analizar la relacion entre El score (indice) y el continente

  2. Analizar la relacion entre Continente y Tipo de Regimen

  3. Analizar la relacion entre Participacion Politica y todas las otras componentes del indice (no analizar el indice)

library(htmltab)
AA=htmltab(doc="https://en.wikipedia.org/wiki/Democracy_Index",
           which='//*[@id="mw-content-text"]/div/table[2]')
names(AA)
##  [1] "Rank >> Rank"                                                    
##  [2] "Country >> Country"                                              
##  [3] "Score >> Score"                                                  
##  [4] "Electoral processand pluralism >> Electoral processand pluralism"
##  [5] "Functioning ofgovernment >> Functioning ofgovernment"            
##  [6] "Politicalparticipation >> Politicalparticipation"                
##  [7] "Politicalculture >> Politicalculture"                            
##  [8] "Civilliberties >> Civilliberties"                                
##  [9] "Regimetype >> Regimetype"                                        
## [10] "Continent >> Continent"
newNames=c("rank","country","score","electoral","funcioning","Participación","culture","civil","regimetype","continent")

names(AA)=newNames
str(AA)
## 'data.frame':    167 obs. of  10 variables:
##  $ rank         : chr  "1" "2" "3" "4" ...
##  $ country      : chr  " Norway" " Iceland" " Sweden" " New Zealand" ...
##  $ score        : chr  "9.87" "9.58" "9.39" "9.26" ...
##  $ electoral    : chr  "10.00" "10.00" "9.58" "10.00" ...
##  $ funcioning   : chr  "9.64" "9.29" "9.64" "9.29" ...
##  $ Participación: chr  "10.00" "8.89" "8.33" "8.89" ...
##  $ culture      : chr  "10.00" "10.00" "10.00" "8.13" ...
##  $ civil        : chr  "9.71" "9.71" "9.41" "10.00" ...
##  $ regimetype   : chr  "Full democracy" "Full democracy" "Full democracy" "Full democracy" ...
##  $ continent    : chr  "Europe" "Europe" "Europe" "Oceania" ...

1.EVITAR ESPACIOS EN BLANCO:

AA[,]=lapply(AA[,],trimws,whitespace="[\\h\\v]")

2.convirtiendo en v.C. nominal:

AA$continent=as.factor(AA$continent)

3.CONVIRTIENDO EN VARIABLE C.ORDINAL

table(AA$regimetype)
## 
##    Authoritarian Flawed democracy   Full democracy    Hybrid regime 
##               53               55               20               39

4.convirtiendo en V.NUMÉRICA

AA[,-c(2,9,10)]=lapply(AA[,-c(2,9,10)],as.numeric)

5.AJUSTANDO NIVELES

ordenOK=c("Authoritarian","Hybrid regime","Flawed democracy", "full democracy")

AA$regimetype=ordered(AA$regimetype,levels=
                        ordenOK)

6.EXPLORANDO valores PERDIDOS

AA[!complete.cases(AA),]
##    rank        country score electoral funcioning Participación culture
## 2     1         Norway  9.87     10.00       9.64         10.00   10.00
## 3     2        Iceland  9.58     10.00       9.29          8.89   10.00
## 4     3         Sweden  9.39      9.58       9.64          8.33   10.00
## 5     4    New Zealand  9.26     10.00       9.29          8.89    8.13
## 6     5        Denmark  9.22     10.00       9.29          8.33    9.38
## 7     6        Ireland  9.15      9.58       7.86          8.33   10.00
## 8     6         Canada  9.15      9.58       9.64          7.78    8.75
## 9     8        Finland  9.14     10.00       8.93          8.33    8.75
## 10    9      Australia  9.09     10.00       8.93          7.78    8.75
## 11   10    Switzerland  9.03      9.58       9.29          7.78    9.38
## 12   11    Netherlands  8.89      9.58       9.29          8.33    8.13
## 13   12     Luxembourg  8.81     10.00       8.93          6.67    8.75
## 14   13        Germany  8.68      9.58       8.57          8.33    7.50
## 15   14 United Kingdom  8.53      9.58       7.50          8.33    8.13
## 16   15        Uruguay  8.38     10.00       8.57          6.11    7.50
## 17   16        Austria  8.29      9.58       7.86          8.33    6.88
## 18   17      Mauritius  8.22      9.17       8.21          5.56    8.75
## 19   18          Malta  8.21      9.17       8.21          6.11    8.75
## 20   19          Spain  8.08      9.17       7.14          7.78    7.50
## 21   20     Costa Rica  8.07      9.58       7.50          6.67    7.50
##    civil regimetype     continent
## 2   9.71       <NA>        Europe
## 3   9.71       <NA>        Europe
## 4   9.41       <NA>        Europe
## 5  10.00       <NA>       Oceania
## 6   9.12       <NA>        Europe
## 7  10.00       <NA>        Europe
## 8  10.00       <NA> North America
## 9   9.71       <NA>        Europe
## 10 10.00       <NA>       Oceania
## 11  9.12       <NA>        Europe
## 12  9.12       <NA>        Europe
## 13  9.71       <NA>        Europe
## 14  9.41       <NA>        Europe
## 15  9.12       <NA>        Europe
## 16  9.71       <NA> South America
## 17  8.82       <NA>        Europe
## 18  9.41       <NA>        Africa
## 19  8.82       <NA>        Europe
## 20  8.82       <NA>        Europe
## 21  9.12       <NA> North America

7.desechar COLUMNA CON PERDIDOS

AA$rank=NULL

FINALMENTEEEEE RESUMEN ESTADÍSTICO

summary(AA)
##    country              score         electoral        funcioning   
##  Length:167         Min.   :1.080   Min.   : 0.000   Min.   :0.000  
##  Class :character   1st Qu.:3.545   1st Qu.: 3.000   1st Qu.:2.860  
##  Mode  :character   Median :5.690   Median : 6.580   Median :5.000  
##                     Mean   :5.479   Mean   : 5.903   Mean   :4.885  
##                     3rd Qu.:7.175   3rd Qu.: 9.170   3rd Qu.:6.790  
##                     Max.   :9.870   Max.   :10.000   Max.   :9.640  
##  Participación      culture           civil                   regimetype
##  Min.   : 1.11   Min.   : 1.250   Min.   : 0.000   Authoritarian   :53  
##  1st Qu.: 3.89   1st Qu.: 4.380   1st Qu.: 3.530   Hybrid regime   :39  
##  Median : 5.56   Median : 5.630   Median : 5.880   Flawed democracy:55  
##  Mean   : 5.25   Mean   : 5.594   Mean   : 5.768   full democracy  : 0  
##  3rd Qu.: 6.67   3rd Qu.: 6.250   3rd Qu.: 8.240   NA's            :20  
##  Max.   :10.00   Max.   :10.000   Max.   :10.000                        
##          continent 
##  Africa       :50  
##  Asia         :42  
##  Europe       :45  
##  North America:14  
##  Oceania      : 4  
##  South America:12
  1. Analizar la relacion entre El score (indice) y el continente numerica,CATEGORICA
f1=formula(score~continent)
aggregate(f1,AA,mean)
##       continent    score
## 1        Africa 4.289000
## 2          Asia 4.459762
## 3        Europe 7.025333
## 4 North America 6.276429
## 5       Oceania 7.557500
## 6 South America 6.576667

.HIPOTESIS No :NO hay diferencias entre medias.

.HIPÓTESIS en este caso: eN ESTE CASO SE OBSERVA QUE OCEANÍA PRESENTA MEJOR INDICE DE DEMOCRACIA QUE LOOS DEMÁS CONTINENTES. POR TANTO,SÍ hay diferencias entre medias,al parecer.

1.graficos

library(ggpubr)
## Loading required package: ggplot2
## Loading required package: magrittr
ggqqplot(data=AA,x="score") + facet_grid(. ~ continent)

LOS PUNTOS Se alejan de la diagonal,no hay normalidad.

Esto podría indicar que se requiere usar la prueba no parametrica…

2.PROBABILIDAD:shapiro WILK

normalidadTest=function(x) {y =shapiro.test(x); 
                            c(y$statistic, y$p.value)}

resultado= aggregate(f1, AA,
                     FUN = normalidadTest) 


library(knitr)

shapiroTest=as.data.frame(resultado[,2])
names(shapiroTest)=c("SW_Statistic","Probabilidad")
kable(cbind(resultado[1],shapiroTest))
continent SW_Statistic Probabilidad
Africa 0.9653422 0.1487353
Asia 0.9486915 0.0579857
Europe 0.9370922 0.0168389
North America 0.9740888 0.9260364
Oceania 0.7752667 0.0647579
South America 0.8433322 0.0304021
LAS PRBABILIDADE S DE 4 DE 6 CON TINENTES SON MAYORES A 0.05.No signifcativo.Usamos ,etonces,Prueba paramétrica

PRUEBA PARAMÉTRICA PARA politooooÓMICAS:

summary(aov(f1, data=AA))
##              Df Sum Sq Mean Sq F value   Pr(>F)    
## continent     5  262.7   52.54   15.65 1.52e-12 ***
## Residuals   161  540.3    3.36                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(ggpubr)
ggerrorplot(AA, x = "score", 
            y = "continent", 
            desc_stat = "mean_ci")
## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced

## Warning in stats::qt(ci/2 + 0.5, length - 1): NaNs produced
## Warning: Removed 155 rows containing missing values (geom_pointrange).

AA
##                              country score electoral funcioning
## 2                             Norway  9.87     10.00       9.64
## 3                            Iceland  9.58     10.00       9.29
## 4                             Sweden  9.39      9.58       9.64
## 5                        New Zealand  9.26     10.00       9.29
## 6                            Denmark  9.22     10.00       9.29
## 7                            Ireland  9.15      9.58       7.86
## 8                             Canada  9.15      9.58       9.64
## 9                            Finland  9.14     10.00       8.93
## 10                         Australia  9.09     10.00       8.93
## 11                       Switzerland  9.03      9.58       9.29
## 12                       Netherlands  8.89      9.58       9.29
## 13                        Luxembourg  8.81     10.00       8.93
## 14                           Germany  8.68      9.58       8.57
## 15                    United Kingdom  8.53      9.58       7.50
## 16                           Uruguay  8.38     10.00       8.57
## 17                           Austria  8.29      9.58       7.86
## 18                         Mauritius  8.22      9.17       8.21
## 19                             Malta  8.21      9.17       8.21
## 20                             Spain  8.08      9.17       7.14
## 21                        Costa Rica  8.07      9.58       7.50
## 22                       South Korea  8.00      9.17       7.86
## 23                             Japan  7.99      8.75       8.21
## 24                             Chile  7.97      9.58       8.57
## 25                           Estonia  7.97      9.58       8.21
## 26                     United States  7.96      9.17       7.14
## 27                        Cape Verde  7.88      9.17       7.86
## 28                          Portugal  7.84      9.58       7.50
## 29                          Botswana  7.81      9.17       7.14
## 30                            France  7.80      9.58       7.50
## 31                            Israel  7.79      9.17       7.50
## 32                           Belgium  7.78      9.58       8.93
## 33                            Taiwan  7.73      9.58       8.21
## 34                             Italy  7.71      9.58       6.07
## 35                    Czech Republic  7.69      9.58       6.79
## 36                            Cyprus  7.59      9.17       6.43
## 37                          Slovenia  7.50      9.58       6.79
## 38                         Lithuania  7.50      9.58       6.43
## 39                            Latvia  7.38      9.58       6.07
## 40                            Greece  7.29      9.58       5.36
## 41                      South Africa  7.24      7.42       7.50
## 42                             India  7.23      9.17       6.79
## 43                       Timor-Leste  7.19      9.08       6.79
## 44               Trinidad and Tobago  7.16      9.58       7.14
## 45                          Slovakia  7.10      9.58       6.79
## 46                            Panama  7.05      9.58       6.07
## 47                          Bulgaria  7.03      9.17       6.43
## 48                         Argentina  7.02      9.17       5.36
## 49                           Jamaica  7.02      8.75       7.14
## 50                          Suriname  6.98      9.17       6.43
## 51                            Brazil  6.97      9.58       5.36
## 52                          Colombia  6.96      9.17       6.79
## 53                          Malaysia  6.88      7.75       7.86
## 54                       Philippines  6.71      9.17       5.71
## 55                            Poland  6.67      9.17       6.07
## 56                            Guyana  6.67      9.17       5.71
## 57                           Lesotho  6.64      9.17       5.00
## 58                             Ghana  6.63      8.33       5.71
## 59                           Hungary  6.63      8.75       6.07
## 60                              Peru  6.60      9.17       5.00
## 61                           Croatia  6.57      9.17       6.07
## 62                Dominican Republic  6.54      9.17       5.36
## 63                          Mongolia  6.50      9.17       5.71
## 64                            Serbia  6.41      8.25       5.36
## 65                           Tunisia  6.41      6.42       5.71
## 66                         Indonesia  6.39      6.92       7.14
## 67                         Singapore  6.38      4.33       7.86
## 68                           Romania  6.38      9.17       5.71
## 69                           Ecuador  6.27      8.75       5.36
## 70                           Namibia  6.25      5.67       5.36
## 71                          Paraguay  6.24      8.75       5.71
## 72                         Sri Lanka  6.19      7.83       5.71
## 73                            Mexico  6.19      8.33       6.07
## 74                         Hong Kong  6.15      3.08       6.07
## 75                           Senegal  6.15      7.50       6.07
## 76                  Papua New Guinea  6.03      6.92       6.07
## 77                           Albania  5.98      7.00       4.71
## 78                       El Salvador  5.96      9.17       4.29
## 79                   North Macedonia  5.87      6.50       5.36
## 80                           Moldova  5.85      7.08       4.64
## 81                              Fiji  5.85      6.58       5.36
## 82                        Montenegro  5.74      6.08       5.36
## 83                             Benin  5.74      6.50       5.71
## 84                           Bolivia  5.70      7.50       4.64
## 85                           Ukraine  5.69      6.17       3.21
## 86                          Honduras  5.63      8.50       4.64
## 87                            Zambia  5.61      6.17       4.64
## 88                         Guatemala  5.60      7.92       5.36
## 89                        Bangladesh  5.57      7.83       5.07
## 90                           Georgia  5.50      7.83       3.57
## 91                            Malawi  5.49      6.58       4.29
## 92                          Tanzania  5.41      7.00       5.00
## 93                              Mali  5.41      7.42       3.93
## 94                           Liberia  5.35      7.42       2.57
## 95                            Bhutan  5.30      8.75       6.79
## 96                        Madagascar  5.22      6.08       3.57
## 97                            Uganda  5.20      5.25       3.57
## 98                             Nepal  5.18      4.33       5.36
## 99                             Kenya  5.11      3.50       5.36
## 100                       Kyrgyzstan  5.11      6.58       2.93
## 101                          Morocco  4.99      5.25       4.64
## 102           Bosnia and Herzegovina  4.98      6.50       2.93
## 103                            Haiti  4.91      5.58       2.93
## 104                          Armenia  4.79      5.67       4.64
## 105                     Burkina Faso  4.75      4.42       4.29
## 106                     Sierra Leone  4.66      6.58       1.86
## 107                          Lebanon  4.63      3.92       2.21
## 108                         Thailand  4.63      3.00       4.29
## 109                          Nigeria  4.44      6.08       4.64
## 110                        Palestine  4.39      3.83       2.14
## 111                           Turkey  4.37      4.50       5.00
## 112                           Gambia  4.31      4.48       4.29
## 113                         Pakistan  4.17      6.08       5.36
## 114                      Ivory Coast  4.15      4.83       2.86
## 115                             Iraq  4.06      4.75       0.07
## 116                           Jordan  3.93      3.58       4.29
## 117                       Mozambique  3.85      3.58       2.14
## 118                           Kuwait  3.85      3.17       4.29
## 119                          Myanmar  3.83      3.67       3.93
## 120                       Mauritania  3.82      3.00       3.57
## 121                            Niger  3.76      5.25       1.14
## 122                          Comoros  3.71      4.33       2.21
## 123                        Nicaragua  3.63      2.67       1.86
## 124                           Angola  3.62      1.75       2.86
## 125                            Gabon  3.61      2.58       2.21
## 126                         Cambodia  3.59      1.33       5.00
## 127                          Algeria  3.50      2.58       2.21
## 128                            Egypt  3.36      3.58       3.21
## 129                         Ethiopia  3.35      0.00       3.57
## 130                           Rwanda  3.35      1.67       5.00
## 131                            China  3.32      0.00       5.00
## 132            Republic of the Congo  3.31      3.17       2.50
## 133                         Cameroon  3.28      3.17       2.86
## 134                            Qatar  3.19      0.00       4.29
## 135                         Zimbabwe  3.16      0.50       2.00
## 136                        Venezuela  3.16      1.67       1.79
## 137                           Guinea  3.14      3.50       0.43
## 138                          Belarus  3.13      0.92       2.86
## 139                             Togo  3.10      3.17       0.79
## 140                          Vietnam  3.08      0.00       3.21
## 141                             Oman  3.04      0.00       3.93
## 142                         Eswatini  3.03      0.92       2.86
## 143                             Cuba  3.00      1.08       3.57
## 144                      Afghanistan  2.97      2.92       1.14
## 145                       Kazakhstan  2.94      0.50       2.14
## 146                           Russia  2.94      2.17       1.79
## 147                         Djibouti  2.87      0.42       1.79
## 148             United Arab Emirates  2.76      0.00       3.93
## 149                          Bahrain  2.71      0.83       3.21
## 150                       Azerbaijan  2.65      0.50       2.14
## 151                             Iran  2.45      0.00       3.21
## 152                          Eritrea  2.37      0.00       2.14
## 153                             Laos  2.37      0.83       2.86
## 154                          Burundi  2.33      0.00       0.43
## 155                            Libya  2.19      1.00       0.36
## 156                            Sudan  2.15      0.00       1.79
## 157                       Uzbekistan  2.01      0.08       1.86
## 158                    Guinea-Bissau  1.98      1.67       0.00
## 159                            Yemen  1.95      0.00       0.00
## 160                     Saudi Arabia  1.93      0.00       2.86
## 161                       Tajikistan  1.93      0.08       0.79
## 162                Equatorial Guinea  1.92      0.00       0.43
## 163                     Turkmenistan  1.72      0.00       0.79
## 164                             Chad  1.61      0.00       0.00
## 165         Central African Republic  1.52      2.25       0.00
## 166 Democratic Republic of the Congo  1.49      0.50       0.71
## 167                            Syria  1.43      0.00       0.00
## 168                      North Korea  1.08      0.00       2.50
##     Participación culture civil       regimetype     continent
## 2           10.00   10.00  9.71             <NA>        Europe
## 3            8.89   10.00  9.71             <NA>        Europe
## 4            8.33   10.00  9.41             <NA>        Europe
## 5            8.89    8.13 10.00             <NA>       Oceania
## 6            8.33    9.38  9.12             <NA>        Europe
## 7            8.33   10.00 10.00             <NA>        Europe
## 8            7.78    8.75 10.00             <NA> North America
## 9            8.33    8.75  9.71             <NA>        Europe
## 10           7.78    8.75 10.00             <NA>       Oceania
## 11           7.78    9.38  9.12             <NA>        Europe
## 12           8.33    8.13  9.12             <NA>        Europe
## 13           6.67    8.75  9.71             <NA>        Europe
## 14           8.33    7.50  9.41             <NA>        Europe
## 15           8.33    8.13  9.12             <NA>        Europe
## 16           6.11    7.50  9.71             <NA> South America
## 17           8.33    6.88  8.82             <NA>        Europe
## 18           5.56    8.75  9.41             <NA>        Africa
## 19           6.11    8.75  8.82             <NA>        Europe
## 20           7.78    7.50  8.82             <NA>        Europe
## 21           6.67    7.50  9.12             <NA> North America
## 22           7.22    7.50  8.24 Flawed democracy          Asia
## 23           6.67    7.50  8.82 Flawed democracy          Asia
## 24           4.44    8.13  9.12 Flawed democracy South America
## 25           6.67    6.88  8.53 Flawed democracy        Europe
## 26           7.78    7.50  8.24 Flawed democracy North America
## 27           6.67    6.88  8.82 Flawed democracy        Africa
## 28           6.11    6.88  9.12 Flawed democracy        Europe
## 29           6.11    7.50  9.12 Flawed democracy        Africa
## 30           7.78    5.63  8.53 Flawed democracy        Europe
## 31           8.89    7.50  5.88 Flawed democracy          Asia
## 32           5.00    6.88  8.53 Flawed democracy        Europe
## 33           6.11    5.63  9.12 Flawed democracy          Asia
## 34           7.78    6.88  8.24 Flawed democracy        Europe
## 35           6.67    6.88  8.53 Flawed democracy        Europe
## 36           6.67    6.88  8.82 Flawed democracy        Europe
## 37           6.67    6.25  8.24 Flawed democracy        Europe
## 38           6.11    6.25  9.12 Flawed democracy        Europe
## 39           5.56    6.88  8.82 Flawed democracy        Europe
## 40           6.11    6.88  8.53 Flawed democracy        Europe
## 41           8.33    5.00  7.94 Flawed democracy        Africa
## 42           7.22    5.63  7.35 Flawed democracy          Asia
## 43           5.56    6.88  7.65 Flawed democracy          Asia
## 44           6.11    5.63  7.35 Flawed democracy North America
## 45           5.56    5.63  7.94 Flawed democracy        Europe
## 46           6.67    5.00  7.94 Flawed democracy North America
## 47           7.22    4.38  7.94 Flawed democracy        Europe
## 48           6.11    6.25  8.24 Flawed democracy South America
## 49           4.44    6.25  8.53 Flawed democracy North America
## 50           6.67    5.00  7.65 Flawed democracy South America
## 51           6.67    5.00  8.24 Flawed democracy South America
## 52           5.00    5.63  8.24 Flawed democracy South America
## 53           6.67    6.25  5.88 Flawed democracy          Asia
## 54           7.22    4.38  7.06 Flawed democracy          Asia
## 55           6.11    4.38  7.65 Flawed democracy        Europe
## 56           6.11    5.00  7.35 Flawed democracy South America
## 57           6.67    5.63  6.76 Flawed democracy        Africa
## 58           6.67    6.25  6.18 Flawed democracy        Africa
## 59           5.00    6.25  7.06 Flawed democracy        Europe
## 60           5.56    5.63  7.65 Flawed democracy South America
## 61           5.56    5.00  7.06 Flawed democracy        Europe
## 62           6.11    5.00  7.06 Flawed democracy North America
## 63           5.56    5.00  7.06 Flawed democracy          Asia
## 64           6.11    5.00  7.35 Flawed democracy        Europe
## 65           7.78    6.25  5.88 Flawed democracy        Africa
## 66           6.67    5.63  5.59 Flawed democracy          Asia
## 67           6.11    6.25  7.35 Flawed democracy          Asia
## 68           5.00    4.38  7.65 Flawed democracy        Europe
## 69           6.11    4.38  6.76 Flawed democracy South America
## 70           6.67    5.63  7.94 Flawed democracy        Africa
## 71           5.00    4.38  7.35 Flawed democracy South America
## 72           5.00    6.25  6.18 Flawed democracy          Asia
## 73           7.22    3.13  6.18 Flawed democracy North America
## 74           5.56    7.50  8.53 Flawed democracy          Asia
## 75           4.44    6.25  6.47 Flawed democracy        Africa
## 76           3.89    5.63  7.65 Flawed democracy       Oceania
## 77           5.56    5.00  7.65    Hybrid regime        Europe
## 78           5.56    3.75  7.06    Hybrid regime North America
## 79           6.67    3.75  7.06    Hybrid regime        Europe
## 80           6.11    4.38  7.06    Hybrid regime        Europe
## 81           6.11    5.63  5.59    Hybrid regime       Oceania
## 82           6.11    4.38  6.76    Hybrid regime        Europe
## 83           5.00    5.63  5.88    Hybrid regime        Africa
## 84           5.56    3.75  7.06    Hybrid regime South America
## 85           6.67    6.25  6.18    Hybrid regime        Europe
## 86           4.44    4.38  6.18    Hybrid regime North America
## 87           3.89    6.88  6.47    Hybrid regime        Africa
## 88           3.89    4.38  6.47    Hybrid regime North America
## 89           5.56    4.38  5.00    Hybrid regime          Asia
## 90           6.11    4.38  5.59    Hybrid regime        Europe
## 91           4.44    6.25  5.88    Hybrid regime        Africa
## 92           5.00    5.63  4.41    Hybrid regime        Africa
## 93           3.89    5.63  6.18    Hybrid regime        Africa
## 94           5.56    5.63  5.59    Hybrid regime        Africa
## 95           2.78    4.38  3.82    Hybrid regime          Asia
## 96           6.11    5.63  4.71    Hybrid regime        Africa
## 97           4.44    6.88  5.88    Hybrid regime        Africa
## 98           5.00    5.63  5.59    Hybrid regime          Asia
## 99           6.67    5.63  4.41    Hybrid regime        Africa
## 100          6.67    4.38  5.00    Hybrid regime          Asia
## 101          5.00    5.63  4.41    Hybrid regime        Africa
## 102          5.56    3.75  6.18    Hybrid regime        Europe
## 103          3.89    6.25  5.88    Hybrid regime North America
## 104          5.56    2.50  5.59    Hybrid regime        Europe
## 105          4.44    5.63  5.00    Hybrid regime        Africa
## 106          3.33    6.25  5.29    Hybrid regime        Africa
## 107          6.67    5.63  4.71    Hybrid regime          Asia
## 108          5.00    5.00  5.88    Hybrid regime          Asia
## 109          3.33    3.75  4.41    Hybrid regime        Africa
## 110          7.78    4.38  3.82    Hybrid regime          Asia
## 111          5.00    5.00  2.35    Hybrid regime        Europe
## 112          3.33    5.63  3.82    Hybrid regime        Africa
## 113          2.22    2.50  4.71    Hybrid regime          Asia
## 114          3.33    5.63  4.12    Hybrid regime        Africa
## 115          6.67    5.00  3.82    Hybrid regime          Asia
## 116          3.89    4.38  3.53    Authoritarian          Asia
## 117          5.00    5.00  3.53    Authoritarian        Africa
## 118          3.89    4.38  3.53    Authoritarian          Asia
## 119          3.89    5.63  2.06    Authoritarian          Asia
## 120          5.00    3.13  4.41    Authoritarian        Africa
## 121          3.33    4.38  4.71    Authoritarian        Africa
## 122          4.44    3.75  3.82    Authoritarian        Africa
## 123          3.89    5.63  4.12    Authoritarian North America
## 124          5.56    5.00  2.94    Authoritarian        Africa
## 125          4.44    5.00  3.82    Authoritarian        Africa
## 126          2.78    5.63  3.24    Authoritarian          Asia
## 127          3.89    5.00  3.82    Authoritarian        Africa
## 128          3.33    3.75  2.94    Authoritarian        Africa
## 129          5.56    5.00  2.65    Authoritarian        Africa
## 130          2.78    4.38  2.94    Authoritarian        Africa
## 131          3.89    6.25  1.47    Authoritarian          Asia
## 132          3.89    3.75  3.24    Authoritarian        Africa
## 133          3.33    4.38  2.65    Authoritarian        Africa
## 134          2.22    5.63  3.82    Authoritarian          Asia
## 135          4.44    5.63  3.24    Authoritarian        Africa
## 136          4.44    4.38  3.53    Authoritarian South America
## 137          4.44    4.38  2.94    Authoritarian        Africa
## 138          3.89    5.63  2.35    Authoritarian        Europe
## 139          3.33    5.00  3.24    Authoritarian        Africa
## 140          3.89    5.63  2.65    Authoritarian          Asia
## 141          2.78    4.38  4.12    Authoritarian          Asia
## 142          2.22    5.63  3.53    Authoritarian        Africa
## 143          3.33    4.38  2.65    Authoritarian North America
## 144          4.44    2.50  3.82    Authoritarian          Asia
## 145          4.44    4.38  3.24    Authoritarian        Europe
## 146          5.00    2.50  3.24    Authoritarian        Europe
## 147          3.89    5.63  2.65    Authoritarian        Africa
## 148          2.22    5.00  2.65    Authoritarian          Asia
## 149          2.78    4.38  2.35    Authoritarian          Asia
## 150          3.33    3.75  3.53    Authoritarian        Europe
## 151          4.44    3.13  1.47    Authoritarian          Asia
## 152          1.67    6.88  1.18    Authoritarian        Africa
## 153          1.67    5.00  1.47    Authoritarian          Asia
## 154          3.89    5.00  2.35    Authoritarian        Africa
## 155          1.67    5.00  2.94    Authoritarian        Africa
## 156          2.78    5.00  1.18    Authoritarian        Africa
## 157          2.22    5.00  0.88    Authoritarian          Asia
## 158          2.78    3.13  2.35    Authoritarian        Africa
## 159          3.89    5.00  0.88    Authoritarian          Asia
## 160          2.22    3.13  1.47    Authoritarian          Asia
## 161          1.67    6.25  0.88    Authoritarian          Asia
## 162          3.33    4.38  1.47    Authoritarian        Africa
## 163          2.22    5.00  0.59    Authoritarian          Asia
## 164          1.67    3.75  2.65    Authoritarian        Africa
## 165          1.11    1.88  2.35    Authoritarian        Africa
## 166          2.22    3.13  0.88    Authoritarian        Africa
## 167          2.78    4.38  0.00    Authoritarian          Asia
## 168          1.67    1.25  0.00    Authoritarian          Asia
ggplot(data=AA,aes(x=continent, y=score)) + geom_boxplot(notch = TRUE)
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.

  1. Analizar la relacion entre Continente y Tipo de Regimen

CATEGÓRICA,CATEGÓRICA

columna=AA$continent

fila=AA$regimetype

(t=table(fila,columna))
##                   columna
## fila               Africa Asia Europe North America Oceania South America
##   Authoritarian        26   20      4             2       0             1
##   Hybrid regime        15    9      9             4       1             1
##   Flawed democracy      8   13     18             6       1             9
##   full democracy        0    0      0             0       0             0
prop_t=prop.table(t,margin = 2)
round(prop_t,2)
##                   columna
## fila               Africa Asia Europe North America Oceania South America
##   Authoritarian      0.53 0.48   0.13          0.17    0.00          0.09
##   Hybrid regime      0.31 0.21   0.29          0.33    0.50          0.09
##   Flawed democracy   0.16 0.31   0.58          0.50    0.50          0.82
##   full democracy     0.00 0.00   0.00          0.00    0.00          0.00

gráfico del %

library("gplots")
## 
## Attaching package: 'gplots'
## The following object is masked from 'package:stats':
## 
##     lowess
balloonplot(t(prop_t), main ="tabla",
            label =T, show.margins = FALSE)

chisq.test(t,simulate.p.value = T)
## Warning in chisq.test(t, simulate.p.value = T): cannot compute simulated p-
## value with zero marginals
## Warning in chisq.test(t, simulate.p.value = T): Chi-squared approximation
## may be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  t
## X-squared = NaN, df = 15, p-value = NA