Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. set.seed(01349)
  2. DF <- data.frame(y = rnorm(100), x1A = rnorm(100), x2A = rnorm(100),
  3. x1B = rnorm(100), x2B = rnorm(100))
  4. regs <- lapply(paste0("x", 1:2, c("A", "A", "B", "B")), function(x)
  5. lm(paste0("y ~ ", x), data = DF))
  6.  
  7. texreg(regs, custom.coef.names = c("Intercept", rep("x", 4)),
  8. custom.model.names = c("1", "2", "1", "2"))
  9.  
  10. begin{table}
  11. begin{center}
  12. begin{tabular}{l c c c c }
  13. hline
  14. & 1 & 2 & 1 & 2 \
  15. hline
  16. Intercept & $-0.13$ & $-0.13$ & $-0.11$ & $-0.11$ \
  17. & $(0.12)$ & $(0.12)$ & $(0.12)$ & $(0.12)$ \
  18. x & $0.02$ & $0.07$ & $0.13$ & $-0.11$ \
  19. & $(0.13)$ & $(0.12)$ & $(0.12)$ & $(0.13)$ \
  20. hline
  21. R$^2$ & 0.00 & 0.00 & 0.01 & 0.01 \
  22. Adj. R$^2$ & -0.01 & -0.01 & 0.00 & -0.00 \
  23. Num. obs. & 100 & 100 & 100 & 100 \
  24. RMSE & 1.18 & 1.17 & 1.17 & 1.17 \
  25. hline
  26. multicolumn{5}{l}{scriptsize{$^{***}p<0.001$, $^{**}p<0.01$, $^*p<0.05$}}
  27. end{tabular}
  28. caption{Statistical models}
  29. label{table:coefficients}
  30. end{center}
  31. end{table}
  32.  
  33. begin{table}
  34. begin{center}
  35. begin{tabular}{l c c c c }
  36. hline
  37. %*************A HEADER LINE HERE*********************
  38. & multicolumn{2}{c}{A} & multicolumn{2}{c}{B} \ %
  39. %****************************************************
  40. & 1 & 2 & 1 & 2 \
  41. hline
  42. Intercept & $-0.13$ & $-0.13$ & $-0.11$ & $-0.11$ \
  43. & $(0.12)$ & $(0.12)$ & $(0.12)$ & $(0.12)$ \
  44. x & $0.02$ & $0.07$ & $0.13$ & $-0.11$ \
  45. & $(0.13)$ & $(0.12)$ & $(0.12)$ & $(0.13)$ \
  46. hline
  47. R$^2$ & 0.00 & 0.00 & 0.01 & 0.01 \
  48. Adj. R$^2$ & -0.01 & -0.01 & 0.00 & -0.00 \
  49. Num. obs. & 100 & 100 & 100 & 100 \
  50. RMSE & 1.18 & 1.17 & 1.17 & 1.17 \
  51. hline
  52. multicolumn{5}{l}{scriptsize{$^{***}p<0.001$, $^{**}p<0.01$, $^*p<0.05$}}
  53. end{tabular}
  54. caption{Statistical models}
  55. label{table:coefficients}
  56. end{center}
  57. end{table}
  58.  
  59. x <- capture.output(texreg(
  60. regs, custom.coef.names = c("Intercept", rep("x", 4)),
  61. custom.model.names = c("1", "2", "1", "2")))
  62.  
  63. x[6] <- paste0("& \multicolumn{2}{c}{A} & \multicolumn{2}{c}{B} \\ n", x[6])
  64.  
  65. cat(x, sep = "n")
  66.  
  67. texreg
  68. function (l, file = NULL, single.row = FALSE, stars = c(0.001,
  69. 0.01, 0.05), custom.model.names = NULL,...
  70.  
  71. begin{table}
  72. begin{center}
  73. begin{tabular}{l c c c c }
  74. hline
  75. & Model 1 & Model 2 & Model 3 & Model 4 \
  76.  
  77. string <- paste0(string, "\begin{tabular}{", coldef,
  78. "}", linesep)
  79.  
  80. string <- paste0(string, "\begin{tabular}{", coldef,
  81. "}", linesep)
  82. ## Additions
  83. string <- paste0(string, "\\[-1.8ex]\hline", linesep)
  84. string <- paste0(string, "& \multicolumn{", length(l),
  85. "}{c}{\textit{Dependent variable:}} \\", linesep)
  86. string <- paste0(string, "\cline{2-5}", linesep)
  87. string <- paste0(string, "\\[-1.8ex] & \multicolumn{", length(l),
  88. "}{c}{", dep.var, "} \\", linesep)
  89.  
  90. texreg2 <- function (l, file = NULL, single.row = FALSE, ...)
  91.  
  92. environment(texreg2) <- asNamespace('texreg')
  93.  
  94. texreg2(out, dep.var = "Normalize Citation Score")
  95.  
  96. begin{table}
  97. begin{center}
  98. begin{tabular}{l c c c c }
  99. \[-1.8ex]hline
  100. & multicolumn{4}{c}{textit{Dependent variable:}} \
  101. cline{2-5}
  102. \[-1.8ex] & multicolumn{4}{c}{Normalize Citation Score} \
  103. hline
  104. & Model 1 & Model 2 & Model 3 & Model 4 \
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement