Aula 1 - Estatística 2024-2

Author

VPI

Estudo do pacote pinochet

Abrindo e exibindo o banco de dados

library(pinochet)
head(pinochet)
  individual_id group_id start_date_daily end_date_daily start_date_monthly
1             1        1       1973-09-12     1973-09-12         1973-09-01
2             2        2       1973-09-11     1973-09-12         1973-09-01
3             3        3       1973-09-12     1973-09-12         1973-09-01
4             4        4       1973-09-12     1973-09-14         1973-09-01
5             5        5       1973-09-12     1973-09-12         1973-09-01
6             6        6       1973-09-12     1973-09-12         1973-09-01
  end_date_monthly            last_name         first_name minor age male
1       1973-09-01      Corredera Reyes Mercedes del Pilar     1  NA    0
2       1973-09-01        Torres Torres   Benito Heriberto     0  57    1
3       1973-09-01         Lira Morales        Juan Manuel     0  23    1
4       1973-09-01       Fontela Alonso    Alberto Mariano     0  26    1
5       1973-09-01 Quintilliano Cardozo      Tulio Roberto     0  29    1
6       1973-09-01      Norambuena Cruz       Sonia Isaura     0  34    0
      occupation  occupation_detail victim_affiliation
1 School Student        high school               <NA>
2    Blue Collar plumbing installer               <NA>
3   White Collar      office worker               <NA>
4    Blue Collar    small fisherman               <NA>
5    Blue Collar           engineer         Opposition
6     Unemployed          homemaker               <NA>
  victim_affiliation_detail      violence method interrogation torture
1                      <NA>        Killed    Gun            NA      NA
2                      <NA>        Killed    Gun            NA      NA
3                      <NA>        Killed    Gun             0       0
4                      <NA> Disappearance   <NA>            NA      NA
5           Communist party Disappearance   <NA>             1      NA
6                      <NA>        Killed    Gun             0       0
  mistreatment targeted press war_tribunal number_previous_arrests
1           NA     <NA>     0            0                      NA
2           NA     <NA>     0            0                      NA
3           NA     <NA>     0            0                      NA
4           NA     <NA>     0            0                      NA
5           NA     <NA>     0            0                      NA
6           NA     <NA>     0            0                      NA
  perpetrator_affiliation perpetrator_affiliation_detail nationality    place_1
1                    <NA>                           <NA>     Chilean  In Public
2                  Regime                      Policemen     Chilean       Home
3                  Regime                      Military      Chilean  In Public
4                  Regime     Military (Tacna Regiment)      Chilean In Custody
5                  Regime                      Military      Chilean In Custody
6                  Regime                      Military      Chilean  In Public
                                location_1 latitude_1 longitude_1
1                       Calle Gran Avenida  -33.50134   -70.65424
2                                 Santiago  -33.44889   -70.66927
3                      La Legua shantytown  -33.48722   -70.63556
4                           Tacna Regiment  -33.59648   -70.70457
5                         Military Academy  -33.41154   -70.58421
6 Ochagavia Bridge over Callejón Lo Ovalle  -33.51556   -70.65333
  exact_coordinates_1     place_2
1                   0 In Hospital
2                   0  In Custody
3                   0 In Hospital
4                   1        <NA>
5                   1        <NA>
6                   0   In Public
                                             location_2 latitude_2 longitude_2
1 Medical Legal Institute (by the Barros Luco Hospital)  -33.48412   -70.64641
2                       Towards the 26th police station  -33.44785   -70.73953
3                                  Barros Luco Hospital  -33.48412   -70.64641
4                                                  <NA>         NA          NA
5                                                  <NA>         NA          NA
6              Ochagavia Bridge over Callejón Lo Ovalle  -33.51556   -70.65333
  exact_coordinates_2   place_3              location_3 latitude_3 longitude_3
1                   1      <NA>                    <NA>         NA          NA
2                   0 In Public found in Las Barrancas   -33.44222   -70.75389
3                   1      <NA>                    <NA>         NA          NA
4                  NA      <NA>                    <NA>         NA          NA
5                  NA      <NA>                    <NA>         NA          NA
6                   0      <NA>                    <NA>         NA          NA
  exact_coordinates_3 place_4 location_4 latitude_4 longitude_4
1                  NA    <NA>       <NA>         NA          NA
2                   0    <NA>       <NA>         NA          NA
3                  NA    <NA>       <NA>         NA          NA
4                  NA    <NA>       <NA>         NA          NA
5                  NA    <NA>       <NA>         NA          NA
6                  NA    <NA>       <NA>         NA          NA
  exact_coordinates_4 place_5 location_5 latitude_5 longitude_5
1                  NA    <NA>       <NA>         NA          NA
2                  NA    <NA>       <NA>         NA          NA
3                  NA    <NA>       <NA>         NA          NA
4                  NA    <NA>       <NA>         NA          NA
5                  NA    <NA>       <NA>         NA          NA
6                  NA    <NA>       <NA>         NA          NA
  exact_coordinates_5 place_6 location_6 latitude_6 longitude_6
1                  NA    <NA>       <NA>         NA          NA
2                  NA    <NA>       <NA>         NA          NA
3                  NA    <NA>       <NA>         NA          NA
4                  NA    <NA>       <NA>         NA          NA
5                  NA    <NA>       <NA>         NA          NA
6                  NA    <NA>       <NA>         NA          NA
  exact_coordinates_6   page additional_comments
1                  NA    159                <NA>
2                  NA 159-60                <NA>
3                  NA    160                <NA>
4                  NA    160                <NA>
5                  NA 160-61                <NA>
6                  NA    161                <NA>

Variáveis qualitativas

Nominais

# Varíaveis qualitativas nominais ---
# Male
table(pinochet$male)

   0    1 
 101 2232 
barplot(table(pinochet$male))

# victim_affiliation
tb = table(pinochet$victim_affiliation)
tb

      None Opposition     Regime 
       135       1287         31 
prop.table(tb)

      None Opposition     Regime 
0.09291122 0.88575361 0.02133517 
barplot(tb)

pie(tb)

O que dá errado!

Variáveis com muitas categorias

tb = table(pinochet$occupation)
tb

                             Blue Collar 
                                     896 
             Blue Collar and Ex-Military 
                                       1 
 Blue Collar and Non-military Government 
                                       3 
          Blue Collar and School Student 
                                       1 
      Blue Collar and University Student 
                                       4 
            Blue Collar and White Collar 
                                       5 
                             Ex-Military 
                                       5 
                               Housewife 
                                       8 
                                Military 
                                      59 
                 Non-military Government 
                                     151 
 Non-military Government and Ex-Military 
                                       2 
                          School Student 
                                      88 
                              Unemployed 
                                      15 
                      University Student 
                                     140 
                            White Collar 
                                     429 
               White Collar and Military 
                                       1 
White Collar and Non-military Government 
                                       5 
     White Collar and University Student 
                                       7 
barplot(tb)

pie(tb)

Melhor usar

tb = table(pinochet$violence)
tb

                      Disappearance Disappearance, Information of Death 
                                853                                 108 
                             Killed                             Suicide 
                               1331                                   8 
                         Unresolved 
                                 93 
prop.table(tb)

                      Disappearance Disappearance, Information of Death 
                        0.356456331                         0.045131634 
                             Killed                             Suicide 
                        0.556205600                         0.003343084 
                         Unresolved 
                        0.038863351 
barplot(tb, main='Gráfico de barras', xlab='Violência', 
        ylab='Frequência', cex.names = 0.6,
        col='lightblue')

pie(tb, main='Gráfico de pizza')