Guest User

Untitled

a guest
May 24th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.16 KB | None | 0 0
  1. # install.packages(c("wooldridge", "plm", "texreg"), dependencies = TRUE)
  2. library(wooldridge)
  3. data(wagepan)
  4. library(plm)
  5.  
  6. POLS <- plm(lwage ~ educ + black + hisp + exper+I(exper^2)+ married + union +
  7. factor(year), data = wagepan, index=c("nr","year") , model="pooling")
  8.  
  9. RE <- plm(lwage ~ educ + black + hisp + exper + I(exper^2) + married + union +
  10. factor(year), data = wagepan, index = c("nr","year") , model = "random")
  11.  
  12. FE <- plm(lwage ~ I(exper^2) + married + union + factor(year),
  13. data = wagepan, index = c("nr","year"), model="within")
  14.  
  15. # library(texreg)
  16. texreg::screenreg(list(POLS, RE, FE), custom.coef.map = list('married' = 'Marrtied', 'union' = 'Union'))
  17. #> ================================================
  18. #> Model 1 Model 2 Model 3
  19. #> ------------------------------------------------
  20. #> Marrtied 0.11 *** 0.06 *** 0.05 *
  21. #> (0.02) (0.02) (0.02)
  22. #> Union 0.18 *** 0.11 *** 0.08 ***
  23. #> (0.02) (0.02) (0.02)
  24. #> ------------------------------------------------
  25. #> R^2 0.19 0.18 0.18
  26. #> Adj. R^2 0.19 0.18 0.06
  27. #> Num. obs. 4360 4360 4360
  28. #> ================================================
  29. #> *** p < 0.001, ** p < 0.01, * p < 0.05
  30.  
  31. #> ------------------------------------------------
  32. #> Obs. (N) 4360 4360 4360
  33. #> Indiv.(n) 545 545 545
  34. #> Time (T) 8 8 8
  35. #> R^2 0.19 0.18 0.18
  36. #> Adj. R^2 0.19 0.18 0.06
  37. #> F-stat 72.458 68.4124 83.8515
  38. #> P-value (2.22e-16) (2.22e-16) (2.22e-16)
  39. #> ================================================
  40. #> *** p < 0.001, ** p < 0.01, * p < 0.05
  41.  
  42. library(texreg)
  43.  
  44. fv.1 <- summary(POLS)$fstatistic$statistic
  45. pv <- summary(POLS)$fstatistic$p.value
  46. rbind(f, p)
  47.  
  48. ex.1 <- extract(POLS)
  49. ex.1@gof.names <- c(ex.1@gof.names, "F-stat", "P-value")
  50. ex.1@gof <- c(ex.1@gof, fv.1, pv)
  51. ex.1@gof.decimal <- c(ex.1@gof.decimal, TRUE, TRUE)
  52.  
  53.  
  54. fv.2 <- summary(RE)$fstatistic$statistic
  55. pv <- summary(RE)$fstatistic$p.value
  56. rbind(f, p)
  57.  
  58. ex.2 <- extract(RE)
  59. ex.2@gof.names <- c(ex.2@gof.names, "F-stat", "P-value")
  60. ex.2@gof <- c(ex.2@gof, fv.2, pv)
  61. ex.2@gof.decimal <- c(ex.2@gof.decimal, TRUE, TRUE)
  62.  
  63.  
  64. fv.3 <- summary(FE)$fstatistic$statistic
  65. pv <- summary(FE)$fstatistic$p.value
  66. rbind(f, p)
  67.  
  68. ex.3 <- extract(FE)
  69. ex.3@gof.names <- c(ex.3@gof.names, "F-stat", "P-value")
  70. ex.3@gof <- c(ex.3@gof, fv.3, pv)
  71. ex.3@gof.decimal <- c(ex.3@gof.decimal, TRUE, TRUE)
  72.  
  73. > screenreg(list(ex.1, ex.2, ex.2))
  74.  
  75. =======================================================
  76. Model 1 Model 2 Model 3
  77. -------------------------------------------------------
  78. (Intercept) 0.09 0.02 0.02
  79. (0.08) (0.15) (0.15)
  80. educ 0.09 *** 0.09 *** 0.09 ***
  81. (0.01) (0.01) (0.01)
  82. black -0.14 *** -0.14 ** -0.14 **
  83. (0.02) (0.05) (0.05)
  84. hisp 0.02 0.02 0.02
  85. (0.02) (0.04) (0.04)
  86. exper 0.07 *** 0.11 *** 0.11 ***
  87. (0.01) (0.02) (0.02)
  88. I(exper^2) -0.00 ** -0.00 *** -0.00 ***
  89. (0.00) (0.00) (0.00)
  90. married 0.11 *** 0.06 *** 0.06 ***
  91. (0.02) (0.02) (0.02)
  92. union 0.18 *** 0.11 *** 0.11 ***
  93. (0.02) (0.02) (0.02)
  94. [...]
  95. -------------------------------------------------------
  96. R^2 0.19 0.18 0.18
  97. Adj. R^2 0.19 0.18 0.18
  98. Num. obs. 4360 4360 4360
  99. F-stat 72.46 68.41 68.41
  100. P-value 0.00 0.00 0.00
  101. =======================================================
  102. *** p < 0.001, ** p < 0.01, * p < 0.05
Add Comment
Please, Sign In to add comment