Load Workspace

load("Claudia_Shiller_HW_021226.RData")

cat("Objects in workspace:\n")
## Objects in workspace:
print(ls())
##  [1] "comparison"        "dt"                "i"                
##  [4] "ie_data"           "ie_data_clean"     "ie_data_no_crisis"
##  [7] "model"             "model_full"        "model_no_crisis"  
## [10] "mpg"

Inspect All Objects

for (obj_name in ls()) {
  cat("\n========================================\n")
  cat("Object:", obj_name, "\n")
  cat("========================================\n")
  cat("Class:", class(get(obj_name)), "\n\n")
  
  obj <- get(obj_name)
  
  if (is.data.frame(obj) || inherits(obj, "data.table")) {
    cat("Dimensions:", nrow(obj), "rows x", ncol(obj), "columns\n")
    cat("\nColumn names:\n")
    print(names(obj))
    cat("\nFirst 5 rows:\n")
    print(head(obj, 5))
    cat("\nSummary:\n")
    print(summary(obj))
  } else if (inherits(obj, "lm")) {
    cat("\nRegression summary:\n")
    print(summary(obj))
  } else if (is.list(obj)) {
    cat("\nList structure:\n")
    print(str(obj))
  } else {
    cat("\nValue:\n")
    print(obj)
  }
}
## 
## ========================================
## Object: comparison 
## ========================================
## Class: data.frame 
## 
## Dimensions: 2 rows x 4 columns
## 
## Column names:
## [1] "Model"     "Intercept" "Slope"     "R_Squared"
## 
## First 5 rows:
##                 Model  Intercept       Slope R_Squared
## 1         Full Sample 0.06915811 0.001512485 0.1039074
## 2 Excluding 2007-2009 0.06992904 0.001496299 0.1061269
## 
## Summary:
##     Model             Intercept           Slope            R_Squared     
##  Length:2           Min.   :0.06916   Min.   :0.001496   Min.   :0.1039  
##  Class :character   1st Qu.:0.06935   1st Qu.:0.001500   1st Qu.:0.1045  
##  Mode  :character   Median :0.06954   Median :0.001504   Median :0.1050  
##                     Mean   :0.06954   Mean   :0.001504   Mean   :0.1050  
##                     3rd Qu.:0.06974   3rd Qu.:0.001508   3rd Qu.:0.1056  
##                     Max.   :0.06993   Max.   :0.001512   Max.   :0.1061  
## 
## ========================================
## Object: dt 
## ========================================
## Class: data.table data.frame 
## 
## Dimensions: 2459 rows x 27 columns
## 
## Column names:
##  [1] "Date"        "P"           "D"           "E"           "CPI"        
##  [6] "Fraction"    "Rate GS10"   "Price"       "Dividend"    "Price"      
## [11] "Earnings"    "Earnings"    "CAPE"        "V14"         "TR CAPE"    
## [16] "V16"         "Yield"       "Returns"     "Returns"     "Real Return"
## [21] "Real Return" "Returns"     "V23"         "V24"         "V25"        
## [26] "V26"         "CPI_lag12"  
## 
## First 5 rows:
##      Date    P    D   E   CPI Fraction Rate GS10  Price Dividend  Price
## 1 1871.01 4.44 0.26 0.4 12.46  1871.04      5.32 109.05     6.39 109.05
## 2 1871.02 4.50 0.26 0.4 12.84  1871.13      5.32 107.25     6.20 107.77
## 3 1871.03 4.61 0.26 0.4 13.03  1871.21      5.33 108.27     6.11 109.30
## 4 1871.04 4.74 0.26 0.4 12.56  1871.29      5.33 115.54     6.34 117.17
## 5 1871.05 4.86 0.26 0.4 12.27  1871.38      5.33 121.22     6.48 123.48
##   Earnings Earnings CAPE V14 TR CAPE V16 Yield Returns Returns Real Return
## 1     9.82     9.82   NA  NA      NA  NA             1    1.00      13.06%
## 2     9.53     9.58   NA  NA      NA  NA             1    0.97      13.09%
## 3     9.39     9.48   NA  NA      NA  NA             1    0.96      13.10%
## 4     9.75     9.89   NA  NA      NA  NA             1    1.00      12.21%
## 5     9.98    10.16   NA  NA      NA  NA             1    1.03      12.26%
##   Real Return Returns V23 V24 V25 V26 CPI_lag12
## 1       9.25%   3.81%  NA  NA  NA  NA      <NA>
## 2       9.46%   3.62%  NA  NA  NA  NA      <NA>
## 3       9.62%   3.48%  NA  NA  NA  NA      <NA>
## 4       9.10%   3.11%  NA  NA  NA  NA      <NA>
## 5       8.95%   3.31%  NA  NA  NA  NA      <NA>
## 
## Summary:
##       Date           P                   D                E           
##  Min.   :1871   Length:2459        Min.   : 0.180   Min.   :  0.1600  
##  1st Qu.:1909   Class :character   1st Qu.: 0.420   1st Qu.:  0.5725  
##  Median :1947   Mode  :character   Median : 0.930   Median :  1.5400  
##  Mean   :1947                      Mean   : 7.482   Mean   : 17.5837  
##  3rd Qu.:1985                      3rd Qu.: 7.705   3rd Qu.: 14.8975  
##  Max.   :2023                      Max.   :68.710   Max.   :197.9100  
##  NA's   :626                       NA's   :629      NA's   :629       
##      CPI               Fraction     Rate GS10             Price        
##  Length:2459        Min.   :1871   Length:2459        Min.   :  82.87  
##  Class :character   1st Qu.:1909   Class :character   1st Qu.: 210.30  
##  Mode  :character   Median :1947   Mode  :character   Median : 323.05  
##                     Mean   :1947                      Mean   : 743.79  
##                     3rd Qu.:1986                      3rd Qu.: 812.92  
##                     Max.   :2024                      Max.   :5140.59  
##                     NA's   :626                       NA's   :626      
##     Dividend        Price              Earnings        Earnings        
##  Min.   : 6.11   Length:2459        Min.   :  5.13   Length:2459       
##  1st Qu.:10.61   Class :character   1st Qu.: 15.87   Class :character  
##  Median :16.25   Mode  :character   Median : 27.05   Mode  :character  
##  Mean   :20.25                      Mean   : 41.17                     
##  3rd Qu.:25.74                      3rd Qu.: 49.65                     
##  Max.   :71.22                      Max.   :217.26                     
##  NA's   :629                        NA's   :629                        
##       CAPE         V14             TR CAPE           V16        
##  Min.   : 4.78   Mode:logical   Min.   : 6.58   Min.   :   1.7  
##  1st Qu.:11.95   NA's:2459      1st Qu.:15.44   1st Qu.: 356.1  
##  Median :16.50                  Median :20.51   Median : 710.4  
##  Mean   :17.40                  Mean   :20.82   Mean   : 710.4  
##  3rd Qu.:21.14                  3rd Qu.:24.71   3rd Qu.:1064.8  
##  Max.   :44.20                  Max.   :48.11   Max.   :1419.2  
##  NA's   :746                    NA's   :746     NA's   :2457    
##     Yield              Returns         Returns      Real Return       
##  Length:2459        Min.   :0.920   Min.   : 0.96   Length:2459       
##  Class :character   1st Qu.:1.000   1st Qu.: 6.35   Class :character  
##  Mode  :character   Median :1.000   Median :10.70   Mode  :character  
##                     Mean   :1.003   Mean   :14.97                     
##                     3rd Qu.:1.010   3rd Qu.:15.46                     
##                     Max.   :1.110   Max.   :59.45                     
##                     NA's   :627     NA's   :626                       
##  Real Return          Returns            V23            V24         
##  Length:2459        Length:2459        Mode:logical   Mode:logical  
##  Class :character   Class :character   NA's:2459      NA's:2459     
##  Mode  :character   Mode  :character                                
##                                                                     
##                                                                     
##                                                                     
##                                                                     
##    V25            V26           CPI_lag12        
##  Mode:logical   Mode:logical   Length:2459       
##  NA's:2459      NA's:2459      Class :character  
##                                Mode  :character  
##                                                  
##                                                  
##                                                  
##                                                  
## 
## ========================================
## Object: i 
## ========================================
## Class: integer 
## 
## 
## Value:
## [1] 1
## 
## ========================================
## Object: ie_data 
## ========================================
## Class: data.table data.frame 
## 
## Dimensions: 1836 rows x 36 columns
## 
## Column names:
##  [1] "Date"                "P"                   "D"                  
##  [4] "E"                   "CPI"                 "...6"               
##  [7] "...7"                "...8"                "...9"               
## [10] "...10"               "...11"               "...12"              
## [13] "...13"               "...14"               "...15"              
## [16] "...16"               "...17"               "...18"              
## [19] "...19"               "Stock_Returns"       "Bond_Returns"       
## [22] "...22"               "...23"               "...24"              
## [25] "...25"               "...26"               "CPI_lag12"          
## [28] "Inflation"           "Earnings_Yield"      "Year"               
## [31] "Period"              "Equity_Risk_Premium" "Inflation_60MA"     
## [34] "Date_numeric"        "Period_Original"     "Period_Alternative" 
## 
## First 5 rows:
##      Date    P    D   E   CPI     ...6      ...7   ...8     ...9  ...10
## 1      NA   NA <NA>  NA    NA     <NA>      <NA>   <NA>     <NA>   <NA>
## 2      NA   NA <NA>  NA    NA     <NA>      <NA>   <NA>     <NA>   <NA>
## 3      NA   NA    D  NA    NA Fraction Rate GS10  Price Dividend  Price
## 4 1871.01 4.44 0.26 0.4 12.46  1871.04      5.32 109.05     6.39 109.05
## 5 1871.02 4.50 0.26 0.4 12.84  1871.13      5.32 107.25     6.20 107.77
##      ...11    ...12      ...13 ...14      ...15 ...16 ...17   ...18   ...19
## 1     <NA>     <NA> Cyclically    NA Cyclically    NA  <NA>    <NA>    <NA>
## 2     <NA>     <NA>   Adjusted    NA   Adjusted    NA  <NA>    <NA>    <NA>
## 3 Earnings Earnings       CAPE    NA    TR CAPE    NA Yield Returns Returns
## 4     9.82     9.82       <NA>    NA       <NA>    NA  <NA>    1.00    1.00
## 5     9.53     9.58       <NA>    NA       <NA>    NA  <NA>    1.00    0.97
##   Stock_Returns Bond_Returns   ...22 ...23 ...24 ...25 ...26 CPI_lag12
## 1            NA           NA    <NA>    NA    NA    NA    NA        NA
## 2            NA           NA    <NA>    NA    NA    NA    NA        NA
## 3            NA           NA Returns    NA    NA    NA    NA        NA
## 4            NA           NA   3.81%    NA    NA    NA    NA        NA
## 5            NA           NA   3.62%    NA    NA    NA    NA        NA
##   Inflation Earnings_Yield Year      Period Equity_Risk_Premium Inflation_60MA
## 1        NA             NA   NA        <NA>                  NA             NA
## 2        NA             NA   NA        <NA>                  NA             NA
## 3        NA             NA   NA        <NA>                  NA             NA
## 4        NA     0.09009009 1871 Before 1945                  NA             NA
## 5        NA     0.08888889 1871 Before 1945                  NA             NA
##   Date_numeric Period_Original Period_Alternative
## 1           NA            <NA>               <NA>
## 2           NA            <NA>               <NA>
## 3           NA            <NA>               <NA>
## 4      1871.01     Before 1945            Pre-WWI
## 5      1871.02     Before 1945            Pre-WWI
## 
## Summary:
##       Date            P                D                   E           
##  Min.   :1871   Min.   :   2.73   Length:1836        Min.   :  0.1600  
##  1st Qu.:1909   1st Qu.:   7.93   Class :character   1st Qu.:  0.5725  
##  Median :1947   Median :  18.07   Mode  :character   Median :  1.5400  
##  Mean   :1947   Mean   : 376.97                      Mean   : 17.5837  
##  3rd Qu.:1985   3rd Qu.: 186.20                      3rd Qu.: 14.8975  
##  Max.   :2023   Max.   :4674.77                      Max.   :197.9100  
##  NA's   :3      NA's   :3                            NA's   :6         
##       CPI             ...6               ...7               ...8          
##  Min.   :  6.28   Length:1836        Length:1836        Length:1836       
##  1st Qu.: 10.28   Class :character   Class :character   Class :character  
##  Median : 21.90   Mode  :character   Mode  :character   Mode  :character  
##  Mean   : 65.33                                                           
##  3rd Qu.:107.80                                                           
##  Max.   :306.13                                                           
##  NA's   :3                                                                
##      ...9              ...10              ...11              ...12          
##  Length:1836        Length:1836        Length:1836        Length:1836       
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##     ...13            ...14            ...15               ...16       
##  Length:1836        Mode:logical   Length:1836        Min.   :   1.7  
##  Class :character   NA's:1836      Class :character   1st Qu.: 356.1  
##  Mode  :character                  Mode  :character   Median : 710.4  
##                                                       Mean   : 710.4  
##                                                       3rd Qu.:1064.8  
##                                                       Max.   :1419.2  
##                                                       NA's   :1834    
##     ...17              ...18              ...19           Stock_Returns 
##  Length:1836        Length:1836        Length:1836        Min.   : NA   
##  Class :character   Class :character   Class :character   1st Qu.: NA   
##  Mode  :character   Mode  :character   Mode  :character   Median : NA   
##                                                           Mean   :NaN   
##                                                           3rd Qu.: NA   
##                                                           Max.   : NA   
##                                                           NA's   :1836  
##   Bond_Returns     ...22            ...23          ...24          ...25        
##  Min.   : NA    Length:1836        Mode:logical   Mode:logical   Mode:logical  
##  1st Qu.: NA    Class :character   NA's:1836      NA's:1836      NA's:1836     
##  Median : NA    Mode  :character                                               
##  Mean   :NaN                                                                   
##  3rd Qu.: NA                                                                   
##  Max.   : NA                                                                   
##  NA's   :1836                                                                  
##   ...26           CPI_lag12        Inflation       Earnings_Yield    
##  Mode:logical   Min.   :  6.28   Min.   :-19.700   Min.   :0.008078  
##  NA's:1836      1st Qu.: 10.20   1st Qu.:  0.000   1st Qu.:0.054506  
##                 Median : 21.30   Median :  2.290   Median :0.067108  
##                 Mean   : 63.77   Mean   :  2.293   Mean   :0.072707  
##                 3rd Qu.:105.30   3rd Qu.:  4.678   3rd Qu.:0.086796  
##                 Max.   :296.81   Max.   : 23.669   Max.   :0.188235  
##                 NA's   :15       NA's   :15        NA's   :6         
##       Year         Period          Equity_Risk_Premium Inflation_60MA   
##  Min.   :1871   Length:1836        Min.   : NA         Min.   :-7.4145  
##  1st Qu.:1909   Class :character   1st Qu.: NA         1st Qu.: 0.9049  
##  Median :1947   Mode  :character   Median : NA         Median : 2.3078  
##  Mean   :1947                      Mean   :NaN         Mean   : 2.3037  
##  3rd Qu.:1985                      3rd Qu.: NA         3rd Qu.: 4.0581  
##  Max.   :2023                      Max.   : NA         Max.   :14.7814  
##  NA's   :3                         NA's   :1836        NA's   :74       
##   Date_numeric  Period_Original    Period_Alternative
##  Min.   :1871   Length:1836        Length:1836       
##  1st Qu.:1909   Class :character   Class :character  
##  Median :1947   Mode  :character   Mode  :character  
##  Mean   :1947                                        
##  3rd Qu.:1985                                        
##  Max.   :2023                                        
##  NA's   :3                                           
## 
## ========================================
## Object: ie_data_clean 
## ========================================
## Class: data.table data.frame 
## 
## Dimensions: 0 rows x 32 columns
## 
## Column names:
##  [1] "Date"                "P"                   "D"                  
##  [4] "E"                   "CPI"                 "...6"               
##  [7] "...7"                "...8"                "...9"               
## [10] "...10"               "...11"               "...12"              
## [13] "...13"               "...14"               "...15"              
## [16] "...16"               "...17"               "...18"              
## [19] "...19"               "Stock_Returns"       "Bond_Returns"       
## [22] "...22"               "...23"               "...24"              
## [25] "...25"               "...26"               "CPI_lag12"          
## [28] "Inflation"           "Earnings_Yield"      "Year"               
## [31] "Period"              "Equity_Risk_Premium"
## 
## First 5 rows:
##  [1] Date                P                   D                  
##  [4] E                   CPI                 ...6               
##  [7] ...7                ...8                ...9               
## [10] ...10               ...11               ...12              
## [13] ...13               ...14               ...15              
## [16] ...16               ...17               ...18              
## [19] ...19               Stock_Returns       Bond_Returns       
## [22] ...22               ...23               ...24              
## [25] ...25               ...26               CPI_lag12          
## [28] Inflation           Earnings_Yield      Year               
## [31] Period              Equity_Risk_Premium
## <0 rows> (or 0-length row.names)
## 
## Summary:
##       Date           P            D                   E            CPI     
##  Min.   : NA   Min.   : NA   Length:0           Min.   : NA   Min.   : NA  
##  1st Qu.: NA   1st Qu.: NA   Class :character   1st Qu.: NA   1st Qu.: NA  
##  Median : NA   Median : NA   Mode  :character   Median : NA   Median : NA  
##  Mean   :NaN   Mean   :NaN                      Mean   :NaN   Mean   :NaN  
##  3rd Qu.: NA   3rd Qu.: NA                      3rd Qu.: NA   3rd Qu.: NA  
##  Max.   : NA   Max.   : NA                      Max.   : NA   Max.   : NA  
##      ...6               ...7               ...8               ...9          
##  Length:0           Length:0           Length:0           Length:0          
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##     ...10              ...11              ...12              ...13          
##  Length:0           Length:0           Length:0           Length:0          
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##   ...14            ...15               ...16        ...17          
##  Mode:logical   Length:0           Min.   : NA   Length:0          
##                 Class :character   1st Qu.: NA   Class :character  
##                 Mode  :character   Median : NA   Mode  :character  
##                                    Mean   :NaN                     
##                                    3rd Qu.: NA                     
##                                    Max.   : NA                     
##     ...18              ...19           Stock_Returns  Bond_Returns
##  Length:0           Length:0           Min.   : NA   Min.   : NA  
##  Class :character   Class :character   1st Qu.: NA   1st Qu.: NA  
##  Mode  :character   Mode  :character   Median : NA   Median : NA  
##                                        Mean   :NaN   Mean   :NaN  
##                                        3rd Qu.: NA   3rd Qu.: NA  
##                                        Max.   : NA   Max.   : NA  
##     ...22            ...23          ...24          ...25          ...26        
##  Length:0           Mode:logical   Mode:logical   Mode:logical   Mode:logical  
##  Class :character                                                              
##  Mode  :character                                                              
##                                                                                
##                                                                                
##                                                                                
##    CPI_lag12     Inflation   Earnings_Yield      Year        Period         
##  Min.   : NA   Min.   : NA   Min.   : NA    Min.   : NA   Length:0          
##  1st Qu.: NA   1st Qu.: NA   1st Qu.: NA    1st Qu.: NA   Class :character  
##  Median : NA   Median : NA   Median : NA    Median : NA   Mode  :character  
##  Mean   :NaN   Mean   :NaN   Mean   :NaN    Mean   :NaN                     
##  3rd Qu.: NA   3rd Qu.: NA   3rd Qu.: NA    3rd Qu.: NA                     
##  Max.   : NA   Max.   : NA   Max.   : NA    Max.   : NA                     
##  Equity_Risk_Premium
##  Min.   : NA        
##  1st Qu.: NA        
##  Median : NA        
##  Mean   :NaN        
##  3rd Qu.: NA        
##  Max.   : NA        
## 
## ========================================
## Object: ie_data_no_crisis 
## ========================================
## Class: data.table data.frame 
## 
## Dimensions: 1797 rows x 36 columns
## 
## Column names:
##  [1] "Date"                "P"                   "D"                  
##  [4] "E"                   "CPI"                 "...6"               
##  [7] "...7"                "...8"                "...9"               
## [10] "...10"               "...11"               "...12"              
## [13] "...13"               "...14"               "...15"              
## [16] "...16"               "...17"               "...18"              
## [19] "...19"               "Stock_Returns"       "Bond_Returns"       
## [22] "...22"               "...23"               "...24"              
## [25] "...25"               "...26"               "CPI_lag12"          
## [28] "Inflation"           "Earnings_Yield"      "Year"               
## [31] "Period"              "Equity_Risk_Premium" "Inflation_60MA"     
## [34] "Date_numeric"        "Period_Original"     "Period_Alternative" 
## 
## First 5 rows:
##      Date    P    D   E   CPI    ...6 ...7   ...8 ...9  ...10 ...11 ...12 ...13
## 1 1871.01 4.44 0.26 0.4 12.46 1871.04 5.32 109.05 6.39 109.05  9.82  9.82  <NA>
## 2 1871.02 4.50 0.26 0.4 12.84 1871.13 5.32 107.25 6.20 107.77  9.53  9.58  <NA>
## 3 1871.03 4.61 0.26 0.4 13.03 1871.21 5.33 108.27 6.11 109.30  9.39  9.48  <NA>
## 4 1871.04 4.74 0.26 0.4 12.56 1871.29 5.33 115.54 6.34 117.17  9.75  9.89  <NA>
## 5 1871.05 4.86 0.26 0.4 12.27 1871.38 5.33 121.22 6.48 123.48  9.98 10.16  <NA>
##   ...14 ...15 ...16 ...17 ...18 ...19 Stock_Returns Bond_Returns ...22 ...23
## 1    NA  <NA>    NA  <NA>  1.00  1.00            NA           NA 3.81%    NA
## 2    NA  <NA>    NA  <NA>  1.00  0.97            NA           NA 3.62%    NA
## 3    NA  <NA>    NA  <NA>  1.00  0.96            NA           NA 3.48%    NA
## 4    NA  <NA>    NA  <NA>  1.00  1.00            NA           NA 3.11%    NA
## 5    NA  <NA>    NA  <NA>  1.00  1.03            NA           NA 3.31%    NA
##   ...24 ...25 ...26 CPI_lag12 Inflation Earnings_Yield Year      Period
## 1    NA    NA    NA        NA        NA     0.09009009 1871 Before 1945
## 2    NA    NA    NA        NA        NA     0.08888889 1871 Before 1945
## 3    NA    NA    NA        NA        NA     0.08676790 1871 Before 1945
## 4    NA    NA    NA        NA        NA     0.08438819 1871 Before 1945
## 5    NA    NA    NA        NA        NA     0.08230453 1871 Before 1945
##   Equity_Risk_Premium Inflation_60MA Date_numeric Period_Original
## 1                  NA             NA      1871.01     Before 1945
## 2                  NA             NA      1871.02     Before 1945
## 3                  NA             NA      1871.03     Before 1945
## 4                  NA             NA      1871.04     Before 1945
## 5                  NA             NA      1871.05     Before 1945
##   Period_Alternative
## 1            Pre-WWI
## 2            Pre-WWI
## 3            Pre-WWI
## 4            Pre-WWI
## 5            Pre-WWI
## 
## Summary:
##       Date            P                D                   E          
##  Min.   :1871   Min.   :   2.73   Length:1797        Min.   :  0.160  
##  1st Qu.:1908   1st Qu.:   7.87   Class :character   1st Qu.:  0.560  
##  Median :1945   Median :  17.06   Mode  :character   Median :  1.425  
##  Mean   :1946   Mean   : 360.19                      Mean   : 16.978  
##  3rd Qu.:1983   3rd Qu.: 151.90                      3rd Qu.: 14.727  
##  Max.   :2023   Max.   :4674.77                      Max.   :197.910  
##                                                      NA's   :3        
##       CPI             ...6               ...7               ...8          
##  Min.   :  6.28   Length:1797        Length:1797        Length:1797       
##  1st Qu.: 10.18   Class :character   Class :character   Class :character  
##  Median : 19.80   Mode  :character   Mode  :character   Mode  :character  
##  Mean   : 62.38                                                           
##  3rd Qu.: 98.60                                                           
##  Max.   :306.13                                                           
##                                                                           
##      ...9              ...10              ...11              ...12          
##  Length:1797        Length:1797        Length:1797        Length:1797       
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##     ...13            ...14            ...15               ...16       
##  Length:1797        Mode:logical   Length:1797        Min.   :   1.7  
##  Class :character   NA's:1797      Class :character   1st Qu.: 356.1  
##  Mode  :character                  Mode  :character   Median : 710.4  
##                                                       Mean   : 710.4  
##                                                       3rd Qu.:1064.8  
##                                                       Max.   :1419.2  
##                                                       NA's   :1795    
##     ...17              ...18              ...19           Stock_Returns 
##  Length:1797        Length:1797        Length:1797        Min.   : NA   
##  Class :character   Class :character   Class :character   1st Qu.: NA   
##  Mode  :character   Mode  :character   Mode  :character   Median : NA   
##                                                           Mean   :NaN   
##                                                           3rd Qu.: NA   
##                                                           Max.   : NA   
##                                                           NA's   :1797  
##   Bond_Returns     ...22            ...23          ...24          ...25        
##  Min.   : NA    Length:1797        Mode:logical   Mode:logical   Mode:logical  
##  1st Qu.: NA    Class :character   NA's:1797      NA's:1797      NA's:1797     
##  Median : NA    Mode  :character                                               
##  Mean   :NaN                                                                   
##  3rd Qu.: NA                                                                   
##  Max.   : NA                                                                   
##  NA's   :1797                                                                  
##   ...26           CPI_lag12        Inflation       Earnings_Yield   
##  Mode:logical   Min.   :  6.28   Min.   :-19.700   Min.   :0.02141  
##  NA's:1797      1st Qu.: 10.18   1st Qu.:  0.000   1st Qu.:0.05508  
##                 Median : 18.90   Median :  2.285   Median :0.06770  
##                 Mean   : 60.86   Mean   :  2.296   Mean   :0.07344  
##                 3rd Qu.: 97.50   3rd Qu.:  4.706   3rd Qu.:0.08712  
##                 Max.   :296.81   Max.   : 23.669   Max.   :0.18824  
##                 NA's   :12       NA's   :12        NA's   :3        
##       Year         Period          Equity_Risk_Premium Inflation_60MA   
##  Min.   :1871   Length:1797        Min.   : NA         Min.   :-7.4145  
##  1st Qu.:1908   Class :character   1st Qu.: NA         1st Qu.: 0.7664  
##  Median :1945   Mode  :character   Median : NA         Median : 2.2526  
##  Mean   :1946                      Mean   :NaN         Mean   : 2.2912  
##  3rd Qu.:1983                      3rd Qu.: NA         3rd Qu.: 4.1329  
##  Max.   :2023                      Max.   : NA         Max.   :14.7814  
##                                    NA's   :1797        NA's   :71       
##   Date_numeric  Period_Original    Period_Alternative
##  Min.   :1871   Length:1797        Length:1797       
##  1st Qu.:1908   Class :character   Class :character  
##  Median :1945   Mode  :character   Mode  :character  
##  Mean   :1946                                        
##  3rd Qu.:1983                                        
##  Max.   :2023                                        
##                                                      
## 
## ========================================
## Object: model 
## ========================================
## Class: lm 
## 
## 
## Regression summary:
## 
## Call:
## lm(formula = Earnings_Yield ~ Inflation, data = ie_data)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.059698 -0.017785 -0.005258  0.016187  0.103894 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 0.0691581  0.0006518  106.10   <2e-16 ***
## Inflation   0.0015125  0.0001042   14.51   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.02586 on 1816 degrees of freedom
##   (18 observations deleted due to missingness)
## Multiple R-squared:  0.1039, Adjusted R-squared:  0.1034 
## F-statistic: 210.6 on 1 and 1816 DF,  p-value: < 2.2e-16
## 
## 
## ========================================
## Object: model_full 
## ========================================
## Class: lm 
## 
## 
## Regression summary:
## 
## Call:
## lm(formula = Earnings_Yield ~ Inflation, data = ie_data)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.059698 -0.017785 -0.005258  0.016187  0.103894 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 0.0691581  0.0006518  106.10   <2e-16 ***
## Inflation   0.0015125  0.0001042   14.51   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.02586 on 1816 degrees of freedom
##   (18 observations deleted due to missingness)
## Multiple R-squared:  0.1039, Adjusted R-squared:  0.1034 
## F-statistic: 210.6 on 1 and 1816 DF,  p-value: < 2.2e-16
## 
## 
## ========================================
## Object: model_no_crisis 
## ========================================
## Class: lm 
## 
## 
## Regression summary:
## 
## Call:
## lm(formula = Earnings_Yield ~ Inflation, data = ie_data_no_crisis)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.050729 -0.017964 -0.005093  0.015861  0.103109 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 0.0699290  0.0006486  107.81   <2e-16 ***
## Inflation   0.0014963  0.0001029   14.54   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.0255 on 1780 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.1061, Adjusted R-squared:  0.1056 
## F-statistic: 211.3 on 1 and 1780 DF,  p-value: < 2.2e-16
## 
## 
## ========================================
## Object: mpg 
## ========================================
## Class: numeric 
## 
## 
## Value:
## [1] 4

