Panel Data

Author

Nuobing(Amy) Fan

do these for key variables– 1. Economic magnitute inde 2. direction (positive) 3. Expected effect (negative NOTE!!!) 4. statistic significant Beta1/(standard Error bata1) NULL!!! NULL effect

#Set up environment

#Clear workspace
rm(list = ls())
gc()
          used (Mb) gc trigger (Mb) max used (Mb)
Ncells  578798 31.0    1323511 70.7   660394 35.3
Vcells 1049087  8.1    8388608 64.0  1769558 13.6
# Clear the console
cat("\f")       
# Clear all graphs
graphics.off()  

# Identify components
entity_component <- "firm"
time_component <- "year"

2. Type out meaningful estimating equation and run the OLS regression/estimate the coefficients.

Do the estimated coefficients make sense (direction, magnitude, statistical significance)? Could there be omitted variable bias that could potentially be reduced by throwing in fixed effects?

\[ Investment_i = \beta_0 + \beta_1 Value_i + \epsilon_i \]

# Run OLS regression
ols_model <- lm(inv ~ value , data = Grunfeld)
summary(ols_model)

Call:
lm(formula = inv ~ value, data = Grunfeld)

Residuals:
    Min      1Q  Median      3Q     Max 
-344.08  -36.81    1.30   33.84  702.82 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) -6.976284  10.272724  -0.679    0.498    
value        0.141386   0.006044  23.394   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 112.1 on 198 degrees of freedom
Multiple R-squared:  0.7343,    Adjusted R-squared:  0.733 
F-statistic: 547.3 on 1 and 198 DF,  p-value: < 2.2e-16
stargazer(ols_model, type = "text")

===============================================
                        Dependent variable:    
                    ---------------------------
                                inv            
-----------------------------------------------
value                        0.141***          
                              (0.006)          
                                               
Constant                      -6.976           
                             (10.273)          
                                               
-----------------------------------------------
Observations                    200            
R2                             0.734           
Adjusted R2                    0.733           
Residual Std. Error     112.066 (df = 198)     
F Statistic          547.297*** (df = 1; 198)  
===============================================
Note:               *p<0.1; **p<0.05; ***p<0.01

Direction: The coefficient for value is 0.141, indicating a positive relationship with investment. Magnitude: This means for every unit increase in value, investment increases by approximately 0.141 units. Statistical Significance: The p-value is < 2e-16, which is highly significant, confirming that value is a strong predictor of investment. Omitted Variable Bias: There could be unobserved factors influencing both investment and value, such as firm characteristics or economic conditions. Including fixed effects could help mitigate this bias.

Summary

The OLS results suggest that higher value is associated with increased investment, with a significant and positive effect. However, potential omitted variable bias indicates that fixed effects modeling might provide more accurate estimates.

3. Now, run a fixed effects model (there are three different ways to do so). Type out the estimating equation (pay attention to the subscript).

Do your coefficients change? Why or why not? Tell us what the fixed effects controlling for (time-invariant characteristics of the entity, or time-varying characteristics affecting all entities, or both - based on your specification)? It is common to include both time and entity fixed effects in many applications in Economics. Do you get the same coefficient if you specify the Fixed Effect in an alternative way? Show (or at least argue).

\[ Investment_i = \beta_0 + \beta_1 Value_i + \beta_2 Capital + \epsilon_i \]

# Convert to panel data frame
pdata <- pdata.frame(Grunfeld, index = c("firm", "year"))

# Run fixed effects model
fe_model <- plm(inv ~ value + capital, data = pdata, model = "within")
summary(fe_model)
Oneway (individual) effect Within Model

Call:
plm(formula = inv ~ value + capital, data = pdata, model = "within")

Balanced Panel: n = 10, T = 20, N = 200

Residuals:
      Min.    1st Qu.     Median    3rd Qu.       Max. 
-184.00857  -17.64316    0.56337   19.19222  250.70974 

Coefficients:
        Estimate Std. Error t-value  Pr(>|t|)    
value   0.110124   0.011857  9.2879 < 2.2e-16 ***
capital 0.310065   0.017355 17.8666 < 2.2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Total Sum of Squares:    2244400
Residual Sum of Squares: 523480
R-Squared:      0.76676
Adj. R-Squared: 0.75311
F-statistic: 309.014 on 2 and 188 DF, p-value: < 2.22e-16
# Fixed Effects with dummy variables for each firm
fe_model_dummy <- lm(inv ~ value + capital + factor(firm), data = Grunfeld)
summary(fe_model_dummy)

Call:
lm(formula = inv ~ value + capital + factor(firm), data = Grunfeld)

Residuals:
     Min       1Q   Median       3Q      Max 
-184.009  -17.643    0.563   19.192  250.710 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     -70.29672   49.70796  -1.414    0.159    
value             0.11012    0.01186   9.288  < 2e-16 ***
capital           0.31007    0.01735  17.867  < 2e-16 ***
factor(firm)2   172.20253   31.16126   5.526 1.08e-07 ***
factor(firm)3  -165.27512   31.77556  -5.201 5.14e-07 ***
factor(firm)4    42.48742   43.90988   0.968    0.334    
factor(firm)5   -44.32010   50.49226  -0.878    0.381    
factor(firm)6    47.13542   46.81068   1.007    0.315    
factor(firm)7     3.74324   50.56493   0.074    0.941    
factor(firm)8    12.75106   44.05263   0.289    0.773    
factor(firm)9   -16.92555   48.45327  -0.349    0.727    
factor(firm)10   63.72887   50.33023   1.266    0.207    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 52.77 on 188 degrees of freedom
Multiple R-squared:  0.9441,    Adjusted R-squared:  0.9408 
F-statistic: 288.5 on 11 and 188 DF,  p-value: < 2.2e-16
# Demean the data
Grunfeld_demeaned <- Grunfeld %>%
  group_by(firm) %>%
  mutate(inv_demeaned = inv - mean(inv),
         value_demeaned = value - mean(value),
         capital_demeaned = capital - mean(capital))

