Part I: Describing Variable Bias and OVB

What is Variable Bias?

source: Evaluating the Goodness of an Estimator: Bias, Mean-Square Error, Relative Eciency

In the least mathematical terms, variable bias describes whether the coefficient from a regression overestimates, underestimates, or correctly predicts an explanatory variable’s relationship with the dependent variable. It is defined mathematically as

\[ Bias(\theta)=E(\hat{\theta})-\theta \]

To translate back into English, bias is the expected value of an estimator, the value calculated from a sample, minus its true population value. If \(\hat\theta >\theta\), you have a positive bias, If \(\hat\theta< \theta\), you have a negative bias, and if \(\hat\theta=\theta\), you have an unbiased estimator.

What is Omitted Variable Bias (OVB)?

Source: Econometrics With R

Definition: The situation where an estimator’s value is biased because another correlated, explanatory variable is not included in the model.

Variable bias can occur for a number of reasons, one of the primary causes being OVB. OVB occurs when there is a variable outside of the model that is correlated with the dependent variable and an explanatory, independent, variable. While a high amount of correlation between explanatory variables may create multicollinearity, failure to include a correlated variable could cause significant problems in an estimator. These may include over or underestimation, or even a flip from a positive to a negative relationship or vice versa. (Question II answer) Adding variables to the model can reduce the effects of OVB but they should be added mindfully to avoid producing multicollinearity or endogeneity. Additionally, increasing the sample size alone does not reduce variable bias. This is because the problem is not the size of the data, but the failure to include a relevant variable.

There are two conditions for OVB:

  1. X, an independent variable, is correlated with the omitted variable.

  2. The omitted variable is a determinant of the dependent variable Y

Part II: Examples of OVB

Setup

# Set working directory and path to data
  setwd("/Users/cam/Desktop/Grad_EMetrics/Discussions")

# Clear the workspace
  rm(list = ls()) # Clear environment
  gc()            # Clear unused memory
##          used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
## Ncells 518080 27.7    1145581 61.2         NA   669294 35.8
## Vcells 953217  7.3    8388608 64.0      16384  1839854 14.1
  cat("\f")       # Clear the console
  dev.off         # Clear the charts
## function (which = dev.cur()) 
## {
##     if (which == 1) 
##         stop("cannot shut down device 1 (the null device)")
##     .External(C_devoff, as.integer(which))
##     dev.cur()
## }
## <bytecode: 0x7fbf00dd2d38>
## <environment: namespace:grDevices>
#make vector containing the packages
packages <- c("AER","knitr","sjPlot","ggcorrplot","stargazer")

for (i in 1:length(packages)) {# Iterate through each package in the 'packages' vector.
  if (!packages[i] %in% rownames(installed.packages())) {#check if package is installed
    install.packages(packages[i], #install package if it isn't already
                     repos = "http://cran.rstudio.com/",
                     dependencies = TRUE)}
  library(packages[i], character.only = TRUE)} # Load the package into the R session.
## Loading required package: car
## Loading required package: carData
## Loading required package: lmtest
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: sandwich
## Loading required package: survival
## Loading required package: ggplot2
## 
## 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

Example 1: Gas Consumption

Description

Panel data on gasoline consumption in 18 OECD countries over 19 years, 1960--1978.

VARIABLE DEFINITION
country Factor indicating country.
year Year.
gas Logarithm of motor gasoline consumption per car.
income Logarithm of real per-capita income.
price Logarithm of real motor gasoline price.
cars Logarithm of the stock of cars per-capita.

Full Regression

\[ price = \beta_0+\beta_1(gas)+\beta_2(income)+\beta_3(cars)+\epsilon \]

Variable of interest: cars

The stock of cars should have a significant influence on the price of gas given that with more cars comes more demand for gas. A change in the stock may also cause a change in the gas consumption per car. As new, fuel efficient cars are introduced to the market, the overall ratio of gas consumption per car may change.

Stock of Cars Variable Dropped

\[ price=\beta_0+\beta_1(gas)+\beta_2(income)+\epsilon \]

Whether or not OVB occurs depends on the omitted variable, cars, correlation with (price) and either (gas) or (income). Thus a correlation plot is necessary.

#Call on the dataset
data("OECDGas")