Data Visualizations

library(ggplot2)
library(data.table)

if (exists("ie_data")) {
  setDT(ie_data)
  
  if ("Date" %in% names(ie_data) && "Inflation" %in% names(ie_data)) {
    cat("\n### Inflation Over Time\n\n")
    p1 <- ggplot(ie_data, aes(x = Date, y = Inflation)) +
      geom_line(color = "blue") +
      labs(title = "Inflation Over Time", x = "Year", y = "Inflation (%)") +
      theme_minimal()
    print(p1)
  }
  
  if ("Date" %in% names(ie_data) && "Earnings_Yield" %in% names(ie_data)) {
    cat("\n### Earnings Yield Over Time\n\n")
    p2 <- ggplot(ie_data, aes(x = Date, y = Earnings_Yield)) +
      geom_line(color = "darkgreen") +
      labs(title = "Earnings Yield Over Time", x = "Year", y = "E/P Ratio") +
      theme_minimal()
    print(p2)
  }
  
  if ("Inflation" %in% names(ie_data) && "Earnings_Yield" %in% names(ie_data)) {
    cat("\n### Inflation vs Earnings Yield\n\n")
    p3 <- ggplot(ie_data, aes(x = Inflation, y = Earnings_Yield)) +
      geom_point(alpha = 0.5) +
      geom_smooth(method = "lm", color = "red") +
      labs(title = "Inflation vs Earnings Yield", x = "Inflation (%)", y = "E/P Ratio") +
      theme_minimal()
    print(p3)
  }
  
  if ("Inflation_60MA" %in% names(ie_data)) {
    cat("\n### Inflation with 60-Month Moving Average\n\n")
    p4 <- ggplot(ie_data, aes(x = Date)) +
      geom_line(aes(y = Inflation, color = "Raw"), alpha = 0.5) +
      geom_line(aes(y = Inflation_60MA, color = "60-Month MA"), size = 1) +
      labs(title = "Inflation and Rolling Mean", x = "Year", y = "Inflation (%)") +
      theme_minimal() +
      scale_color_manual(values = c("Raw" = "gray", "60-Month MA" = "red"))
    print(p4)
  }
}

