Control de lectura - evaluacion

Prueba de significancia estadistica.

datos$diferencia <- datos[[3]] - datos[[2]]
shapiro.test(datos$diferencia)
## 
##  Shapiro-Wilk normality test
## 
## data:  datos$diferencia
## W = 0.96911, p-value = 0.04745
wilcox.test(datos[[3]], datos[[2]],
            paired = TRUE,
            alternative = "two.sided",
            exact = FALSE)
## 
##  Wilcoxon signed rank test with continuity correction
## 
## data:  datos[[3]] and datos[[2]]
## V = 2175.5, p-value = 4.837e-08
## alternative hypothesis: true location shift is not equal to 0
median(datos[[2]]) #Linea de entrada
## [1] 0.1753704
median(datos[[3]]) #Linea de salida
## [1] 0.3355556

Prueba de diferencia en diferencia

library(haven)
evaluation <- read_dta("D:/Documentos/Especializacion/Modulo 2/EjercicioR/evaluation.dta")

data_full <- evaluation
library (magrittr)
data<-data_full %>% tidyr::pivot_wider (
  names_from = round, values_from = c (
    "health_expenditures", "poverty_index", "age_hh", "age_sp",
    "educ_hh", "educ_sp", "female_hh", "indigenous", "hhsize",
    "dirtfloor", "bathroom", "land", "hospital_distance"
  )
) %>% dplyr::filter (!base::is.na (health_expenditures_0))
library(MatchIt)
model_lg2<-MatchIt::matchit (
  formula= enrolled ~age_hh_0+educ_hh_0+age_sp_0+educ_sp_0+
    female_hh_0+indigenous_0+hhsize_0+dirtfloor_0+bathroom_0+hospital_distance_0,
  data=data, distance = "glm", link ="logit",
  method = "nearest", replace = FALSE, ratio = 1
); model_lg2
## A matchit object
##  - method: 1:1 nearest neighbor matching without replacement
##  - distance: Propensity score
##              - estimated with logistic regression
##  - number of obs.: 9913 (original), 5928 (matched)
##  - target estimand: ATT
##  - covariates: age_hh_0, educ_hh_0, age_sp_0, educ_sp_0, female_hh_0, indigenous_0, hhsize_0, dirtfloor_0, bathroom_0, hospital_distance_0
library(modelr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
modelr::add_predictions (
  data= data, model = model_lg2$model, var = "pred",
  type = "response"
) %>% dplyr:: mutate (
  enrolled_lab = base ::ifelse (
    test = enrolled == 1, yes = "Si", no = "No"
  )
) %>% ggplot2::ggplot (
  mapping = ggplot2::aes (
    x=pred, colour = enrolled_lab, fill = enrolled_lab
  )
) + ggplot2::geom_density (alpha = 1/3)

data_ps2<- MatchIt::match.data (object = model_lg2)

data_ps2%>% dplyr::mutate (
  enrolled_lab = base::ifelse (
    test = enrolled == 1, yes = "Si", no = "No"
  )
) %>% ggplot2::ggplot (
  mapping = ggplot2::aes (
    x= distance, colour = enrolled_lab, fill=enrolled_lab
  )
) + ggplot2::geom_density (alpha = 1/3)

data_ps_dd2<- dplyr::left_join(
  x=data_ps2 %>% dplyr::select (
    household_identifier, weights
  ),
  y= data_full
)
## Joining with `by = join_by(household_identifier)`
model_ps_dd2<-stats::lm (
  data= data_ps_dd2,
  formula= health_expenditures ~ enrolled*round
); model_ps_dd2 %>% base::summary ()
## 
## Call:
## stats::lm(formula = health_expenditures ~ enrolled * round, data = data_ps_dd2)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -9.581 -4.461 -1.049  2.946 80.306 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     15.0616     0.1217 123.800  < 2e-16 ***
## enrolled        -0.5719     0.1721  -3.324  0.00089 ***
## round            2.7264     0.1721  15.846  < 2e-16 ***
## enrolled:round  -9.3763     0.2433 -38.535  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.624 on 11852 degrees of freedom
## Multiple R-squared:  0.2337, Adjusted R-squared:  0.2335 
## F-statistic:  1205 on 3 and 11852 DF,  p-value: < 2.2e-16

Respondiendo la Guía

1. Defina que es evaluacion

Para responder lo que es evaluacion se va a tomar lo mencionado en AEVAL 2009, en donde