# Create a data frame with the variables of interest
gas_vars <- OECDGas[, c("price", "gas", "income", "cars")]

# Calculate the correlation matrix
gas_matrix <- cor(gas_vars)

#calculate p values of each correlation
p_values <- cor_pmat(gas_vars, method = "pearson")

# Create a correlation plot
ggcorrplot(gas_matrix,
           method = "square", 
           type = "full", 
           colors = c("darkred", "white", "darkgreen"),
           lab = TRUE,
           hc.order = TRUE,
           p.mat = p_values, # Use calculated p-values
           insig = "pch", # Mask insignificant correlations with blank
           pch = 4,
           pch.cex = 10) # Specify the character for masking (you can adjust this)

The correlation plot above provides evidence that removing stock of cars creates omitted variable bias exists because it meets the 2 conditions for OVB:

  1. Cars is significantly correlated with dependent variable, price (corr = -0.39)

  2. Cars is significantly correlated with independent variable, income (corr = 0.55). It is also correlated with gas consumption per vehicle (corr = -0.35).

OVB MATRIX \(X_1\) and \(X_2\) positively correlated \(X_1\) and \(X_2\) negatively correlated
\(X_1\) and \(Y\) positively correlated Positive bias (overestimated) Negative bias (underestimated)
\(X_1\) and \(Y\) negatively correlated Negative bias (underestimated) Positive bias (overestimated)

Based on the OVB matrix, omitting cars would result in a negative bias on income (cell 2,1) and a positive bias (cell 2,2) on gas consumption per vehicle.

#run regression on all variables
gas_reg_all <- lm(price ~ gas + income + cars, data = OECDGas)

#run OVB regression
gas_reg_OVB <- lm(price ~ gas + income, data = OECDGas)

#Show regressions with stargazer
stargazer( gas_reg_OVB, gas_reg_all, title = "Regression Results", 
          align = TRUE, type = "text", header = FALSE)
## 
## Regression Results
## ======================================================================
##                                    Dependent variable:                
##                     --------------------------------------------------
##                                           price                       
##                               (1)                      (2)            
## ----------------------------------------------------------------------
## gas                         0.148**                 -0.806***         
##                             (0.065)                  (0.027)          
##                                                                       
## income                     0.467***                  0.983***         
##                             (0.056)                  (0.021)          
##                                                                       
## cars                                                -0.753***         
##                                                      (0.014)          
##                                                                       
## Constant                   1.708***                  2.165***         
##                             (0.364)                  (0.117)          
##                                                                       
## ----------------------------------------------------------------------
## Observations                  342                      342            
## R2                           0.169                    0.914           
## Adjusted R2                  0.164                    0.913           
## Residual Std. Error    0.620 (df = 339)          0.200 (df = 338)     
## F Statistic         34.458*** (df = 2; 339) 1,198.641*** (df = 3; 338)
## ======================================================================
## Note:                                      *p<0.1; **p<0.05; ***p<0.01

As we can see from the regressions above, there is evidence of positive OVB on gas consumption per vehicle (gas decreases when cars is included) and negative bias on income (income increased when cars included).

Under some logic used earlier, as more fuel efficient cars are introduced to the market, the gas consumption per vehicle will decrease. Additionally, an increased stockpile of cars could be the result of increased demand for cars driven by an increase in income. Thus, the change in these estimators intuitively makes sense (although a negative coefficient for consumption for vehicle is questionable).

Example 2: Gun Laws

Description

Blanced panel of data on 50 US states, plus the District of Columbia (for a total of 51 states), by year for 1977--1999

Variable Description
state factor indicating state
year factor indicating year
violent violent crime rate (incidents per 100,000 members of the population)
murder murder rate (incidents per 100,000)
robbery robbery rate (incidents per 100,000)
prisoners incarceration rate in the state in the previous year (sentenced prisoners per 100,000 residents; value for the previous year)
afam percent of state population that is African-American, ages 10 to 64
cauc percent of state population that is Caucasian, ages 10 to 64
male percent of state population that is male, ages 10 to 29
population state population, in millions of people
income real per capita personal income in the state (US dollars)
density population per square mile of land area, divided by 1,000
law factor. Does the state have a shall carry law in effect in that year?

Full Regression

