Estout demo

2,342 views

Published on

I gave a short talk at New England R Users Group in August 2010. This talk includes a short econometric regression and code to export the regression results into LaTeX or a CSV file.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,342
On SlideShare
0
From Embeds
0
Number of Embeds
953
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Estout demo

  1. 1. {estout} for R Regression Output for *.csv, *.tex Formats Ben Mazzotta Fletcher School August 24, 2010 Ben Mazzotta (Fletcher School) Estout Demo August 24, 2010 1 / 11
  2. 2. 1 Regression Output 2 {estout} Ben Mazzotta (Fletcher School) Estout Demo August 24, 2010 2 / 11
  3. 3. Regression Y = βX + γC + (1) Figure 1: A generic OLS regression model Key features Multiple specifications α significance level σβ precision of the coefficient estimates Ben Mazzotta (Fletcher School) Estout Demo August 24, 2010 3 / 11
  4. 4. Output Figure 2: Sample outreg output Ben Mazzotta (Fletcher School) Estout Demo August 24, 2010 4 / 11
  5. 5. 1 Regression Output 2 {estout} Ben Mazzotta (Fletcher School) Estout Demo August 24, 2010 5 / 11
  6. 6. Code I Preliminaries library(datasets) data(freeny) names(freeny) names(freeny) <- c("y","lag.rev","price","income", "potential") Regressions reg1 <- lm(y ~ lag.rev + price, data=freeny) reg2 <- lm(y ~ lag.rev + price + income, data=freeny) reg3 <- lm(y ~ lag.rev + price + income + potential, data=freeny)
  7. 7. Code II Output descriptive statistics # Open the estout package library(estout) # Write the descriptive statistics # Specify the objects descsto(freeny) # Write to files desctab(filename="freeny", csv=FALSE) desctab(filename="freeny", csv=TRUE) Ben Mazzotta (Fletcher School) Estout Demo August 24, 2010 7 / 11
  8. 8. Code III Output regression estimates # Store the objects eststo(reg1) eststo(reg2) eststo(reg3) # Write to file esttab(filename="freeny.reg", csv=FALSE) esttab(filename="freeny.reg", csv=TRUE)
  9. 9. Descriptive Statistics in LaTeX Min. 1st Qu. Median Mean 3rd Qu. Max. Missing Values y 8.791 9.045 9.314 9.306 9.591 9.794 0 lag.quarterly.revenue 8.791 9.02 9.284 9.281 9.561 9.775 0 price.index 4.278 4.392 4.51 4.496 4.605 4.71 0 income.level 5.821 5.948 6.061 6.039 6.139 6.2 0 market.potential 12.97 13.01 13.07 13.07 13.12 13.17 0 Ben Mazzotta (Fletcher School) Estout Demo August 24, 2010 9 / 11
  10. 10. Regression in CSV Figure 3: CSV format output Ben Mazzotta (Fletcher School) Estout Demo August 24, 2010 10 / 11
  11. 11. Regression in LaTeX (1) (2) (3) y y y (Intercept) 2.186 4.971∗∗∗ -10.473∗ (1.472) (1.24) (6.022) lag.rev 0.891∗∗∗ 0.373∗∗∗ 0.124 (0.074) (0.114) (0.142) price -0.256 -0.819∗∗∗ -0.754∗∗∗ (0.175) (0.172) (0.161) income 0.754∗∗∗ 0.767∗∗∗ (0.145) (0.134) potential 1.331∗∗ (0.509) R2 0.996 0.998 0.998 adj.R 2 0.996 0.997 0.998 N 39 39 39 Standard errors in parentheses ∗ ∗∗ ∗∗∗ (p ≤ 0.1), (p ≤ 0.05), (p ≤ 0.01) Table 1: LaTeX format output Ben Mazzotta (Fletcher School) Estout Demo August 24, 2010 11 / 11

×