Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

ps2

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF,
and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the
output of any embedded R code chunks within the document. You can embed an R code chunk like this:

data = read.csv("Mexico_PS2.csv")

library(stargazer)

##
## Please cite as:

## Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.

## R package version 5.2.2. https://CRAN.R-project.org/package=stargazer

library(lmtest)

## Loading required package: zoo

##
## Attaching package: ’zoo’

## The following objects are masked from ’package:base’:


##
## as.Date, as.Date.numeric

library(sandwich)
library(car)

## Loading required package: carData

library(ivreg)

stargazer(data, type="text",
title="Summary Statistics",
summary.stat = c("n", "mean", "sd", "min","max"),
out="Summary Table.txt")

1
##
## Summary Statistics
## ===========================================================
## Statistic N Mean St. Dev. Min Max
## -----------------------------------------------------------
## year 1,153 2,000.000 0.000 2,000 2,000
## municode 1,153 18,168.720 8,045.480 1,001 32,056
## inc_m 1,153 2,583.081 1,257.101 299.757 14,792.910
## ind_lang 1,153 0.114 0.221 0.000 0.984
## educ_years 1,153 7.031 1.354 2.488 11.870
## sales_hotel 1,153 27,120.140 201,033.400 1 5,229,616
## logtemp 1,153 5.283 0.212 4.658 5.671
## logprecip 1,153 4.304 0.562 1.790 5.746
## dist_us_km 1,153 696.171 278.301 6.609 1,348.003
## -----------------------------------------------------------

data$l_inc=log(data$inc_m)

reg_qa = lm(l_inc ~ educ_years , data=data)


reg_qa_robust = coeftest(reg_qa , vcov = vcovHC(reg_qa, type="HC1"))
stargazer(reg_qa_robust,
type = "text",
omit.stat=c("LL","ser","f","adj.rsq"))

##
## ======================================
## Dependent variable:
## ---------------------------
##
## --------------------------------------
## educ_years 0.183***
## (0.007)
##
## Constant 6.485***
## (0.052)
##
## ======================================
## ======================================
## Note: *p<0.1; **p<0.05; ***p<0.01

reg_qe = lm(educ_years ~ ind_lang, data= data)


reg_qe_robust = coeftest(reg_qe, vcov = vcovHC(reg_qe, type="HC1"))
stargazer(reg_qe_robust,
type = "text",
omit.stat=c("LL","ser","f","adj.rsq"))

##
## ====================================
## Dependent variable:
## ---------------------------
##
## ------------------------------------

2
## ind_lang -2.421***
## (0.149)
##
## Constant 7.306***
## (0.042)
##
## ====================================
## ====================================
## Note: *p<0.1; **p<0.05; ***p<0.01

reg_qf = ivreg(l_inc ~ educ_years | ind_lang, data = data)


reg_qf_robust = coeftest(reg_qf, vcov = vcovHC(reg_qf, type="HC1"))
stargazer(reg_qf_robust,
type = "text",
omit.stat=c("LL","ser","f","adj.rsq"))

##
## ======================================
## Dependent variable:
## ---------------------------
##
## --------------------------------------
## educ_years 0.310***
## (0.021)
##
## Constant 5.597***
## (0.148)
##
## ======================================
## ======================================
## Note: *p<0.1; **p<0.05; ***p<0.01

reg_qg_controls = ivreg(l_inc ~ educ_years + dist_us_km + logtemp + logprecip + sales_hotel | ind_lang +


reg_qg_controls_robust = coeftest(reg_qg_controls, vcov = vcovHC(reg_qg_controls, type="HC1"))
stargazer(reg_qg_controls_robust,
type = "text",
omit.stat=c("LL","ser","f","adj.rsq"))

##
## =======================================
## Dependent variable:
## ---------------------------
##
## ---------------------------------------
## educ_years 0.298***
## (0.032)
##
## dist_us_km -0.0002***
## (0.00005)
##
## logtemp 0.102*
## (0.057)
##

3
## logprecip 0.005
## (0.032)
##
## sales_hotel -0.00000
## (0.00000)
##
## Constant 5.223***
## (0.499)
##
## =======================================
## =======================================
## Note: *p<0.1; **p<0.05; ***p<0.01

You might also like