\[ violent = \beta_0+\beta_1(law)+\beta_2(income)+\beta_3(density)+\beta_4(prisoners)+epsilon \]

variable of interest: incarceration rate (prisoners)

Violent crimes should theoretically be more frequent in areas that have more arrests. Additionally, it might be interesting to see how it trends with income and population density. Low income, high density areas are generally associated with higher incarceration rates so this could be an interesting relationship to study. The ideal variable to use would have been gun laws, but it did not yield any significant correlation bias.

Incarceration Rate Dropped

\[ violent = \beta_0+\beta_1(law)+\beta_2(income)+\beta_3(density)+epsilon \]

#call on the data
data("Guns")

#convert law to binary data
Guns$law <- ifelse(Guns$law == "yes", 1, 0)

# Calculate the correlation matrix
matrix_2<- cor(Guns[, !(colnames(Guns) %in% c("state","year"))])

#calculate p values of each correlation
p_values_2 <- cor_pmat(matrix_2, method = "pearson")

# Create a correlation plot
ggcorrplot(matrix_2,
           method = "square", 
           type = "full", 
           colors = c("darkred", "white", "darkgreen"),
           lab = TRUE,
           hc.order = TRUE,
           p.mat = p_values_2, # Use calculated p-values
           insig = "pch", # Mask insignificant correlations with blank
           pch = 4,
           pch.cex = 10) # Specify the character for masking (you can adjust this)

The correlation plot above suggests that removing the incarceration rate meets the conditions for OVB:

  1. Incarceration rate (prisoners) has a significant positive relationship with an explanatory variable, income (corr = 0.46).

  2. Incarceration rate (prisoners) has a significant positive relationship with the dependent variable, violent crime rate (corr = 0.7).

Since both coefficients are positive, the OVB would be positive, meaning that we would overestimate the violent crime rate and the beta for income without the incarceration rate. This would fall in cell 1,1 of the OVB matrix.

#run regression on all variables
reg_2_all <- lm(violent ~ law + income + density + prisoners, data = Guns)

#run OVB regression
reg_2_OVB <- lm(violent ~ law + income + density, data = Guns)

#Show regressions with stargazer
stargazer( reg_2_OVB, reg_2_all, title = "Regression Results", 
          align = TRUE, type = "text", header = FALSE)
## 
## Regression Results
## =======================================================================
##                                     Dependent variable:                
##                     ---------------------------------------------------
##                                           violent                      
##                                (1)                       (2)           
## -----------------------------------------------------------------------
## law                        -110.590***               -146.481***       
##                             (16.256)                  (13.904)         
##                                                                        
## income                      0.027***                  0.008***         
##                              (0.003)                   (0.003)         
##                                                                        
## density                    142.208***                 86.367***        
##                              (5.479)                   (5.339)         
##                                                                        
## prisoners                                             0.907***         
##                                                        (0.043)         
##                                                                        
## Constant                   102.676***                188.183***        
##                             (39.686)                  (33.932)         
##                                                                        
## -----------------------------------------------------------------------
## Observations                  1,173                     1,173          
## R2                            0.498                     0.639          
## Adjusted R2                   0.497                     0.637          
## Residual Std. Error    237.059 (df = 1169)       201.263 (df = 1168)   
## F Statistic         387.127*** (df = 3; 1169) 516.261*** (df = 4; 1168)
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01

As we can see, positive Omitted Variable Bias (OVB) was accurately predicted for income, as evidenced by the decrease in the beta coefficient for income after the inclusion of the incarceration rate in the model. Since the incarceration rate exhibited positive correlations with both income and violent crime, part of the explanation for the upward effect that the incarceration rate would have on violent crime was integrated into the model through the variable ‘income.’ To put it simply, the beta coefficient for income had to be artificially higher than it would realistically be in order to better align the model with the observed data and provide an accurate representation of the influence of the incarceration rate on violent crime.

Intuition of OVB

A good way to think of OVB is through the lens of rules for multiplication. It’s as if you have two factors that are pushing in the same direction (whether it be positive or negative). When they work together, the impact on the outcome is amplified, and you get an overestimation (positive bias) of the effect of X on Y. If the factors are working against each each other (1 is positive and the other is negative), then the outcome is reduced and you get an underestimation (negative bias).