Introdução

Este relatório apresenta os resultados de uma regressão linear múltipla para explicar o Índice de Desenvolvimento Humano (IDH) de Angola no período de 2010-2022, utilizando indicadores socioeconômicos como variáveis explicativas.

Modelo Estimado

# Carregar pacotes
library("readxl")
library("ggplot2")
library("broom")   # organiza resultados da regressão

# Importando os dados
caminho_dados = "Dados para Monografia.xlsx"
excel_sheets(caminho_dados)
## [1] "Dados"
df = read_excel(caminho_dados, sheet = "Dados")

# Explorando os dados
head(df)
## # A tibble: 6 × 6
##     Ano   IDH Expectativa_Vida RNB_per_capita_PPP Índice_Corrupção
##   <dbl> <dbl>            <dbl>              <dbl>            <dbl>
## 1  2010 0.516             56.7               5970               19
## 2  2011 0.533             57.6               6130               20
## 3  2012 0.545             58.6               6760               22
## 4  2013 0.555             59.3               7010               23
## 5  2014 0.565             60.0               7500               19
## 6  2015 0.591             60.7               6760               15
## # ℹ 1 more variable: Anos_Médios_Escolaridade <chr>
tail(df)
## # A tibble: 6 × 6
##     Ano   IDH Expectativa_Vida RNB_per_capita_PPP Índice_Corrupção
##   <dbl> <dbl>            <dbl>              <dbl>            <dbl>
## 1  2017 0.597             61.7               6560               19
## 2  2018 0.598             62.1               6780               19
## 3  2019 0.597             62.4               6850               26
## 4  2020 0.594             62.3               5870               27
## 5  2021 0.591             61.6               6800               29
## 6  2022 0.591             61.9               7310               33
## # ℹ 1 more variable: Anos_Médios_Escolaridade <chr>
str(df)
## tibble [13 × 6] (S3: tbl_df/tbl/data.frame)
##  $ Ano                     : num [1:13] 2010 2011 2012 2013 2014 ...
##  $ IDH                     : num [1:13] 0.516 0.533 0.545 0.555 0.565 0.591 0.595 0.597 0.598 0.597 ...
##  $ Expectativa_Vida        : num [1:13] 56.7 57.6 58.6 59.3 60 ...
##  $ RNB_per_capita_PPP      : num [1:13] 5970 6130 6760 7010 7500 6760 6490 6560 6780 6850 ...
##  $ Índice_Corrupção        : num [1:13] 19 20 22 23 19 15 18 19 19 26 ...
##  $ Anos_Médios_Escolaridade: chr [1:13] "3.8283973" "3.868798" "3.9091985" "3.9495993" ...
# Limpando os dados
df$Anos_Médios_Escolaridade = as.numeric(df$Anos_Médios_Escolaridade)
str(df$Anos_Médios_Escolaridade)
##  num [1:13] 3.83 3.87 3.91 3.95 3.99 ...
# Ajustar o modelo
modelo <- lm(IDH ~ Expectativa_Vida + RNB_per_capita_PPP +
               Anos_Médios_Escolaridade + Índice_Corrupção,
             data = df)

# Resumo do modelo
summary(modelo)
## 
## Call:
## lm(formula = IDH ~ Expectativa_Vida + RNB_per_capita_PPP + Anos_Médios_Escolaridade + 
##     Índice_Corrupção, data = df)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0057413 -0.0021444  0.0006461  0.0019165  0.0052488 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              -1.487e-01  8.721e-02  -1.705 0.126575    
## Expectativa_Vida          1.099e-02  1.913e-03   5.745 0.000431 ***
## RNB_per_capita_PPP        4.938e-06  3.149e-06   1.568 0.155515    
## Anos_Médios_Escolaridade  1.041e-02  3.923e-03   2.653 0.029128 *  
## Índice_Corrupção         -1.180e-03  2.620e-04  -4.505 0.001989 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.004043 on 8 degrees of freedom
## Multiple R-squared:  0.9865, Adjusted R-squared:  0.9797 
## F-statistic: 145.9 on 4 and 8 DF,  p-value: 1.655e-07
# Tabela organizada dos coeficientes
tidy(modelo)
## # A tibble: 5 × 5
##   term                        estimate  std.error statistic  p.value
##   <chr>                          <dbl>      <dbl>     <dbl>    <dbl>
## 1 (Intercept)              -0.149      0.0872         -1.71 0.127   
## 2 Expectativa_Vida          0.0110     0.00191         5.74 0.000431
## 3 RNB_per_capita_PPP        0.00000494 0.00000315      1.57 0.156   
## 4 Anos_Médios_Escolaridade  0.0104     0.00392         2.65 0.0291  
## 5 Índice_Corrupção         -0.00118    0.000262       -4.50 0.00199
# Estatísticas de qualidade do modelo
glance(modelo)
## # A tibble: 1 × 12
##   r.squared adj.r.squared   sigma statistic     p.value    df logLik   AIC   BIC
##       <dbl>         <dbl>   <dbl>     <dbl>       <dbl> <dbl>  <dbl> <dbl> <dbl>
## 1     0.986         0.980 0.00404      146. 0.000000165     4   56.4 -101. -97.3
## # ℹ 3 more variables: deviance <dbl>, df.residual <int>, nobs <int>
coef_df <- tidy(modelo, conf.int = TRUE)

