library(wooldridge)
library(rmarkdown)
data('fair')
paged_table(fair)

An updated version of this data set, through the 2004 election, is available at Professor Fair’s web site at Yale University: http://fairmodel.econ.yale.edu/rayfair/pdf/2001b.htm. Students might want to try their own hands at predicting the most recent election outcome, but they should be restricted to no more than a handful of explanatory variables because of the small sample size.

A data.frame with 21 observations on 28 variables:

year: 1916 to 1992, by 4

V: prop. dem. vote

I: =1 if demwh, -1 if repwh

DPER: incumbent running

DUR: duration

g3: avg ann grwth rte, prev 3 qrts

p15: avg ann inf rate, prev 15 qtrs

n: quarters of good news

g2: avg ann grwth rte, prev 2 qrts

gYR: ann grwth rte, prev year

p8: avg ann inf rate, prev 8 qtrs

p2YR: inf rte over 2 yr period

Ig2: I*g2

Ip8: I*p8

demwins: =1 if V > .5

In: I*n

d: =1 in 1920, 1944,1948

Id: I*d

Ig3: I*g3

Ip151md: Ip15(1-d)

In1md: In(1-d)

summary

summary is a generic function used to produce result summaries of the results of various model fitting functions. The function invokes particular methods which depend on the class of the first argument.

summary(lm(formula = year ~ V + I + DPER + DUR + g3 + p15 + n + g2 ,data = fair ))
## 
## Call:
## lm(formula = year ~ V + I + DPER + DUR + g3 + p15 + n + g2, data = fair)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -52.048  -9.538   1.930  11.281  32.791 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1966.0598    61.6036  31.915 5.65e-13 ***
## V             11.8044   118.3189   0.100    0.922    
## I              2.8140    19.1643   0.147    0.886    
## DPER          -6.5541    16.9384  -0.387    0.706    
## DUR           -3.6664    15.3962  -0.238    0.816    
## g3             3.2836     3.0825   1.065    0.308    
## p15           -0.2763     2.2225  -0.124    0.903    
## n             -2.6613     2.4014  -1.108    0.289    
## g2            -1.2098     2.5592  -0.473    0.645    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 27.23 on 12 degrees of freedom
## Multiple R-squared:  0.2777, Adjusted R-squared:  -0.2038 
## F-statistic: 0.5768 on 8 and 12 DF,  p-value: 0.7788

stargazer

library(stargazer)
## 
## Please cite as:
##  Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.3. https://CRAN.R-project.org/package=stargazer
model1 <- lm(year ~ V + I + DPER + DUR + g3 + p15 + n + g2 ,data = fair)
model1_2 <- lm(log(year) ~ V + I + DPER + DUR + g3 + p15 + n + g2 ,data = fair )
stargazer(model1,model1_2, type = "text")
## 
## ==========================================================
##                                   Dependent variable:     
##                               ----------------------------
##                                    year        log(year)  
##                                     (1)           (2)     
## ----------------------------------------------------------
## V                                 11.804         0.006    
##                                  (118.319)      (0.061)   
##                                                           
## I                                  2.814         0.001    
##                                  (19.164)       (0.010)   
##                                                           
## DPER                              -6.554         -0.003   
##                                  (16.938)       (0.009)   
##                                                           
## DUR                               -3.666         -0.002   
##                                  (15.396)       (0.008)   
##                                                           
## g3                                 3.284         0.002    
##                                   (3.083)       (0.002)   
##                                                           
## p15                               -0.276        -0.0001   
##                                   (2.223)       (0.001)   
##                                                           
## n                                 -2.661         -0.001   
##                                   (2.401)       (0.001)   
##                                                           
## g2                                -1.210         -0.001   
##                                   (2.559)       (0.001)   
##                                                           
## Constant                       1,966.060***     7.584***  
##                                  (61.604)       (0.032)   
##                                                           
## ----------------------------------------------------------
## Observations                        21             21     
## R2                                 0.278         0.276    
## Adjusted R2                       -0.204         -0.206   
## Residual Std. Error (df = 12)     27.231         0.014    
## F Statistic (df = 8; 12)           0.577         0.573    
## ==========================================================
## Note:                          *p<0.1; **p<0.05; ***p<0.01
lm(scale(year) ~ scale(I) + scale(DPER) +scale(DUR) + scale(g3) + scale(p15) + scale(n) + scale(g2) ,data = fair)
## 
## Call:
## lm(formula = scale(year) ~ scale(I) + scale(DPER) + scale(DUR) + 
##     scale(g3) + scale(p15) + scale(n) + scale(g2), data = fair)
## 
## Coefficients:
## (Intercept)     scale(I)  scale(DPER)   scale(DUR)    scale(g3)   scale(p15)  
##   1.026e-16    1.455e-01   -2.181e-01   -1.641e-01    7.739e-01   -4.634e-02  
##    scale(n)    scale(g2)  
##  -3.263e-01   -3.528e-01

logarithmic

lm(log(year) ~ V + I + DPER + DUR + g3 + p15 + n + g2 ,data = fair )
## 
## Call:
## lm(formula = log(year) ~ V + I + DPER + DUR + g3 + p15 + n + 
##     g2, data = fair)
## 
## Coefficients:
## (Intercept)            V            I         DPER          DUR           g3  
##   7.5835042    0.0064138    0.0013634   -0.0033267   -0.0018023    0.0016751  
##         p15            n           g2  
##  -0.0001427   -0.0013542   -0.0006157