# Run regression on demeaned data
fe_model_demeaned <- lm(inv_demeaned ~ value_demeaned + capital_demeaned, data = Grunfeld_demeaned)
summary(fe_model_demeaned)

Call:
lm(formula = inv_demeaned ~ value_demeaned + capital_demeaned, 
    data = Grunfeld_demeaned)

Residuals:
     Min       1Q   Median       3Q      Max 
-184.009  -17.643    0.563   19.192  250.710 

Coefficients:
                  Estimate Std. Error t value Pr(>|t|)    
(Intercept)      3.541e-15  3.645e+00   0.000        1    
value_demeaned   1.101e-01  1.158e-02   9.508   <2e-16 ***
capital_demeaned 3.101e-01  1.695e-02  18.289   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 51.55 on 197 degrees of freedom
Multiple R-squared:  0.7668,    Adjusted R-squared:  0.7644 
F-statistic: 323.8 on 2 and 197 DF,  p-value: < 2.2e-16
# Comparison of the fixed effects models
stargazer(fe_model, fe_model_dummy, fe_model_demeaned, 
          type = "text", 
          title = "Comparison of Fixed Effects Models",
          column.labels = c("Fixed Effects (plm)", "Fixed Effects (Dummy)", "Demeaned Fixed Effects"),
          dep.var.labels = "Investment")

Comparison of Fixed Effects Models
===============================================================================================
                                                Dependent variable:                            
                    ---------------------------------------------------------------------------
                                        Investment                           inv_demeaned      
                             panel                      OLS                      OLS           
                             linear                                                            
                      Fixed Effects (plm)      Fixed Effects (Dummy)    Demeaned Fixed Effects 
                              (1)                       (2)                      (3)           
-----------------------------------------------------------------------------------------------
value                       0.110***                 0.110***                                  
                            (0.012)                   (0.012)                                  
                                                                                               
capital                     0.310***                 0.310***                                  
                            (0.017)                   (0.017)                                  
                                                                                               
factor(firm)2                                       172.203***                                 
                                                     (31.161)                                  
                                                                                               
factor(firm)3                                       -165.275***                                
                                                     (31.776)                                  
                                                                                               
factor(firm)4                                         42.487                                   
                                                     (43.910)                                  
                                                                                               
factor(firm)5                                         -44.320                                  
                                                     (50.492)                                  
                                                                                               
factor(firm)6                                         47.135                                   
                                                     (46.811)                                  
                                                                                               
factor(firm)7                                          3.743                                   
                                                     (50.565)                                  
                                                                                               
factor(firm)8                                         12.751                                   
                                                     (44.053)                                  
                                                                                               
factor(firm)9                                         -16.926                                  
                                                     (48.453)                                  
                                                                                               
factor(firm)10                                        63.729                                   
                                                     (50.330)                                  
                                                                                               
value_demeaned                                                                 0.110***        
                                                                               (0.012)         
                                                                                               
capital_demeaned                                                               0.310***        
                                                                               (0.017)         
                                                                                               
Constant                                              -70.297                   0.000          
                                                     (49.708)                  (3.645)         
                                                                                               
-----------------------------------------------------------------------------------------------
Observations                  200                       200                      200           
R2                           0.767                     0.944                    0.767          
Adjusted R2                  0.753                     0.941                    0.764          
Residual Std. Error                              52.768 (df = 188)        51.549 (df = 197)    
F Statistic         309.014*** (df = 2; 188) 288.500*** (df = 11; 188) 323.807*** (df = 2; 197)
===============================================================================================
Note:                                                               *p<0.1; **p<0.05; ***p<0.01

Direction: Both coefficients are positive, reflecting a positive relationship with investment. Expected Effect: We expect a positive effect on investment from both value and capital. Statistical Significance: Both coefficients are statistically significant (p < 0.001), indicating meaningful impacts on investment. Coefficient Changes: Coefficients remain consistent across fixed effects and OLS models but may slightly differ due to unobserved characteristics being controlled. Fixed Effects Control: Fixed effects control for time-invariant characteristics of firms, addressing omitted variable bias. Comparison of Models: Fixed effects models yield similar coefficients to OLS but provide more reliable estimates by accounting for firm-specific factors.

The coefficients change when moving from OLS to fixed effects models due to the latter controlling for unobserved, time-invariant characteristics of the entities, which can lead to omitted variable bias in OLS. Fixed effects effectively isolate the influence of time-varying predictors on the dependent variable by removing the impact of these constant factors. While different specifications of fixed effects (like using dummy variables versus the plm package) may yield slightly different coefficients, the underlying relationships they represent should remain consistent. Thus, fixed effects models enhance the robustness of the analysis by accounting for unobserved heterogeneity.