관리자 글쓰기
[Practice] Estimation of Return to Schooling
2019. 11. 19. 17:22 - MunJunHyeok

 

교육 수익률의 추정

시작하기

  • Reading data: labor_supply_female.csv
  • Create New Chunk at MarkDown : ctrl + alt + I

  • 라이브러리 로드

library(tidyverse)
library(readr)
library(gridExtra)
library(stargazer)
library(showtext)
font_add_google('Nanum Gothic','nanumgothic')
showtext::showtext_auto()
  • 데이터 로드 및 편집
labor.sup <- readr::read_csv('labor_supply.csv')
labor.sup$w2edu <- factor(labor.sup$w2edu,
                          labels = c('무학','초졸','중졸','고졸','전문대졸','4년제','석사','박사')
                          )
  • plot으로 데이터 확인하기
labor.sup %>% 
  group_by(w2edu) %>%
  # x 축을 나이, y 축을 log 변환한 시간당 임금으로 설정
  ggplot(mapping = aes(x     = age,
                       y     = ln_wage_hourly)) +
  
  # Scatter gram과 추세선을 그림
  geom_point(aes(col = w2edu)) +
  geom_smooth(method = 'glm',
              formula = y ~ poly(x,2),
              color = 'steelblue',
              se = FALSE,
              linetype = 'dashed') +
  scale_color_brewer(palette = 'RdYlBu') +
  xlim(18, 80) +
  xlab('age') +
  ylab('log_hourly_wage')

Regression (회귀분석)

  1. age를 독립변수로 갖는 회귀분석
  2. age와 age의 제곱을 독립변수로 갖는 회귀분석
  3. age와 age의 제곱, 교육수준을 독립변수로 갖는 회귀분석
  4. age와 age의 제곱, 교육기간을 독립변수로 갖는 회귀분석
# no.1
lm.1 <- lm(ln_wage_hourly ~ age,
           data = labor.sup)
summary(lm.1)
## 
## Call:
## lm(formula = ln_wage_hourly ~ age, data = labor.sup)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.7605 -0.4103 -0.0118  0.4344  2.6761 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.152733   0.076711   1.991   0.0467 *  
## age         -0.017896   0.001847  -9.689   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.774 on 1123 degrees of freedom
##   (694 observations deleted due to missingness)
## Multiple R-squared:  0.07714,    Adjusted R-squared:  0.07632 
## F-statistic: 93.87 on 1 and 1123 DF,  p-value: < 2.2e-16
# 결론 : age의 coefficient가 음수이다. 즉, 나이가 많을 수록 임금이 떨어진다.
# 모형이 제약적이기 때문에 예상과 다른 결과가 나온다.
# overfit: 지나치게 fitting을 해서 미래 예측이 불가한 상태.
# no.2
lm.2 <- lm(ln_wage_hourly ~ age + I(age^2),
           data = labor.sup)
summary(lm.2)
## 
## Call:
## lm(formula = ln_wage_hourly ~ age + I(age^2), data = labor.sup)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.87855 -0.40389 -0.02607  0.44161  2.97720 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -1.7420240  0.2244846  -7.760 1.90e-14 ***
## age          0.0787824  0.0109577   7.190 1.18e-12 ***
## I(age^2)    -0.0011215  0.0001254  -8.942  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.7481 on 1122 degrees of freedom
##   (694 observations deleted due to missingness)
## Multiple R-squared:  0.1385, Adjusted R-squared:  0.137 
## F-statistic: 90.22 on 2 and 1122 DF,  p-value: < 2.2e-16
# 결론 a : age의 coefficient가 양수로 바뀌었다. 즉, 나이가 많을 수록 시간당 임금이 증가한다.
# age가 1년 증가할 때 마다 시간당 임금이 7.9% 올라가는 경향이 있다.
# 결론 b : 제곱항의 coefficient가 음수이다. 위로 볼록한 2차 함수의 형태를 띈다.
# 즉, 연령에 따른 한계수확은 나이가 많을수록 체감한다.
  • add the education variable, w2edu
# no.3
lm.3 <- lm(ln_wage_hourly ~ age + I(age^2) + w2edu,
           data = labor.sup)
