setwd("C:/Users/marcogeovanni/Desktop/Modern Guide To Econometrics/Chapter 3")
library(readstata13)
BWAGES <- read.dta13("bwages.dta")
attach(BWAGES)
summary(BWAGES)
## wage lnwage educ exper
## Min. : 2.191 Min. :0.7843 Min. :1.000 Min. : 0.00
## 1st Qu.: 8.113 1st Qu.:2.0935 1st Qu.:3.000 1st Qu.: 9.00
## Median :10.127 Median :2.3152 Median :3.000 Median :16.50
## Mean :11.051 Mean :2.3344 Mean :3.378 Mean :17.22
## 3rd Qu.:12.755 3rd Qu.:2.5460 3rd Qu.:4.000 3rd Qu.:24.00
## Max. :47.576 Max. :3.8623 Max. :5.000 Max. :47.00
## lnexper lneduc male
## Min. :0.000 Min. :0.000 Min. :0.0000
## 1st Qu.:2.303 1st Qu.:1.099 1st Qu.:0.0000
## Median :2.862 Median :1.099 Median :1.0000
## Mean :2.691 Mean :1.137 Mean :0.6067
## 3rd Qu.:3.219 3rd Qu.:1.386 3rd Qu.:1.0000
## Max. :3.871 Max. :1.609 Max. :1.0000
exper2 <- exper^2
E1 <- lm(wage~ male + educ + exper )
E2 <- lm(wage~ male + educ + exper + exper2 )
library(stargazer)
## Warning: package 'stargazer' was built under R version 3.2.3
##
## Please cite as:
## Hlavac, Marek (2015). stargazer: Well-Formatted Regression and Summary Statistics Tables.
## R package version 5.2. http://CRAN.R-project.org/package=stargazer
stargazer(E1,E2, type = "text",out="table1.txt")
##
## =======================================================================
## Dependent variable:
## ---------------------------------------------------
## wage
## (1) (2)
## -----------------------------------------------------------------------
## male 1.346*** 1.334***
## (0.193) (0.191)
##
## educ 1.986*** 1.988***
## (0.081) (0.080)
##
## exper 0.192*** 0.358***
## (0.010) (0.032)
##
## exper2 -0.004***
## (0.001)
##
## Constant 0.214 -0.892**
## (0.387) (0.433)
##
## -----------------------------------------------------------------------
## Observations 1,472 1,472
## R2 0.366 0.378
## Adjusted R2 0.364 0.377
## Residual Std. Error 3.548 (df = 1468) 3.514 (df = 1467)
## F Statistic 281.977*** (df = 3; 1468) 223.204*** (df = 4; 1467)
## =======================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
ResE2 <- residuals(E2)
FittedE2 <- fitted(E2)
plot(FittedE2, ResE2)
lnexper2 <- lnexper*lnexper
E3 <- lm(lnwage~ male + lneduc + lnexper + lnexper2)
summary(E3)
##
## Call:
## lm(formula = lnwage ~ male + lneduc + lnexper + lnexper2)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.75085 -0.15921 0.00618 0.17145 1.10533
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.26271 0.06634 19.033 < 2e-16 ***
## male 0.11794 0.01557 7.574 6.35e-14 ***
## lneduc 0.44218 0.01819 24.306 < 2e-16 ***
## lnexper 0.10982 0.05438 2.019 0.0436 *
## lnexper2 0.02601 0.01148 2.266 0.0236 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2862 on 1467 degrees of freedom
## Multiple R-squared: 0.3783, Adjusted R-squared: 0.3766
## F-statistic: 223.1 on 4 and 1467 DF, p-value: < 2.2e-16
ResE3 <- residuals(E3)
FittedE3 <- fitted(E3)
plot(FittedE3, ResE3)
stargazer(E1,E2,E3, type = "text",out="table1.txt")
##
## =================================================================================================
## Dependent variable:
## -----------------------------------------------------------------------------
## wage lnwage
## (1) (2) (3)
## -------------------------------------------------------------------------------------------------
## male 1.346*** 1.334*** 0.118***
## (0.193) (0.191) (0.016)
##
## educ 1.986*** 1.988***
## (0.081) (0.080)
##
## exper 0.192*** 0.358***
## (0.010) (0.032)
##
## exper2 -0.004***
## (0.001)
##
## lneduc 0.442***
## (0.018)
##
## lnexper 0.110**
## (0.054)
##
## lnexper2 0.026**
## (0.011)
##
## Constant 0.214 -0.892** 1.263***
## (0.387) (0.433) (0.066)
##
## -------------------------------------------------------------------------------------------------
## Observations 1,472 1,472 1,472
## R2 0.366 0.378 0.378
## Adjusted R2 0.364 0.377 0.377
## Residual Std. Error 3.548 (df = 1468) 3.514 (df = 1467) 0.286 (df = 1467)
## F Statistic 281.977*** (df = 3; 1468) 223.204*** (df = 4; 1467) 223.127*** (df = 4; 1467)
## =================================================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01