ggplot(coef_df, aes(x = estimate, y = term)) +
  geom_point(color = "steelblue", size = 3) +
  geom_errorbarh(aes(xmin = conf.low, xmax = conf.high),
                 height = 0.2, color = "darkgray") +
  labs(title = "Coeficientes da Regressão com Intervalos de Confiança",
       x = "Efeito estimado", y = "") +
  theme_minimal()

# Previsões

## Previsões para os próprios dados (in-sample)
# Gerar previsões para os dados usados no modelo
df$IDH_Previsto <- predict(modelo)

# Mostrar primeiras linhas
head(df[, c("IDH", "IDH_Previsto")])
## # A tibble: 6 × 2
##     IDH IDH_Previsto
##   <dbl>        <dbl>
## 1 0.516        0.521
## 2 0.533        0.531
## 3 0.545        0.544
## 4 0.555        0.552
## 5 0.565        0.567
## 6 0.591        0.589
# Criar novos cenários hipotéticos
novos_dados <- data.frame(
  Expectativa_Vida = c(72, 80),
  RNB_per_capita_PPP = c(15000, 25000),
  Anos_Médios_Escolaridade = c(8, 12),
  Índice_Corrupção = c(0.35, 0.20)
)

# Fazer previsão com intervalos de confiança
predict(modelo, newdata = novos_dados, interval = "confidence")
##         fit       lwr       upr
## 1 0.7993376 0.7434522 0.8552229
## 2 0.9784221 0.8522082 1.1046360
# Tabela com previsões + intervalos
prev <- as.data.frame(predict(modelo, newdata = novos_dados,
                              interval = "prediction"))
cbind(novos_dados, prev)
##   Expectativa_Vida RNB_per_capita_PPP Anos_Médios_Escolaridade Índice_Corrupção
## 1               72              15000                        8             0.35
## 2               80              25000                       12             0.20
##         fit       lwr       upr
## 1 0.7993376 0.7426799 0.8559952
## 2 0.9784221 0.8518644 1.1049799
# Gráfico simples IDH Previsto-Expectativa de Vida
library(ggplot2)
ggplot(cbind(novos_dados, prev), aes(x = Expectativa_Vida, y = fit)) +
  geom_point(color = "blue", size = 3) +
  geom_errorbar(aes(ymin = lwr, ymax = upr), width = 0.2) +
  labs(title = "Previsões de IDH para Novos Cenários",
       x = "Expectativa de Vida", y = "IDH Previsto") +
  theme_minimal()

# Gráfico simples IDH Previsto-RNB_per_capita_PPP
library(ggplot2)
ggplot(cbind(novos_dados, prev), aes(x = RNB_per_capita_PPP, y = fit)) +
  geom_point(color = "blue", size = 3) +
  geom_errorbar(aes(ymin = lwr, ymax = upr), width = 0.2) +
  labs(title = "Previsões de IDH para Novos Cenários",
       x = "RNB_per_capita_PPP", y = "IDH Previsto") +
  theme_minimal()

# Gráfico simples IDH Previsto-Anos_Médios_Escolaridade 
library(ggplot2)
ggplot(cbind(novos_dados, prev), aes(x = Anos_Médios_Escolaridade, y = fit)) +
  geom_point(color = "blue", size = 3) +
  geom_errorbar(aes(ymin = lwr, ymax = upr), width = 0.2) +
  labs(title = "Previsões de IDH para Novos Cenários",
       x = "Anos_Médios_Escolaridade", y = "IDH Previsto") +
  theme_minimal()

# Gráfico simples IDH Previsto-Índice_Corrupção
library(ggplot2)
ggplot(cbind(novos_dados, prev), aes(x = Índice_Corrupção, y = fit)) +
  geom_point(color = "blue", size = 3) +
  geom_errorbar(aes(ymin = lwr, ymax = upr), width = 0.2) +
  labs(title = "Previsões de IDH para Novos Cenários",
       x = "Índice_Corrupção", y = "IDH Previsto") +
  theme_minimal()