summary(lm.3)
## 
## Call:
## lm(formula = ln_wage_hourly ~ age + I(age^2) + w2edu, data = labor.sup)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.3140 -0.3123  0.0553  0.4167  1.9190 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   -2.8605677  0.2419628 -11.822  < 2e-16 ***
## age            0.0742900  0.0112049   6.630 5.22e-11 ***
## I(age^2)      -0.0008390  0.0001336  -6.277 4.92e-10 ***
## w2edu초졸      0.1421755  0.1541257   0.922 0.356486    
## w2edu중졸      0.3391013  0.1627300   2.084 0.037403 *  
## w2edu고졸      0.6199602  0.1651687   3.753 0.000183 ***
## w2edu전문대졸  0.9276296  0.1752402   5.293 1.44e-07 ***
## w2edu4년제     1.2356706  0.1706671   7.240 8.33e-13 ***
## w2edu석사      1.6530789  0.1913012   8.641  < 2e-16 ***
## w2edu박사      1.8454967  0.3457613   5.337 1.14e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6758 on 1115 degrees of freedom
##   (694 observations deleted due to missingness)
## Multiple R-squared:  0.3015, Adjusted R-squared:  0.2958 
## F-statistic: 53.46 on 9 and 1115 DF,  p-value: < 2.2e-16
# 다중공선성 문제 해결을 위해 자유도를 제한한다. '무학' 독립변수를 제거한다.
# 제거된 독릴변수에 대비해 추정량 평가.
# 결론 : '무학' 교육수준에 비해 '고졸' 교육수준인 사람은 시간당 임금이 61% 높다 등.

Report the results of model 2,3,4

# no.4
lm.4 <- lm(ln_wage_hourly ~ age + I(age^2) + educ_year,
           data = labor.sup)
summary(lm.4)
## 
## Call:
## lm(formula = ln_wage_hourly ~ age + I(age^2) + educ_year, data = labor.sup)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.7045 -0.3190  0.0404  0.4383  1.9297 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -3.1247333  0.2257963 -13.839  < 2e-16 ***
## age          0.0505973  0.0102098   4.956 8.31e-07 ***
## I(age^2)    -0.0005288  0.0001216  -4.348 1.50e-05 ***
## educ_year    0.1165055  0.0078876  14.771  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6848 on 1121 degrees of freedom
##   (694 observations deleted due to missingness)
## Multiple R-squared:  0.2789, Adjusted R-squared:  0.277 
## F-statistic: 144.5 on 3 and 1121 DF,  p-value: < 2.2e-16
stargazer::stargazer(lm.2,lm.3,lm.4,
                     type = 'text')
## 
## ===============================================================================================
##                                                 Dependent variable:                            
##                     ---------------------------------------------------------------------------
##                                                   ln_wage_hourly                               
##                               (1)                      (2)                       (3)           
## -----------------------------------------------------------------------------------------------
## age                         0.079***                 0.074***                 0.051***         
##                             (0.011)                  (0.011)                   (0.010)         
##                                                                                                
## I(age2)                    -0.001***                -0.001***                 -0.001***        
##                             (0.0001)                 (0.0001)                 (0.0001)         
##                                                                                                
## w2edu초졸                                               0.142                                    
##                                                      (0.154)                                   
##                                                                                                
## w2edu중졸                                              0.339**                                   
##                                                      (0.163)                                   
##                                                                                                
## w2edu고졸                                              0.620***                                  
##                                                      (0.165)                                   
##                                                                                                
## w2edu전문대졸                                            0.928***                                  
##                                                      (0.175)                                   
##                                                                                                
## w2edu4년제                                             1.236***                                  
##                                                      (0.171)                                   
##                                                                                                
## w2edu석사                                              1.653***                                  
##                                                      (0.191)                                   
##                                                                                                
## w2edu박사                                              1.845***                                  
##                                                      (0.346)                                   
##                                                                                                
## educ_year                                                                     0.117***         
##                                                                                (0.008)         
##                                                                                                
## Constant                   -1.742***                -2.861***                 -3.125***        
##                             (0.224)                  (0.242)                   (0.226)         
##                                                                                                
## -----------------------------------------------------------------------------------------------
## Observations                 1,125                    1,125                     1,125          
## R2                           0.139                    0.301                     0.279          
## Adjusted R2                  0.137                    0.296                     0.277          
## Residual Std. Error    0.748 (df = 1122)        0.676 (df = 1115)         0.685 (df = 1121)    
## F Statistic         90.220*** (df = 2; 1122) 53.464*** (df = 9; 1115) 144.514*** (df = 3; 1121)
## ===============================================================================================
## Note:                                                               *p<0.1; **p<0.05; ***p<0.01
# 결론 : 교육 기간이 1년 증가했을 때, 임금이 약 11.7% 증가한다.