Advertisement
Guest User

Untitled

a guest
Aug 11th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.54 KB | None | 0 0
  1. ###### loading required packages
  2. library(dplyr)
  3. library(stargazer)
  4. library(oaxaca)
  5. library(knitr)
  6. library(survey)
  7. library(Hmisc)
  8. library(matrixStats)
  9. library(quantreg)
  10.  
  11. ######removing previous global environment
  12. rm(list=ls())
  13.  
  14. #############################################################################################################
  15. #Loading Data
  16. ##############################################################################################################
  17. pg <- src_postgres("datacube", user="bsagmeister", password="migrantwagegap", host="ineq.wu.ac.at", options="-c search_path=silc")
  18.  
  19. #h <- tbl(pg, "c13h")
  20. d <- tbl(pg, "c13d")
  21. p <- tbl(pg, "c13p")
  22. #r <- tbl(pg, "c13r")
  23.  
  24.  
  25. #####################################################################################################################
  26. #####Nur-Vollzeit, fuer den Fall, dass meine Vollzeit/Teilzeit Variable nicht passt
  27. #silc1 <- p %>% filter(pb020=="AT") %>% select(pb010, pb020, pb030, pb040, pb140, pb150, pb190,pb210,pe040,pl060,
  28. # pl073,py010g, pl074,pl100,pl200,pl040,pl111,pl150,ph010,pb220a)
  29. #silc2 <- r %>% filter(rb020=="AT") %>% select(rb030, rb220, rb230)
  30. #silc1 <- collect(silc1, n=Inf)
  31. #silc2 <- collect(silc2, n=Inf)
  32. #silc <-left_join(silc1, silc2, by=c("pb030" = "rb030"))
  33. #silc <- collect(silc, n=Inf)
  34.  
  35.  
  36.  
  37.  
  38. #silc <- filter(silc, pl073 == 12)
  39. #silc <- filter(silc, py010g > 0)
  40. #silc["hwage"]<-silc$py010g/52/silc$pl060
  41. #silc<-na.omit(silc)
  42.  
  43.  
  44.  
  45.  
  46.  
  47. ####################################################################################################################
  48. #####Herstellung der benoetigten Variablen
  49. ####################################################################################################################
  50. #silc <- p %>% filter(pb020=="AT") %>% select(pb010, pb020, pb030, pb040, pb140, pb150, pb190,pb210,pe040,pl060,
  51. # pl073,py010g, pl074,pl100,pl200,pl040,pl111,pl150,ph010,pb220a)
  52. #silc <- collect(silc, n=Inf)
  53. silc1 <- p %>% filter(pb020=="AT") %>% select(pb010, pb020, pb030,px030, pb040, pb140, pb150, pb190,pb210,pe040,pl060,
  54. pl073,py010g, pl074,pl100,pl200,pl040,pl111,pl150,ph010,pb220a)
  55. silc2 <- d %>% filter(db020=="AT") %>% select(db030, db100)
  56. silc1 <- collect(silc1, n=Inf)
  57. silc2 <- collect(silc2, n=Inf)
  58. silc <-left_join(silc1, silc2, by=c("px030" = "db030"))
  59. rm(silc1,silc2)
  60.  
  61.  
  62.  
  63.  
  64.  
  65. ##################################################
  66. #Stundenlohn: Vollzeit+Teilzeit
  67. #################################################
  68.  
  69.  
  70. silc <- filter(silc, py010g > 0)
  71. silc <- filter(silc, pl040 == 3)
  72. silc$pl060[is.na(silc$pl060)]<-0
  73. silc$pl100[is.na(silc$pl100)]<-0
  74. silc["tothr"]<-silc$pl060+silc$pl100
  75. silc <- filter(silc, tothr > 0)
  76. silc["totmnth"]<-silc$pl073+silc$pl074
  77. silc <- filter(silc, totmnth > 0)
  78. silc["hwage"]<-silc$py010g/((silc$pl073+silc$pl074)*4*(silc$pl060+silc$pl100))
  79.  
  80. summary(silc$hwage)
  81. silc<-na.omit(silc)
  82.  
  83. ##############################################
  84. #Education-Dummies
  85. #############################################
  86.  
  87. #-> alles niedriger (inkl.) lower second wird zu 2 zusammengefasst und reference category; upper second and non tertiary wird zu 3 zusammengefasst
  88. silc$pe040[silc$pe040==0]<-2
  89. silc$pe040[silc$pe040==1]<-2
  90. silc$pe040[silc$pe040==4]<-3
  91. silc$education <-factor(silc$pe040, levels=c("2","3","5"))
  92.  
  93.  
  94. ##########################################################
  95. #Managerial Position Dummy
  96. ##########################################################
  97.  
  98. #### 0 wenn keine leitende Position, 1 wenn in einer leitenden Position
  99.  
  100. silc["position"]<-silc$pl150
  101. silc$position[silc$position==2]<-0
  102. silc$position<-as.numeric(silc$position)
  103.  
  104. ###########################################################
  105. #Health Dummy
  106. ##########################################################
  107.  
  108. silc["health"]<-silc$ph010
  109. table(silc$health)
  110. # absolute Mehrheit im Sample entweder "fair", "good" oder "very good", daher 0 -> Abweichung ("bad", "very bad") wird zu 1
  111.  
  112. silc$health[silc$health==1]<-0
  113. silc$health[silc$health==2]<-0
  114. silc$health[silc$health==3]<-0
  115. silc$health[silc$health==4]<-1
  116. silc$health[silc$health==5]<-1
  117.  
  118.  
  119. #######################################################
  120. #Age Variable herstellen
  121. ####################################################
  122.  
  123. silc["age"]<-2013-silc$pb140
  124. summary(silc$age)
  125.  
  126.  
  127.  
  128. #####Variablen-umbenennen####
  129. silc["exp"]<-silc$pl200
  130. summary(silc$pl200)
  131.  
  132. ##################################################
  133. #Sex Dummy
  134. ################################################
  135.  
  136. silc$pb150[silc$pb150==1]<-0
  137. silc$pb150[silc$pb150==2]<-1
  138. silc["sex"]<-silc$pb150
  139.  
  140.  
  141. ###############################################
  142. #Degree of Urbanisation
  143. ###############################################
  144. silc["urb"]<-silc$db100
  145. silc$urb <-factor(silc$db100, levels=c("1","2","3"))
  146.  
  147.  
  148. ####################################################
  149. #Citizenship and Country of birth
  150. ####################################################
  151.  
  152. silc["loc"]<-silc$pb210
  153. ## wie viele ATs, EUs, OTHs?
  154. loctable<-as.data.frame(table(silc$loc))
  155. rm(loctable)
  156. #AT+EU wird zusammengefasst
  157. silc$loc[silc$loc=="LOC"]<-0
  158. silc$loc[silc$loc=="EU"]<-0
  159. silc$loc[silc$loc=="OTH"]<-1
  160. silc$loc<-as.numeric(silc$loc)
  161.  
  162. silc["cit"]<-silc$pb220a
  163. silc$cit[silc$cit=="LOC"]<-0
  164. silc$cit[silc$cit=="EU"]<-0
  165. silc$cit[silc$cit=="OTH"]<-1
  166. silc$cit<-as.numeric(silc$cit)
  167.  
  168. #######################################################
  169. #Migrants
  170. ######################################################
  171. silc["mig"]<-silc$loc
  172. silc$mig[silc$cit]<-0
  173. silc$mig[silc$loc]<-0
  174. silc$mig[silc$cit==1]<-1
  175. silc$mig[silc$loc==1]<-1
  176. mig<-as.data.frame(table(silc$mig))
  177. table(mig)
  178. rm(mig)
  179. ##############################################################################
  180. #Neues Dataframe nur mit verwendeten Variablen
  181. ############################################################################
  182. silc<-na.omit(silc)
  183.  
  184. sub.inl.aus<-data.frame(cbind(silc$sex,silc$age,silc$exp,silc$mig,silc$education,silc$hwage,silc$position,silc$health,silc$pb040,silc$urb))
  185. colnames(sub.inl.aus)<-c("sex","age","exp","mig","education","hwage","position","health","weights","urb")
  186. rm(silc)
  187. sub.inl.aus<-na.omit(sub.inl.aus)
  188.  
  189.  
  190. #####################################################################################
  191. # OLS zur Analyse des Stundenlohns
  192. ##################################################################################
  193.  
  194. #################################
  195. # OLS des gesamten Samples
  196. ################################
  197.  
  198. ols<-(lm(log(hwage)~sex+I(exp)+I((exp)^2)+as.factor(education)+mig+health+position+as.factor(urb), data=sub.inl.aus,weights=weights))
  199.  
  200. #ols<-(lm(log(hwage)~sex*I(exp)*I((exp)^2)*as.factor(education)*loc+health*position, data=sub.inl.aus,weights=weights))
  201. summary(ols)
  202. summary(sub.inl.aus$hwage)
  203.  
  204.  
  205.  
  206. #################################
  207. # Herstellung zweier Samples mit entweder EU Citizens (inkl. AT) oder nur Dritt-Staat Citizens
  208. #################################
  209.  
  210. ateu<-subset(sub.inl.aus, mig==0)
  211. oth<-subset(sub.inl.aus,mig==1)
  212.  
  213.  
  214.  
  215. #################################
  216. # OLS dieser beiden Samples
  217. ################################
  218.  
  219.  
  220. olsateu<-(lm(log(hwage)~sex+I(exp)+I((exp)^2)+as.factor(education)+health+position+as.factor(urb), data=ateu,weights=weights))
  221. summary(olsateu)
  222.  
  223. table(ateu$education)
  224.  
  225. olsoth<-(lm(log(hwage)~sex+I(exp)+I((exp)^2)+as.factor(education)+health+position+as.factor(urb), data=oth,weights=weights))
  226. summary(olsoth)
  227. table(oth$education)
  228.  
  229.  
  230.  
  231.  
  232. #########################################################################################
  233. # Oaxaca-Blinder Zerlegung des gesamten Samples
  234. ########################################################################################
  235.  
  236.  
  237. in.aus<-oaxaca(hwage~sex+I(exp)+I((exp)^2)+as.factor(education)+position+health+as.factor(urb)|mig, data=sub.inl.aus)
  238.  
  239. #Ergebnisse
  240. #Neumark Gewichtung -1
  241.  
  242. summary(in.aus)
  243. in.aus$twofold$overall
  244.  
  245.  
  246. #Plot
  247. plot(in.aus, decomposition = "twofold", weight=-1)
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254. ##################################################################################################
  255. #####Oaxaca-Blinder Zerlegung in den verschiedenen Quartilen
  256. ##################################################################################################
  257.  
  258.  
  259. ################################
  260. ###Herstellung von Quartilen
  261. ################################
  262.  
  263. wtd.quantile(ateu$hwage, weights=ateu$weights, probs=c(0, .25, .5, .75, 1),
  264. type=c('quantile','(i-1)/(n-1)','i/(n+1)','i/n'),
  265. normwt=FALSE, na.rm=TRUE)
  266.  
  267.  
  268. wtd.mean(ateu$hwage, weights=ateu$weights, normwt="ignored", na.rm=TRUE)
  269.  
  270.  
  271. wtd.quantile(oth$hwage, weights=oth$weights, probs=c(0, .25, .5, .75, 1),
  272. type=c('quantile','(i-1)/(n-1)','i/(n+1)','i/n'),
  273. normwt=FALSE, na.rm=TRUE)
  274.  
  275.  
  276. wtd.mean(oth$hwage, weights=oth$weights, normwt="ignored", na.rm=TRUE)
  277.  
  278. #wtd.quantile(sub.inl.aus$hwage, weights=sub.inl.aus$weights, probs=c(0, .25, .5, .75, 1),
  279. #type=c('quantile','(i-1)/(n-1)','i/(n+1)','i/n'),
  280. #normwt=FALSE, na.rm=TRUE)
  281.  
  282.  
  283. #wtd.mean(sub.inl.aus$hwage, weights=sub.inl.aus$weights, normwt="ignored", na.rm=TRUE)
  284.  
  285.  
  286.  
  287. quart1at<-subset(ateu, ateu$hwage <= 12.504891)
  288. quart2at<-subset(ateu, ateu$hwage > 12.504891 & ateu$hwage <= 17.358578)
  289. quart3at<-subset(ateu,ateu$hwage > 17.358578 & ateu$hwage <= 23.845882)
  290. quart4at<-subset(ateu, ateu$hwage >23.845882)
  291.  
  292.  
  293. quart1oth<-subset(oth, oth$hwage <= 9.9241400)
  294. quart2oth<-subset(oth, oth$hwage > 9.9241400 & oth$hwage <= 13.2664474)
  295. quart3oth<-subset(oth,oth$hwage > 13.2664474 & oth$hwage <= 17.5470260)
  296. quart4oth<-subset(oth, oth$hwage >17.5470260)
  297.  
  298. #Analyse des Stundenlohns
  299. summary(ateu$hwage)
  300. summary(oth$hwage)
  301.  
  302. wtd.mean(ateu$hwage, weights=ateu$weights, normwt="ignored", na.rm=TRUE)
  303. wtd.mean(oth$hwage, weights=oth$weights, normwt="ignored", na.rm=TRUE)
  304.  
  305. #Zusammenf\FCgen der beiden Quartils-Gruppen
  306.  
  307. atoth1 <- rbind(quart1at, quart1oth)
  308. atoth2 <- rbind(quart2at, quart2oth)
  309. atoth3 <- rbind(quart3at, quart3oth)
  310. atoth4 <- rbind(quart4at, quart4oth)
  311.  
  312.  
  313. ##################################
  314. #Analyse 1. Quartile
  315. ##################################
  316. in.aus1<-oaxaca(hwage~sex+I(exp)+I((exp)^2)+as.factor(education)+position+health+as.factor(urb)|mig, data=atoth1)
  317.  
  318. in.aus1$y
  319. in.aus1$n
  320. summary(in.aus1)
  321. in.aus1$twofold$overall
  322. plot(in.aus1, decomposition = "twofold", weight=-1)
  323.  
  324. table(atoth1$education)
  325. table(atoth1$mig)
  326.  
  327. ##################################
  328. #Analyse 2. Quartile
  329. ##################################
  330.  
  331. in.aus2<-oaxaca(hwage~sex+I(exp)+I((exp)^2)+as.factor(education)+position+health+as.factor(urb)|mig, data=atoth2)
  332. in.aus2$y
  333. in.aus2$twofold$overall
  334. summary(in.aus2)
  335. plot(in.aus2, decomposition = "twofold", weight=-1)
  336.  
  337. table(atoth2$education)
  338. table(atoth2$mig)
  339.  
  340. ##################################
  341. #Analyse 3. Quartile
  342. ##################################
  343.  
  344. in.aus3<-oaxaca(hwage~sex+I(exp)+I((exp)^2)+as.factor(education)+position+health+as.factor(urb)|mig, data=atoth3)
  345. summary(in.aus3)
  346. in.aus3$y
  347. in.aus3$twofold$overall
  348. plot(in.aus3, decomposition = "twofold", weight=-1)
  349.  
  350. table(atoth3$education)
  351. table(atoth3$mig)
  352.  
  353. ##################################
  354. #Analyse 4. Quartile
  355. ##################################
  356.  
  357. in.aus4<-oaxaca(hwage~sex+I(exp)+I((exp)^2)+as.factor(education)+position+health+as.factor(urb)|mig, data=atoth4)
  358. summary(in.aus4)
  359. in.aus4$y
  360. in.aus4$twofold$overall
  361. plot(in.aus4, decomposition = "twofold", weight=-1)
  362.  
  363. table(atoth4$education)
  364. table(atoth4$mig)
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374. ###########################################################################################################################
  375. #oaxaca h\E4ndisch
  376. #########################################################################################################################
  377.  
  378. ##################
  379. #Full Sample
  380. ##################
  381.  
  382.  
  383. mean.inl<-data.frame(rbind(colWeightedMeans(ateu, w=ateu$weights)))
  384. mean.aus<-data.frame(rbind(colWeightedMeans(oth, w=oth$weights)))
  385. #lohngleichung definieren
  386. lohnd<-as.formula(hwage~sex+exp+I((exp)^2)+education+position+health)
  387. # lohngleichung schaetzen
  388. mylm.inl<-lm(lohnd,data=ateu,weights=weights)
  389. mylm.aus<-lm(lohnd,data=oth,weights=weights)
  390.  
  391. wage_i_i<-predict(mylm.inl,newdata=mean.inl,weights=weights)
  392. wage_a_a<-predict(mylm.aus,newdata=mean.aus,weights=weights)
  393.  
  394. wage_i_a<-predict(mylm.aus,newdata=mean.inl,weights=weights)
  395. wage_a_i<-predict(mylm.inl,newdata=mean.aus,weights=weights)
  396.  
  397. wagediffd<-wtd.mean(ateu$hwage, weights=ateu$weights, normwt="ignored",
  398. na.rm=TRUE)-wtd.mean(oth$hwage, weights=oth$weights, normwt="ignored", na.rm=TRUE)
  399. # Fall 1: Bewertung zu inl werten
  400. erkl.1d<-wage_i_i-wage_a_i
  401. unerkl.1d<-wage_a_i-wage_a_a
  402. # Fall 2: Bewertung zu ausl werten
  403. erkl.2d<-wage_i_a-wage_a_a
  404. unerkl.2d<-wage_i_i-wage_i_a
  405.  
  406. dec=6 # dezimalstellen angeben
  407. oaxacad<-as.data.frame(rbind(c("differenz",round(wagediffd,dec),round(wagediffd,dec)),c("charakteristika",round(erkl.1d,dec),round(erkl.2d,dec)),c("diskriminierung",round(unerkl.1d,dec),round(unerkl.2d,dec))))
  408.  
  409. # ergebnis anzeigen
  410. stargazer(oaxacad,type="text",summary=F,rownames=F,colnames=F)
  411.  
  412.  
  413. ##############################
  414. #1. Quartil
  415. #############################
  416. #ateu1<-subset(quart1, loc==0)
  417. #oth1<-subset(quart1,loc==1)
  418.  
  419.  
  420. mean.inl<-data.frame(rbind(colWeightedMeans(quart1at, w=quart1at$weights)))
  421. mean.aus<-data.frame(rbind(colWeightedMeans(quart1oth, w=quart1oth$weights)))
  422. #lohngleichung definieren
  423. lohnd<-as.formula(hwage~sex+exp+I((exp)^2)+education+position+health)
  424. # lohngleichung schaetzen
  425. mylm.inl<-lm(lohnd,data=quart1at,weights=weights)
  426. mylm.aus<-lm(lohnd,data=quart1oth,weights=weights)
  427.  
  428. wage_i_i<-predict(mylm.inl,newdata=mean.inl,weights=weights)
  429. wage_a_a<-predict(mylm.aus,newdata=mean.aus,weights=weights)
  430.  
  431. wage_i_a<-predict(mylm.aus,newdata=mean.inl,weights=weights)
  432. wage_a_i<-predict(mylm.inl,newdata=mean.aus,weights=weights)
  433.  
  434. wagediffd<-wtd.mean(quart1at$hwage, weights=quart1at$weights, normwt="ignored",
  435. na.rm=TRUE)-wtd.mean(quart1oth$hwage, weights=quart1oth$weights, normwt="ignored", na.rm=TRUE)
  436.  
  437. wtd.mean(quart1at$hwage, weights=quart1at$weights, normwt="ignored",
  438. na.rm=TRUE)
  439. wtd.mean(quart1oth$hwage, weights=quart1oth$weights, normwt="ignored", na.rm=TRUE)
  440.  
  441. # Fall 1: Bewertung zu inl werten
  442. erkl.1d<-wage_i_i-wage_a_i
  443. unerkl.1d<-wage_a_i-wage_a_a
  444. # Fall 2: Bewertung zu ausl werten
  445. erkl.2d<-wage_i_a-wage_a_a
  446. unerkl.2d<-wage_i_i-wage_i_a
  447.  
  448. dec=6 # dezimalstellen angeben
  449. oaxacad1<-as.data.frame(rbind(c("differenz",round(wagediffd,dec),round(wagediffd,dec)),c("charakteristika",round(erkl.1d,dec),round(erkl.2d,dec)),c("diskriminierung",round(unerkl.1d,dec),round(unerkl.2d,dec))))
  450.  
  451. # ergebnis anzeigen
  452. stargazer(oaxacad1,type="text",summary=F,rownames=F,colnames=F)
  453.  
  454. ###############################
  455. #2. Quartil
  456. ###############################
  457.  
  458. mean.inl<-data.frame(rbind(colWeightedMeans(quart2at, w=quart2at$weights)))
  459. mean.aus<-data.frame(rbind(colWeightedMeans(quart2oth, w=quart2oth$weights)))
  460. #lohngleichung definieren
  461. lohnd<-as.formula(hwage~sex+exp+I((exp)^2)+education+position+health)
  462. # lohngleichung schaetzen
  463. mylm.inl<-lm(lohnd,data=quart2at,weights=weights)
  464. mylm.aus<-lm(lohnd,data=quart2oth,weights=weights)
  465.  
  466. wage_i_i<-predict(mylm.inl,newdata=mean.inl,weights=weights)
  467. wage_a_a<-predict(mylm.aus,newdata=mean.aus,weights=weights)
  468.  
  469. wage_i_a<-predict(mylm.aus,newdata=mean.inl,weights=weights)
  470. wage_a_i<-predict(mylm.inl,newdata=mean.aus,weights=weights)
  471.  
  472. wagediffd<-wtd.mean(quart2at$hwage, weights=quart2at$weights, normwt="ignored",
  473. na.rm=TRUE)-wtd.mean(quart2oth$hwage, weights=quart2oth$weights, normwt="ignored", na.rm=TRUE)
  474. # Fall 1: Bewertung zu inl werten
  475. erkl.1d<-wage_i_i-wage_a_i
  476. unerkl.1d<-wage_a_i-wage_a_a
  477. # Fall 2: Bewertung zu ausl werten
  478. erkl.2d<-wage_i_a-wage_a_a
  479. unerkl.2d<-wage_i_i-wage_i_a
  480.  
  481. dec=6 # dezimalstellen angeben
  482. oaxacad2<-as.data.frame(rbind(c("differenz",round(wagediffd,dec),round(wagediffd,dec)),c("charakteristika",round(erkl.1d,dec),round(erkl.2d,dec)),c("diskriminierung",round(unerkl.1d,dec),round(unerkl.2d,dec))))
  483.  
  484. # ergebnis anzeigen
  485. stargazer(oaxacad2,type="text",summary=F,rownames=F,colnames=F)
  486.  
  487. ##############################
  488. #3. Quartil
  489. #############################
  490. mean.inl<-data.frame(rbind(colWeightedMeans(quart3at, w=quart3at$weights)))
  491. mean.aus<-data.frame(rbind(colWeightedMeans(quart3oth, w=quart3oth$weights)))
  492. #lohngleichung definieren
  493. lohnd<-as.formula(hwage~sex+exp+I((exp)^2)+education+position+health)
  494. # lohngleichung schaetzen
  495. mylm.inl<-lm(lohnd,data=quart3at,weights=weights)
  496. mylm.aus<-lm(lohnd,data=quart3oth,weights=weights)
  497.  
  498. wage_i_i<-predict(mylm.inl,newdata=mean.inl,weights=weights)
  499. wage_a_a<-predict(mylm.aus,newdata=mean.aus,weights=weights)
  500.  
  501. wage_i_a<-predict(mylm.aus,newdata=mean.inl,weights=weights)
  502. wage_a_i<-predict(mylm.inl,newdata=mean.aus,weights=weights)
  503.  
  504. wagediffd<-wtd.mean(quart3at$hwage, weights=quart3at$weights, normwt="ignored",
  505. na.rm=TRUE)-wtd.mean(quart3oth$hwage, weights=quart3oth$weights, normwt="ignored", na.rm=TRUE)
  506. # Fall 1: Bewertung zu inl werten
  507. erkl.1d<-wage_i_i-wage_a_i
  508. unerkl.1d<-wage_a_i-wage_a_a
  509. # Fall 2: Bewertung zu ausl werten
  510. erkl.2d<-wage_i_a-wage_a_a
  511. unerkl.2d<-wage_i_i-wage_i_a
  512.  
  513. dec=6 # dezimalstellen angeben
  514. oaxacad3<-as.data.frame(rbind(c("differenz",round(wagediffd,dec),round(wagediffd,dec)),c("charakteristika",round(erkl.1d,dec),round(erkl.2d,dec)),c("diskriminierung",round(unerkl.1d,dec),round(unerkl.2d,dec))))
  515.  
  516. # ergebnis anzeigen
  517. stargazer(oaxacad3,type="text",summary=F,rownames=F,colnames=F)
  518.  
  519.  
  520. ##############################
  521. #4. Quartil
  522. ##############################
  523. mean.inl<-data.frame(rbind(colWeightedMeans(quart4at, w=quart4at$weights)))
  524. mean.aus<-data.frame(rbind(colWeightedMeans(quart4oth, w=quart4oth$weights)))
  525. #lohngleichung definieren
  526. lohnd<-as.formula(hwage~sex+exp+I((exp)^2)+education+position+health)
  527. # lohngleichung schaetzen
  528. mylm.inl<-lm(lohnd,data=quart4at,weights=weights)
  529. mylm.aus<-lm(lohnd,data=quart4oth,weights=weights)
  530.  
  531. wage_i_i<-predict(mylm.inl,newdata=mean.inl,weights=weights)
  532. wage_a_a<-predict(mylm.aus,newdata=mean.aus,weights=weights)
  533.  
  534. wage_i_a<-predict(mylm.aus,newdata=mean.inl,weights=weights)
  535. wage_a_i<-predict(mylm.inl,newdata=mean.aus,weights=weights)
  536.  
  537. wagediffd<-wtd.mean(quart4at$hwage, weights=quart4at$weights, normwt="ignored",
  538. na.rm=TRUE)-wtd.mean(quart4oth$hwage, weights=quart4oth$weights, normwt="ignored", na.rm=TRUE)
  539. # Fall 1: Bewertung zu inl werten
  540. erkl.1d<-wage_i_i-wage_a_i
  541. unerkl.1d<-wage_a_i-wage_a_a
  542. # Fall 2: Bewertung zu ausl werten
  543. erkl.2d<-wage_i_a-wage_a_a
  544. unerkl.2d<-wage_i_i-wage_i_a
  545.  
  546. dec=6 # dezimalstellen angeben
  547. oaxacad4<-as.data.frame(rbind(c("differenz",round(wagediffd,dec),round(wagediffd,dec)),c("charakteristika",round(erkl.1d,dec),round(erkl.2d,dec)),c("diskriminierung",round(unerkl.1d,dec),round(unerkl.2d,dec))))
  548.  
  549. # ergebnis anzeigen
  550. stargazer(oaxacad4,type="text",summary=F,rownames=F,colnames=F)
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560. ################################################################################################
  561. #Producing Tables
  562. ################################################################################################
  563. summary(ols)
  564.  
  565. stargazer(ols,title= "Wage Regression Full Sample", type = "latex", style="qje",single.row=TRUE,align=TRUE,
  566. dep.var.labels = "Effect on hourly Wage",
  567. covariate.labels = c("Sex","Experience","Experience Squared","Medium Education",
  568. "High Education","Migrant","Bad Health","Managerial Position","Intermediate Area","Rural Area"))
  569. summary(olsateu)
  570.  
  571. stargazer(olsateu, olsoth,title= "Wage Regression Split", type = "latex", style="qje",single.row=TRUE,align=TRUE,
  572. dep.var.labels = "Effect on hourly Wage",
  573. covariate.labels = c("Sex","Experience","Experience Squared","Medium Education",
  574. "High Education","Bad Health","Managerial Position","Intermediate Area","Rural Area"))
  575.  
  576.  
  577. hwage<-sub.inl.aus$hwage
  578. sumhwage<-(summary(hwage))
  579.  
  580. stargazer(sub.inl.aus, title="Hourly Wages (Full Sample)", type="latex", style="qje",
  581. summary.stat=c("n","min","median","mean","max"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement