library(foreign) library(dplyr) data_URL <- "https://github.com/Jeshua-Romero-Guadarrama/Econoalgoritmia/tree/main/data/fastfood.dta?raw=true" dat <- read.dta(data_URL) dat <- dat %>% mutate(FTE = nmgrs + empft + (0.5 * emppt), FTE2 = nmgrs2 + empft2 + (0.5 * emppt2)) dat_NJ <- subset(dat, state == 1) dat_PA <- subset(dat, state == 0) reg_dat <- data.frame( rbind( data.frame(id = dat$sheet, chain = dat$chain, state = dat$state, empl = dat$FTE, D = 0), data.frame(id = dat$sheet, chain = dat$chain, state = dat$state, empl = dat$FTE2, D = 1))) library(AER) t_test <- t.test(dat_NJ$FTE, dat_NJ$FTE2, var.equal = F) emp_mod <- lm(empl ~ D, data = reg_dat, subset = state == 1) # comprobar que las estimaciones y el estadístico t coinciden t_test <- t.test(dat_NJ$FTE, dat_NJ$FTE2, var.equal = F) emp_mod <- lm(empl ~ D, data = reg_dat, subset = state == 1) # estimaciones emp_mod$coef[2] diff(t_test$estimate) # estadístico t t_test$statistic coeftest(emp_mod, vcov. = vcovHC, type = "HC1")[2,3]