Inflation Over Time

### Earnings Yield Over Time

### Inflation vs Earnings Yield

### Inflation with 60-Month Moving Average

Statistical Models

model_objects <- ls()[grepl("model", ls())]

for (model_name in model_objects) {
  cat("\n###", model_name, "\n\n")
  model <- get(model_name)
  if (inherits(model, "lm")) {
    print(summary(model))
    cat("\n")
  }
}

model

Call: lm(formula = Earnings_Yield ~ Inflation, data = ie_data)

Residuals: Min 1Q Median 3Q Max -0.059698 -0.017785 -0.005258 0.016187 0.103894

Coefficients: Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.0691581 0.0006518 106.10 <2e-16 Inflation 0.0015125 0.0001042 14.51 <2e-16 — Signif. codes: 0 ‘’ 0.001 ’’ 0.01 ’’ 0.05 ‘.’ 0.1 ’ ’ 1

Residual standard error: 0.02586 on 1816 degrees of freedom (18 observations deleted due to missingness) Multiple R-squared: 0.1039, Adjusted R-squared: 0.1034 F-statistic: 210.6 on 1 and 1816 DF, p-value: < 2.2e-16

model_full

Call: lm(formula = Earnings_Yield ~ Inflation, data = ie_data)

Residuals: Min 1Q Median 3Q Max -0.059698 -0.017785 -0.005258 0.016187 0.103894

Coefficients: Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.0691581 0.0006518 106.10 <2e-16 Inflation 0.0015125 0.0001042 14.51 <2e-16 — Signif. codes: 0 ‘’ 0.001 ’’ 0.01 ’’ 0.05 ‘.’ 0.1 ’ ’ 1

Residual standard error: 0.02586 on 1816 degrees of freedom (18 observations deleted due to missingness) Multiple R-squared: 0.1039, Adjusted R-squared: 0.1034 F-statistic: 210.6 on 1 and 1816 DF, p-value: < 2.2e-16

model_no_crisis

Call: lm(formula = Earnings_Yield ~ Inflation, data = ie_data_no_crisis)

Residuals: Min 1Q Median 3Q Max -0.050729 -0.017964 -0.005093 0.015861 0.103109

Coefficients: Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.0699290 0.0006486 107.81 <2e-16 Inflation 0.0014963 0.0001029 14.54 <2e-16 — Signif. codes: 0 ‘’ 0.001 ’’ 0.01 ’’ 0.05 ‘.’ 0.1 ’ ’ 1

Residual standard error: 0.0255 on 1780 degrees of freedom (15 observations deleted due to missingness) Multiple R-squared: 0.1061, Adjusted R-squared: 0.1056 F-statistic: 211.3 on 1 and 1780 DF, p-value: < 2.2e-16

Period Analysis

if (exists("ie_data") && "Period" %in% names(ie_data)) {
  setDT(ie_data)
  
  period_stats <- ie_data[, .(
    N = .N,
    Mean_Inflation = mean(Inflation, na.rm = TRUE),
    SD_Inflation = sd(Inflation, na.rm = TRUE),
    Mean_Earnings_Yield = mean(Earnings_Yield, na.rm = TRUE),
    SD_Earnings_Yield = sd(Earnings_Yield, na.rm = TRUE)
  ), by = Period]
  
  print(period_stats)
}
##         Period     N Mean_Inflation SD_Inflation Mean_Earnings_Yield
##         <char> <int>          <num>        <num>               <num>
## 1:        <NA>    15      2.2736739    0.2409016          0.06469783
## 2: Before 1945   888      0.7460954    7.3611513          0.07819083
## 3:   1946-1969   288      3.0813058    3.8721400          0.07899016
## 4:   1970-1999   360      5.2191111    3.1363085          0.07614543
## 5:  After 2000   285      2.5531815    1.8110133          0.04497078
##    SD_Earnings_Yield
##                <num>
## 1:       0.004906284
## 2:       0.023154778
## 3:       0.030164967
## 4:       0.029649455
## 5:       0.012590900

Session Info

sessionInfo()
## R version 4.5.1 (2025-06-13)
## Platform: aarch64-apple-darwin20
## Running under: macOS Tahoe 26.1
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib 
## LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## time zone: America/New_York
## tzcode source: internal
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] data.table_1.18.2.1 ggplot2_4.0.1      
## 
## loaded via a namespace (and not attached):
##  [1] Matrix_1.7-3       gtable_0.3.6       jsonlite_2.0.0     dplyr_1.1.4       
##  [5] compiler_4.5.1     tidyselect_1.2.1   jquerylib_0.1.4    splines_4.5.1     
##  [9] scales_1.4.0       yaml_2.3.12        fastmap_1.2.0      lattice_0.22-7    
## [13] R6_2.6.1           labeling_0.4.3     generics_0.1.4     knitr_1.51        
## [17] tibble_3.3.0       bslib_0.10.0       pillar_1.11.1      RColorBrewer_1.1-3
## [21] rlang_1.1.6        cachem_1.1.0       xfun_0.56          sass_0.4.10       
## [25] S7_0.2.1           cli_3.6.5          withr_3.0.2        magrittr_2.0.4    
## [29] mgcv_1.9-3         digest_0.6.39      grid_4.5.1         rstudioapi_0.18.0 
## [33] lifecycle_1.0.4    nlme_3.1-168       vctrs_0.6.5        evaluate_1.0.5    
## [37] glue_1.8.0         farver_2.1.2       rmarkdown_2.30     tools_4.5.1       
## [41] pkgconfig_2.0.3    htmltools_0.5.9