Wantchekon (2003) discusses a unique field experiment (RCT) organized in the context of the first round of the March 2001 presidential elections in Benin, in which randomly selected villages were exposed to ‘clientelist’ and ‘public policy’ platforms, to see which induced more voting.
Clientelist platforms emphasized how candidates would send benefits and resources to specific types/groups of voters. Public policy platforms focused on broadly-shared society-wide benefits.
16 villages were divided into 8 blocks, such that each block had 2 similar villages. In each block, the treatments of “public policy,” OR “clientelist” were assigned at random. The outcome is VOTE SHARE and the single covariate is the NUMBER OF REGISTERED VOTERS.
To estimate a treatment effect using Fisher’s Exact Test, the smallest p-value possible is theoretically the reciprocal of the total number of possible treatment assignments to the units, assuming a 1-tailed test. This is because, under the null hypothesis of no treatment effect, the smallest p-value would occur if there is only one way (out of all possible ways) to assign treatments that lead to an outcome as extreme or more extreme than the observed one. In the case of the Benin paper with 16 villages divided into 8 blocks, where each block can be randomly assigned one of two treatments, the total number of possible assignments is 12870 (16choose8). Therefore, the smallest p-value would be achieved if only one of these 12870 assignments resulted in an outcome as extreme as what was observed. In such a simplified scenario, the smallest p-value possible would thus be 1/12870, reflecting the low probability of observing the extreme outcome by chance alone under the conditions of the null hypothesis.
The observed treatment effect that I obtained is 0.5175. Therefore, on average, the difference between villages treated with clientelism and those treated with public policy is 15.75 percentage points. The p-value is 0.95395, which is high. Given this, there is not strong evidence against the null hypothesis — that there is no difference in vote shares between treatments — and the result is not statistically significant. I might be missing some important context by ignoring the blocking.
library(readr)
data_url <- "https://docs.google.com/spreadsheets/d/e/2PACX-1vT60MPn4BZk5xHVi9FSW_bwrOF_dlhl5rmcH5yClmIEmUFO9O_mJaFMoIkzd_qAFugyCs4unsSyL6o3/pub?gid=1672245872&single=true&output=csv"
data <- read_csv(data_url)
## Rows: 16 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): treat
## dbl (4): id, block, reg_voters, vote_pop
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
fisherfunction <- function(nulleffect = 0, Ys = data$vote_pop, sims = 20000) {
storage.vector <- numeric(sims)
for(i in 1:sims) {
# Simulate the treatment effect by adjusting half the villages by the null effect
Y0s <- c(Ys[1], Ys[2]-nulleffect, Ys[3], Ys[4]-nulleffect,
Ys[5], Ys[6]-nulleffect, Ys[7], Ys[8]-nulleffect,
Ys[9], Ys[10]-nulleffect, Ys[11], Ys[12]-nulleffect,
Ys[13], Ys[14]-nulleffect, Ys[15], Ys[16]-nulleffect)
# Assume that the other half gets the opposite treatment effect
Y1s <- c(Ys[1]+nulleffect, Ys[2], Ys[3]+nulleffect, Ys[4],
Ys[5]+nulleffect, Ys[6], Ys[7]+nulleffect, Ys[8],
Ys[9]+nulleffect, Ys[10], Ys[11]+nulleffect, Ys[12],
Ys[13]+nulleffect, Ys[14], Ys[15]+nulleffect, Ys[16])
# Simulate the assignments
which_treated <- sample(1:16, 8)
which_controls <- setdiff(1:16, which_treated)
# Calculate the mean difference for this simulation
storage.vector[i] <- mean(Y1s[which_treated]) - mean(Y0s[which_controls])
}
# Calculate the observed treatment effect
observed_effect <- mean(Ys[seq(1, 16, by = 2)]) - mean(Ys[seq(2, 16, by = 2)])
# Calculate the p-value: proportion of simulated effects as extreme or more extreme than observed
p_value <- mean(storage.vector <= observed_effect)
return(list(p_value = p_value, observed_effect = observed_effect, simulations = storage.vector))
}
results <- fisherfunction(Ys = data$vote_pop)
results$p_value
## [1] 0.9535
results$observed_effect
## [1] 0.1575
This part asks you to perform various matching methods on the “greenbuildings.csv” data set: https://drive.google.com/file/d/1dWJTCy24Yp9xeXKz8lJK0-O_OvIAcAWM/view?usp=sharing
Background: In commercial real estate, the concept of sustainability is deeply woven into routine financial planning. Every fresh venture demands a balancing act between the immediate costs and the long-term gains of the property. In this vein, opting for sustainable buildings could yield numerous advantages. However, whether tenants are prepared to pay extra for spaces in environmentally conscious buildings remains uncertain, a question that can only be answered by a detailed analysis of the commercial real-estate sector.
The dataset titled greenbuildings.csv encompasses information on 7,894 commercial rental properties from various locations in the United States. Out of these, 685 properties have been recognized as green buildings, with certifications such as LEED or EnergyStar.53 Essentially, a commercial property is deemed green if it meets specific standards regarding energy efficiency, carbon footprint, site selection, and the use of sustainable materials.
To compile this dataset, a team of real estate analysts began by selecting 679 properties with green certifications from the official LEED or EnergyStar directories. They then aligned this information with records from the CoStar Group (), a reputable provider of data in the commercial real estate field. To establish a baseline for comparison, each of these 685 certified properties was paired with a collection of geographically close commercial buildings found in the CoStar database. Within this framework, each cluster consists of one certified green building and all non-certified buildings within a quarter-mile. On average, the 679 clusters include about 12 buildings each, accumulating a total of 7,820 data entries.
The stable weights achieved by Generation 7 indicate that each of the four variables—size, stories, age, and class—was balanced throughout the genetic matching process. In comparison to non-green buildings, green-rated buildings enjoy an average increase in leasing rates by 3.5592, confirming a significant advantage for green-rated buildings. Accordingly, this figure reflects the tangible financial benefits of green ratings in the commercial real estate market when adjusted for key variables. A p-value of 0.00017232 supports the finding, demonstrating that green-rated buildings have a positive influence on leasing rates.
install.packages("rgenoud", repos='http://cran.rstudio.com/')
##
## The downloaded binary packages are in
## /var/folders/fj/bzw0pc4x1jj02gb727vblf6h0000gn/T//RtmpwTb6IK/downloaded_packages
install.packages("Matching", repos='http://cran.rstudio.com/')
##
## The downloaded binary packages are in
## /var/folders/fj/bzw0pc4x1jj02gb727vblf6h0000gn/T//RtmpwTb6IK/downloaded_packages
library(rgenoud)
## ## rgenoud (Version 5.9-0.3, Build Date: 2022-04-19)
## ## See http://sekhon.berkeley.edu/rgenoud for additional documentation.
## ## Please cite software as:
## ## Walter Mebane, Jr. and Jasjeet S. Sekhon. 2011.
## ## ``Genetic Optimization Using Derivatives: The rgenoud package for R.''
## ## Journal of Statistical Software, 42(11): 1-26.
## ##
library(Matching)
## Loading required package: MASS
## ##
## ## Matching (Version 4.10-14, Build Date: 2023-09-13)
## ## See https://www.jsekhon.com for additional documentation.
## ## Please cite software as:
## ## Jasjeet S. Sekhon. 2011. ``Multivariate and Propensity Score Matching
## ## Software with Automated Balance Optimization: The Matching package for R.''
## ## Journal of Statistical Software, 42(7): 1-52.
## ##
# Read the data
google_sheet_csv_url <- "https://docs.google.com/spreadsheets/d/e/2PACX-1vQnNuE89lhtg3pxJDfp95VSO_FU5w-H23fL-Ps4ljoXQ6JxJn7kReIV9jIfOUWwe0-jUqBaYipGBGdI/pub?gid=1918397729&single=true&output=csv"
df1 <- read.csv(google_sheet_csv_url)
# Convert the green_rating to logical (assuming 1 for green-rated buildings)
df1$green_rating <- df1$green_rating == 1
# Convert class to numeric
df1$class <- as.numeric(as.factor(df1$class))
# Define the treatment (green_rating) and outcome (leasing_rate) variables
treatment <- "green_rating"
outcome <- "leasing_rate"
# Define the confounders
confounders <- c("size", "stories", "age", "class")
# Perform genetic matching
gen_match <- GenMatch(Tr = df1[[treatment]], X = df1[confounders], M=1, pop.size=200, max.generations=100)
##
##
## Sat Dec 2 11:29:12 2023
## Domains:
## 0.000000e+00 <= X1 <= 1.000000e+03
## 0.000000e+00 <= X2 <= 1.000000e+03
## 0.000000e+00 <= X3 <= 1.000000e+03
## 0.000000e+00 <= X4 <= 1.000000e+03
##
## Data Type: Floating Point
## Operators (code number, name, population)
## (1) Cloning........................... 22
## (2) Uniform Mutation.................. 25
## (3) Boundary Mutation................. 25
## (4) Non-Uniform Mutation.............. 25
## (5) Polytope Crossover................ 25
## (6) Simple Crossover.................. 26
## (7) Whole Non-Uniform Mutation........ 25
## (8) Heuristic Crossover............... 26
## (9) Local-Minimum Crossover........... 0
##
## SOFT Maximum Number of Generations: 100
## Maximum Nonchanging Generations: 4
## Population size : 200
## Convergence Tolerance: 1.000000e-03
##
## Not Using the BFGS Derivative Based Optimizer on the Best Individual Each Generation.
## Not Checking Gradients before Stopping.
## Using Out of Bounds Individuals.
##
## Maximization Problem.
## GENERATION: 0 (initializing the population)
## Lexical Fit..... 8.478050e-02 9.293904e-02 2.776471e-01 2.978889e-01 3.173109e-01 6.903677e-01 7.043924e-01 1.000000e+00
## #unique......... 200, #Total UniqueCount: 200
## var 1:
## best............ 5.381017e+02
## mean............ 4.874766e+02
## variance........ 8.767205e+04
## var 2:
## best............ 7.273772e+02
## mean............ 5.044533e+02
## variance........ 8.442841e+04
## var 3:
## best............ 6.470360e+02
## mean............ 4.629214e+02
## variance........ 8.793695e+04
## var 4:
## best............ 4.865476e+02
## mean............ 4.727607e+02
## variance........ 8.692162e+04
##
## GENERATION: 1
## Lexical Fit..... 1.349518e-01 1.759458e-01 2.498460e-01 4.616288e-01 5.180869e-01 7.587031e-01 8.415359e-01 1.000000e+00
## #unique......... 143, #Total UniqueCount: 343
## var 1:
## best............ 4.916491e+02
## mean............ 5.620681e+02
## variance........ 2.799630e+04
## var 2:
## best............ 3.519933e+02
## mean............ 5.290536e+02
## variance........ 5.429576e+04
## var 3:
## best............ 9.190136e+02
## mean............ 6.806027e+02
## variance........ 2.688799e+04
## var 4:
## best............ 7.581810e+00
## mean............ 4.047475e+02
## variance........ 6.090748e+04
##
## GENERATION: 2
## Lexical Fit..... 2.000165e-01 2.471362e-01 2.799590e-01 4.692299e-01 4.971300e-01 5.271808e-01 6.452862e-01 9.999996e-01
## #unique......... 146, #Total UniqueCount: 489
## var 1:
## best............ 4.916491e+02
## mean............ 5.144005e+02
## variance........ 1.556733e+04
## var 2:
## best............ 3.519933e+02
## mean............ 3.936588e+02
## variance........ 1.825305e+04
## var 3:
## best............ 9.190136e+02
## mean............ 7.994367e+02
## variance........ 1.972098e+04
## var 4:
## best............ 3.735887e+00
## mean............ 1.356318e+02
## variance........ 4.915147e+04
##
## GENERATION: 3
## Lexical Fit..... 2.410759e-01 2.553162e-01 2.909327e-01 4.234013e-01 4.658604e-01 4.937389e-01 6.420311e-01 9.999995e-01
## #unique......... 142, #Total UniqueCount: 631
## var 1:
## best............ 4.821752e+02
## mean............ 4.910645e+02
## variance........ 8.701021e+03
## var 2:
## best............ 3.519933e+02
## mean............ 3.612895e+02
## variance........ 9.370347e+03
## var 3:
## best............ 9.190136e+02
## mean............ 8.950865e+02
## variance........ 1.159250e+04
## var 4:
## best............ 3.735887e+00
## mean............ 4.498083e+01
## variance........ 2.098055e+04
##
## GENERATION: 4
## Lexical Fit..... 3.125982e-01 3.170219e-01 3.427999e-01 3.464625e-01 4.877661e-01 6.057431e-01 6.974244e-01 9.999994e-01
## #unique......... 149, #Total UniqueCount: 780
## var 1:
## best............ 4.473512e+02
## mean............ 4.898537e+02
## variance........ 8.525813e+03
## var 2:
## best............ 3.519933e+02
## mean............ 3.522785e+02
## variance........ 4.075240e+03
## var 3:
## best............ 9.190136e+02
## mean............ 8.902872e+02
## variance........ 1.157354e+04
## var 4:
## best............ 3.735887e+00
## mean............ 4.467392e+01
## variance........ 1.480906e+04
##
## GENERATION: 5
## Lexical Fit..... 3.167884e-01 3.435132e-01 4.658604e-01 4.718471e-01 4.937389e-01 5.165020e-01 7.328418e-01 1.000000e+00
## #unique......... 140, #Total UniqueCount: 920
## var 1:
## best............ 3.720896e+02
## mean............ 4.496691e+02
## variance........ 7.479902e+03
## var 2:
## best............ 3.519933e+02
## mean............ 3.633893e+02
## variance........ 4.494007e+03
## var 3:
## best............ 8.859235e+02
## mean............ 8.893558e+02
## variance........ 1.461212e+04
## var 4:
## best............ 3.735887e+00
## mean............ 3.804796e+01
## variance........ 1.514448e+04
##
## GENERATION: 6
## Lexical Fit..... 3.167884e-01 3.435132e-01 4.658604e-01 4.718471e-01 4.937389e-01 5.165020e-01 7.328418e-01 1.000000e+00
## #unique......... 136, #Total UniqueCount: 1056
## var 1:
## best............ 3.720896e+02
## mean............ 4.093308e+02
## variance........ 9.048038e+03
## var 2:
## best............ 3.519933e+02
## mean............ 3.664367e+02
## variance........ 8.766206e+03
## var 3:
## best............ 8.859235e+02
## mean............ 8.693930e+02
## variance........ 8.947538e+03
## var 4:
## best............ 3.735887e+00
## mean............ 3.647730e+01
## variance........ 1.273771e+04
##
## GENERATION: 7
## Lexical Fit..... 3.167884e-01 3.435132e-01 4.658604e-01 4.718471e-01 4.937389e-01 5.165020e-01 7.328418e-01 1.000000e+00
## #unique......... 81, #Total UniqueCount: 1137
## var 1:
## best............ 3.720896e+02
## mean............ 4.004557e+02
## variance........ 6.948470e+03
## var 2:
## best............ 3.519933e+02
## mean............ 3.651049e+02
## variance........ 6.559131e+03
## var 3:
## best............ 8.859235e+02
## mean............ 8.632209e+02
## variance........ 1.009199e+04
## var 4:
## best............ 3.735887e+00
## mean............ 3.195008e+01
## variance........ 8.638844e+03
##
## GENERATION: 8
## Lexical Fit..... 3.167884e-01 3.435132e-01 4.658604e-01 4.718471e-01 4.937389e-01 5.165020e-01 7.328418e-01 1.000000e+00
## #unique......... 77, #Total UniqueCount: 1214
## var 1:
## best............ 3.720896e+02
## mean............ 3.715831e+02
## variance........ 4.734235e+03
## var 2:
## best............ 3.519933e+02
## mean............ 3.605647e+02
## variance........ 5.882764e+03
## var 3:
## best............ 8.859235e+02
## mean............ 8.546306e+02
## variance........ 1.370490e+04
## var 4:
## best............ 3.735887e+00
## mean............ 4.375388e+01
## variance........ 1.771404e+04
##
## GENERATION: 9
## Lexical Fit..... 3.167884e-01 3.435132e-01 4.658604e-01 4.718471e-01 4.937389e-01 5.165020e-01 7.328418e-01 1.000000e+00
## #unique......... 80, #Total UniqueCount: 1294
## var 1:
## best............ 3.720896e+02
## mean............ 3.732002e+02
## variance........ 2.498912e+03
## var 2:
## best............ 3.519933e+02
## mean............ 3.555115e+02
## variance........ 4.844706e+03
## var 3:
## best............ 8.859235e+02
## mean............ 8.732713e+02
## variance........ 5.151232e+03
## var 4:
## best............ 3.735887e+00
## mean............ 3.367642e+01
## variance........ 1.570137e+04
##
## GENERATION: 10
## Lexical Fit..... 3.167884e-01 3.435132e-01 4.658604e-01 4.718471e-01 4.937389e-01 5.165020e-01 7.328418e-01 1.000000e+00
## #unique......... 85, #Total UniqueCount: 1379
## var 1:
## best............ 3.720896e+02
## mean............ 3.709036e+02
## variance........ 8.110745e+03
## var 2:
## best............ 3.519933e+02
## mean............ 3.574539e+02
## variance........ 8.483859e+03
## var 3:
## best............ 8.859235e+02
## mean............ 8.711040e+02
## variance........ 4.021727e+03
## var 4:
## best............ 3.735887e+00
## mean............ 3.725628e+01
## variance........ 1.595546e+04
##
## 'wait.generations' limit reached.
## No significant improvement in 4 generations.
##
## Solution Lexical Fitness Value:
## 3.167884e-01 3.435132e-01 4.658604e-01 4.718471e-01 4.937389e-01 5.165020e-01 7.328418e-01 1.000000e+00
##
## Parameters at the Solution:
##
## X[ 1] : 3.720896e+02
## X[ 2] : 3.519933e+02
## X[ 3] : 8.859235e+02
## X[ 4] : 3.735887e+00
##
## Solution Found Generation 5
## Number of Generations Run 10
##
## Sat Dec 2 11:32:53 2023
## Total run time : 0 hours 3 minutes and 41 seconds
matched <- Match(Y = df1[[outcome]], Tr = df1[[treatment]], X = df1[confounders], Weight.matrix = gen_match)
# Analyze the matched data
matched_results <- summary(matched)
##
## Estimate... 3.5041
## AI SE...... 0.95073
## T-stat..... 3.6857
## p.val...... 0.00022807
##
## Original number of observations.............. 7820
## Original number of treated obs............... 679
## Matched number of observations............... 679
## Matched number of observations (unweighted). 1530
# Print the results
print(matched_results)
In both exact and caliper matching methods applied to ‘Class’ and ‘Size’, respectively, the analysis resulted in zero dropped treated units, allowing the use of the full dataset. In the code, I left exact matching on ‘Class’. Specifically, with exact matching on ‘Class’, every green-rated building in the dataset found a comparable non-green-rated building within the same class category. This ensures that the matching is effective and that the distribution of buildings across classes is adequately represented in both the treated and control groups, which is crucial for a robust comparative analysis.
The treatment effect estimate of 3.1269 reveals that green-rated buildings, on average, benefit from higher leasing rates compared to non-green buildings by this amount. This estimate is slightly lower than what was observed in the genetic matching without exact matching on ‘Class’, possibly due to the more stringent control of confounding effects related to building classes in the matched groups.
With a statistically significant p-value of 0.00056884, the analysis confirms the reliability of the treatment effect estimate. The finding that green-rated buildings command higher leasing rates holds true and is not likely to be an artifact of sample variation or unaccounted factors within the class variable.
library(rgenoud)
library(Matching)
# Read the data from the Google Sheet's CSV URL
google_sheet_csv_url <- "https://docs.google.com/spreadsheets/d/e/2PACX-1vQnNuE89lhtg3pxJDfp95VSO_FU5w-H23fL-Ps4ljoXQ6JxJn7kReIV9jIfOUWwe0-jUqBaYipGBGdI/pub?gid=1918397729&single=true&output=csv"
df1 <- read.csv(google_sheet_csv_url)
# Convert the green_rating to logical (assuming 1 for green-rated buildings)
df1$green_rating <- df1$green_rating == 1
# Convert class to numeric
df1$class <- as.numeric(as.factor(df1$class))
# Define the treatment (green_rating) and outcome (leasing_rate) variables
treatment <- "green_rating"
outcome <- "leasing_rate"
# Define the confounders
confounders <- c("size", "stories", "age", "class")
# Perform genetic matching
gen_match <- GenMatch(Tr = df1[[treatment]], X = df1[confounders], M=1, pop.size=200, max.generations=100)
##
##
## Sat Dec 2 11:32:57 2023
## Domains:
## 0.000000e+00 <= X1 <= 1.000000e+03
## 0.000000e+00 <= X2 <= 1.000000e+03
## 0.000000e+00 <= X3 <= 1.000000e+03
## 0.000000e+00 <= X4 <= 1.000000e+03
##
## Data Type: Floating Point
## Operators (code number, name, population)
## (1) Cloning........................... 22
## (2) Uniform Mutation.................. 25
## (3) Boundary Mutation................. 25
## (4) Non-Uniform Mutation.............. 25
## (5) Polytope Crossover................ 25
## (6) Simple Crossover.................. 26
## (7) Whole Non-Uniform Mutation........ 25
## (8) Heuristic Crossover............... 26
## (9) Local-Minimum Crossover........... 0
##
## SOFT Maximum Number of Generations: 100
## Maximum Nonchanging Generations: 4
## Population size : 200
## Convergence Tolerance: 1.000000e-03
##
## Not Using the BFGS Derivative Based Optimizer on the Best Individual Each Generation.
## Not Checking Gradients before Stopping.
## Using Out of Bounds Individuals.
##
## Maximization Problem.
## GENERATION: 0 (initializing the population)
## Lexical Fit..... 1.378056e-01 1.978323e-01 2.632246e-01 3.173109e-01 3.460629e-01 5.583850e-01 7.089596e-01 1.000000e+00
## #unique......... 200, #Total UniqueCount: 200
## var 1:
## best............ 2.056063e+02
## mean............ 5.213820e+02
## variance........ 8.947308e+04
## var 2:
## best............ 1.909999e+02
## mean............ 4.998388e+02
## variance........ 8.525553e+04
## var 3:
## best............ 4.726692e+02
## mean............ 4.896952e+02
## variance........ 8.512822e+04
## var 4:
## best............ 9.374040e+01
## mean............ 5.124945e+02
## variance........ 7.271683e+04
##
## GENERATION: 1
## Lexical Fit..... 1.920475e-01 2.062572e-01 2.587656e-01 3.173109e-01 3.387277e-01 5.503494e-01 6.713175e-01 1.000000e+00
## #unique......... 155, #Total UniqueCount: 355
## var 1:
## best............ 2.019271e+02
## mean............ 3.732720e+02
## variance........ 5.563907e+04
## var 2:
## best............ 1.869796e+02
## mean............ 2.704461e+02
## variance........ 3.667849e+04
## var 3:
## best............ 4.115313e+02
## mean............ 6.404208e+02
## variance........ 6.313633e+04
## var 4:
## best............ 1.521629e+02
## mean............ 1.862058e+02
## variance........ 4.128069e+04
##
## GENERATION: 2
## Lexical Fit..... 2.071975e-01 2.118736e-01 2.492895e-01 3.173109e-01 3.387277e-01 5.503494e-01 6.713175e-01 1.000000e+00
## #unique......... 157, #Total UniqueCount: 512
## var 1:
## best............ 2.056063e+02
## mean............ 2.267357e+02
## variance........ 6.895032e+03
## var 2:
## best............ 1.873816e+02
## mean............ 2.051482e+02
## variance........ 5.886318e+03
## var 3:
## best............ 4.176451e+02
## mean............ 4.820298e+02
## variance........ 2.754173e+04
## var 4:
## best............ 1.447836e+02
## mean............ 1.450172e+02
## variance........ 1.475392e+04
##
## GENERATION: 3
## Lexical Fit..... 2.257325e-01 2.289469e-01 2.313313e-01 3.173109e-01 3.387277e-01 5.503494e-01 6.713175e-01 1.000000e+00
## #unique......... 85, #Total UniqueCount: 597
## var 1:
## best............ 2.064818e+02
## mean............ 2.229555e+02
## variance........ 7.889080e+03
## var 2:
## best............ 1.874773e+02
## mean............ 2.081758e+02
## variance........ 9.235162e+03
## var 3:
## best............ 4.190999e+02
## mean............ 4.283161e+02
## variance........ 7.664141e+03
## var 4:
## best............ 1.430276e+02
## mean............ 1.620244e+02
## variance........ 1.352800e+04
##
## GENERATION: 4
## Lexical Fit..... 2.421303e-01 2.464013e-01 2.637522e-01 3.173109e-01 3.387277e-01 5.503494e-01 7.317321e-01 1.000000e+00
## #unique......... 147, #Total UniqueCount: 744
## var 1:
## best............ 2.064818e+02
## mean............ 2.244223e+02
## variance........ 9.211145e+03
## var 2:
## best............ 1.874773e+02
## mean............ 2.124726e+02
## variance........ 1.415825e+04
## var 3:
## best............ 4.190999e+02
## mean............ 4.267581e+02
## variance........ 8.138569e+03
## var 4:
## best............ 1.327972e+01
## mean............ 1.757052e+02
## variance........ 1.323392e+04
##
## GENERATION: 5
## Lexical Fit..... 3.273879e-01 3.555339e-01 3.673427e-01 4.018779e-01 4.548130e-01 5.271808e-01 7.230884e-01 9.999994e-01
## #unique......... 147, #Total UniqueCount: 891
## var 1:
## best............ 2.064491e+02
## mean............ 2.252132e+02
## variance........ 9.331716e+03
## var 2:
## best............ 1.874737e+02
## mean............ 2.045178e+02
## variance........ 6.626512e+03
## var 3:
## best............ 4.190456e+02
## mean............ 4.259034e+02
## variance........ 7.326354e+03
## var 4:
## best............ 1.737962e+00
## mean............ 1.111205e+02
## variance........ 1.292947e+04
##
## GENERATION: 6
## Lexical Fit..... 3.807868e-01 3.841311e-01 4.014621e-01 4.049883e-01 4.082595e-01 4.543852e-01 7.227071e-01 9.685648e-01
## #unique......... 146, #Total UniqueCount: 1037
## var 1:
## best............ 2.064760e+02
## mean............ 2.262086e+02
## variance........ 9.935051e+03
## var 2:
## best............ 1.874767e+02
## mean............ 2.186988e+02
## variance........ 1.269997e+04
## var 3:
## best............ 4.190903e+02
## mean............ 4.162842e+02
## variance........ 7.564855e+03
## var 4:
## best............ 2.401367e+00
## mean............ 6.139675e+01
## variance........ 1.866563e+04
##
## GENERATION: 7
## Lexical Fit..... 3.807868e-01 3.841311e-01 4.014621e-01 4.049883e-01 4.082595e-01 4.543852e-01 7.227071e-01 9.685648e-01
## #unique......... 156, #Total UniqueCount: 1193
## var 1:
## best............ 2.064760e+02
## mean............ 2.308348e+02
## variance........ 8.076468e+03
## var 2:
## best............ 1.874767e+02
## mean............ 2.160953e+02
## variance........ 1.144204e+04
## var 3:
## best............ 4.190903e+02
## mean............ 4.256852e+02
## variance........ 1.031754e+04
## var 4:
## best............ 2.401367e+00
## mean............ 4.699868e+01
## variance........ 2.102726e+04
##
## GENERATION: 8
## Lexical Fit..... 3.807868e-01 3.841311e-01 4.014621e-01 4.049883e-01 4.082595e-01 4.543852e-01 7.227071e-01 9.685648e-01
## #unique......... 144, #Total UniqueCount: 1337
## var 1:
## best............ 2.064760e+02
## mean............ 2.297223e+02
## variance........ 1.197034e+04
## var 2:
## best............ 1.874767e+02
## mean............ 2.069459e+02
## variance........ 7.893335e+03
## var 3:
## best............ 4.190903e+02
## mean............ 4.247095e+02
## variance........ 5.594118e+03
## var 4:
## best............ 2.401367e+00
## mean............ 3.127843e+01
## variance........ 1.007902e+04
##
## GENERATION: 9
## Lexical Fit..... 3.807868e-01 3.841311e-01 4.014621e-01 4.049883e-01 4.082595e-01 4.543852e-01 7.227071e-01 9.685648e-01
## #unique......... 128, #Total UniqueCount: 1465
## var 1:
## best............ 2.064760e+02
## mean............ 2.242940e+02
## variance........ 5.822138e+03
## var 2:
## best............ 1.874767e+02
## mean............ 2.084429e+02
## variance........ 8.266473e+03
## var 3:
## best............ 4.190903e+02
## mean............ 4.209961e+02
## variance........ 3.810882e+03
## var 4:
## best............ 2.401367e+00
## mean............ 3.168410e+01
## variance........ 1.111793e+04
##
## GENERATION: 10
## Lexical Fit..... 3.807868e-01 3.841311e-01 4.014621e-01 4.049883e-01 4.082595e-01 4.543852e-01 7.227071e-01 9.685648e-01
## #unique......... 127, #Total UniqueCount: 1592
## var 1:
## best............ 2.064760e+02
## mean............ 2.210549e+02
## variance........ 1.003376e+04
## var 2:
## best............ 1.874767e+02
## mean............ 2.125053e+02
## variance........ 1.033334e+04
## var 3:
## best............ 4.190903e+02
## mean............ 4.266401e+02
## variance........ 5.110936e+03
## var 4:
## best............ 2.401367e+00
## mean............ 3.079091e+01
## variance........ 1.271547e+04
##
## GENERATION: 11
## Lexical Fit..... 3.807868e-01 3.841311e-01 4.014621e-01 4.049883e-01 4.082595e-01 4.543852e-01 7.227071e-01 9.685648e-01
## #unique......... 134, #Total UniqueCount: 1726
## var 1:
## best............ 2.064760e+02
## mean............ 2.203537e+02
## variance........ 7.004824e+03
## var 2:
## best............ 1.874767e+02
## mean............ 2.172429e+02
## variance........ 1.304200e+04
## var 3:
## best............ 4.190903e+02
## mean............ 4.213150e+02
## variance........ 3.962216e+03
## var 4:
## best............ 2.401367e+00
## mean............ 3.432003e+01
## variance........ 1.104665e+04
##
## 'wait.generations' limit reached.
## No significant improvement in 4 generations.
##
## Solution Lexical Fitness Value:
## 3.807868e-01 3.841311e-01 4.014621e-01 4.049883e-01 4.082595e-01 4.543852e-01 7.227071e-01 9.685648e-01
##
## Parameters at the Solution:
##
## X[ 1] : 2.064760e+02
## X[ 2] : 1.874767e+02
## X[ 3] : 4.190903e+02
## X[ 4] : 2.401367e+00
##
## Solution Found Generation 6
## Number of Generations Run 11
##
## Sat Dec 2 11:37:12 2023
## Total run time : 0 hours 4 minutes and 15 seconds
# Perform matching with exact matching on 'class'
matched <- Match(Y = df1[[outcome]], Tr = df1[[treatment]], X = df1[confounders],
Weight.matrix = gen_match, exact = c(0, 0, 0, 1))
# Analyze the matched data
matched_results <- summary(matched)
##
## Estimate... 3.0912
## AI SE...... 0.89968
## T-stat..... 3.4359
## p.val...... 0.00059052
##
## Original number of observations.............. 7820
## Original number of treated obs............... 679
## Matched number of observations............... 679
## Matched number of observations (unweighted). 1525
##
## Number of obs dropped by 'exact' or 'caliper' 0
# Print the results
print(matched_results)
# Calculate and print the number of treated units that were dropped due to exact matching constraints
dropped_units <- sum(!matched$index.treated)
print(paste("Number of treated units dropped due to exact matching on class:", dropped_units))
## [1] "Number of treated units dropped due to exact matching on class: 0"
I chose to use (a) the genetic matching. I chose to divide it into the 25th, 50th, and 75th percentiles to provide a comprehensive view of the effect of green ratings on leasing rates. The 25th percentile helps us understand the impact of green ratings on the lower segment of the leasing rate distribution, which aids in analyzing how less expensive properties are affected by green ratings. The 50th percentile (the median) can provide a better picture of the typical impact across all properties. The 75th percentile shows the effect on the higher end of the leasing rate distribution, allowing us to understand the impact on more expensive properties.
Looking at the results, we can see that at the 25th percentile, there is a positive effect, suggesting that green-rated buildings in the lower percentile of the leasing rate distribution are priced on average 0.5750 units higher than their non-green counterparts. However, at the 50th percentile, there is a negative effect. At the midpoint of the distribution, green-rated buildings tend to have leasing rates that are 0.5150 units lower than non-green buildings. This suggests that for the ‘typical’ property, green ratings might be associated with factors that reduce leasing rates, or it might reflect market dynamics like location and demand. In the 75th percentile, there is also a negative effect of -0.4975. This suggests that for higher-priced properties, green ratings are associated with slightly lower leasing rates compared to non-green buildings. There may be several reasons for this, such as the likelihood that higher-end properties already incorporate sustainability features, or that the premium for green ratings is less pronounced in this segment. In the initial genetic matching analysis, we found a treatment effect of 3.5592, indicating that, generally, green-rated buildings have higher leasing rates than non-green ones, adjusted for factors like size and age. However, a deeper analysis into different percentiles revealed a more complex picture. This breakdown showed that the financial benefit of green ratings varies across the leasing rate spectrum, with some segments not following the overall trend. This highlights the nuanced impact of green ratings in the real estate market.
install.packages("quantreg", repos='http://cran.rstudio.com/')
##
## The downloaded binary packages are in
## /var/folders/fj/bzw0pc4x1jj02gb727vblf6h0000gn/T//RtmpwTb6IK/downloaded_packages
install.packages("Matrix",repos='http://cran.rstudio.com/')
##
## The downloaded binary packages are in
## /var/folders/fj/bzw0pc4x1jj02gb727vblf6h0000gn/T//RtmpwTb6IK/downloaded_packages
library(rgenoud)
library(Matching)
# Read the data
google_sheet_csv_url <- "https://docs.google.com/spreadsheets/d/e/2PACX-1vQnNuE89lhtg3pxJDfp95VSO_FU5w-H23fL-Ps4ljoXQ6JxJn7kReIV9jIfOUWwe0-jUqBaYipGBGdI/pub?gid=1918397729&single=true&output=csv"
df1 <- read.csv(google_sheet_csv_url)
# Convert the green_rating to logical and class to numeric
df1$green_rating <- df1$green_rating == 1
df1$class <- as.numeric(as.factor(df1$class))
# Define treatment, outcome, and confounders
treatment <- "green_rating"
outcome <- "leasing_rate"
confounders <- c("size", "stories", "age", "class")
# Perform genetic matching
gen_match <- GenMatch(Tr = df1[[treatment]], X = df1[confounders], M=1, pop.size=200, max.generations=100)
##
##
## Sat Dec 2 11:37:18 2023
## Domains:
## 0.000000e+00 <= X1 <= 1.000000e+03
## 0.000000e+00 <= X2 <= 1.000000e+03
## 0.000000e+00 <= X3 <= 1.000000e+03
## 0.000000e+00 <= X4 <= 1.000000e+03
##
## Data Type: Floating Point
## Operators (code number, name, population)
## (1) Cloning........................... 22
## (2) Uniform Mutation.................. 25
## (3) Boundary Mutation................. 25
## (4) Non-Uniform Mutation.............. 25
## (5) Polytope Crossover................ 25
## (6) Simple Crossover.................. 26
## (7) Whole Non-Uniform Mutation........ 25
## (8) Heuristic Crossover............... 26
## (9) Local-Minimum Crossover........... 0
##
## SOFT Maximum Number of Generations: 100
## Maximum Nonchanging Generations: 4
## Population size : 200
## Convergence Tolerance: 1.000000e-03
##
## Not Using the BFGS Derivative Based Optimizer on the Best Individual Each Generation.
## Not Checking Gradients before Stopping.
## Using Out of Bounds Individuals.
##
## Maximization Problem.
## GENERATION: 0 (initializing the population)
## Lexical Fit..... 7.441786e-02 2.308097e-01 2.460009e-01 2.960621e-01 5.512005e-01 6.111909e-01 1.000000e+00 1.000000e+00
## #unique......... 200, #Total UniqueCount: 200
## var 1:
## best............ 3.117713e+02
## mean............ 5.075707e+02
## variance........ 8.715477e+04
## var 2:
## best............ 3.204811e+02
## mean............ 4.998656e+02
## variance........ 8.489317e+04
## var 3:
## best............ 8.953540e+02
## mean............ 5.183294e+02
## variance........ 8.672602e+04
## var 4:
## best............ 7.642257e+02
## mean............ 5.180960e+02
## variance........ 9.126109e+04
##
## GENERATION: 1
## Lexical Fit..... 1.250764e-01 2.245043e-01 2.977929e-01 3.173109e-01 3.180225e-01 5.520503e-01 6.120236e-01 1.000000e+00
## #unique......... 146, #Total UniqueCount: 346
## var 1:
## best............ 3.117713e+02
## mean............ 4.491180e+02
## variance........ 3.784310e+04
## var 2:
## best............ 3.204811e+02
## mean............ 3.566033e+02
## variance........ 4.934686e+04
## var 3:
## best............ 8.953540e+02
## mean............ 8.201898e+02
## variance........ 3.558131e+04
## var 4:
## best............ 2.430161e+02
## mean............ 5.252733e+02
## variance........ 8.290005e+04
##
## GENERATION: 2
## Lexical Fit..... 1.399813e-01 2.027747e-01 2.977929e-01 3.173109e-01 3.191512e-01 4.675469e-01 5.533228e-01 1.000000e+00
## #unique......... 151, #Total UniqueCount: 497
## var 1:
## best............ 3.154467e+02
## mean............ 4.349561e+02
## variance........ 3.684187e+04
## var 2:
## best............ 3.204811e+02
## mean............ 3.143296e+02
## variance........ 2.188672e+04
## var 3:
## best............ 8.953540e+02
## mean............ 8.823551e+02
## variance........ 1.680098e+04
## var 4:
## best............ 2.315600e+02
## mean............ 3.196258e+02
## variance........ 4.335862e+04
##
## GENERATION: 3
## Lexical Fit..... 1.527709e-01 1.836766e-01 2.975220e-01 3.173109e-01 3.210311e-01 4.696501e-01 5.261816e-01 1.000000e+00
## #unique......... 144, #Total UniqueCount: 641
## var 1:
## best............ 3.190852e+02
## mean............ 3.776243e+02
## variance........ 2.072905e+04
## var 2:
## best............ 3.204811e+02
## mean............ 3.194078e+02
## variance........ 9.200264e+03
## var 3:
## best............ 8.953540e+02
## mean............ 8.766310e+02
## variance........ 9.978099e+03
## var 4:
## best............ 2.202190e+02
## mean............ 2.458030e+02
## variance........ 1.220552e+04
##
## GENERATION: 4
## Lexical Fit..... 1.615338e-01 1.836766e-01 3.085102e-01 3.173109e-01 3.191512e-01 4.675469e-01 5.240611e-01 1.000000e+00
## #unique......... 146, #Total UniqueCount: 787
## var 1:
## best............ 3.182247e+02
## mean............ 3.335607e+02
## variance........ 1.086321e+04
## var 2:
## best............ 3.228279e+02
## mean............ 3.330889e+02
## variance........ 8.559153e+03
## var 3:
## best............ 8.953540e+02
## mean............ 8.731569e+02
## variance........ 1.288988e+04
## var 4:
## best............ 2.310825e+02
## mean............ 2.398014e+02
## variance........ 9.616025e+03
##
## GENERATION: 5
## Lexical Fit..... 1.712549e-01 1.725861e-01 2.972509e-01 3.173109e-01 3.199033e-01 4.683888e-01 5.249102e-01 1.000000e+00
## #unique......... 141, #Total UniqueCount: 928
## var 1:
## best............ 3.182247e+02
## mean............ 3.356685e+02
## variance........ 1.074548e+04
## var 2:
## best............ 3.240045e+02
## mean............ 3.306793e+02
## variance........ 7.997325e+03
## var 3:
## best............ 8.953540e+02
## mean............ 8.728502e+02
## variance........ 6.959013e+03
## var 4:
## best............ 2.351843e+02
## mean............ 2.477627e+02
## variance........ 1.202004e+04
##
## GENERATION: 6
## Lexical Fit..... 1.712549e-01 1.725861e-01 2.972509e-01 3.173109e-01 3.199033e-01 4.683888e-01 5.249102e-01 1.000000e+00
## #unique......... 147, #Total UniqueCount: 1075
## var 1:
## best............ 3.182247e+02
## mean............ 3.351683e+02
## variance........ 1.159766e+04
## var 2:
## best............ 3.240045e+02
## mean............ 3.476202e+02
## variance........ 1.258973e+04
## var 3:
## best............ 8.953540e+02
## mean............ 8.635538e+02
## variance........ 1.267400e+04
## var 4:
## best............ 2.351843e+02
## mean............ 2.583278e+02
## variance........ 1.291473e+04
##
## GENERATION: 7
## Lexical Fit..... 1.712549e-01 1.725861e-01 2.972509e-01 3.173109e-01 3.199033e-01 4.683888e-01 5.249102e-01 1.000000e+00
## #unique......... 133, #Total UniqueCount: 1208
## var 1:
## best............ 3.182247e+02
## mean............ 3.243246e+02
## variance........ 4.751737e+03
## var 2:
## best............ 3.240045e+02
## mean............ 3.300245e+02
## variance........ 4.695549e+03
## var 3:
## best............ 8.953540e+02
## mean............ 8.775577e+02
## variance........ 6.777534e+03
## var 4:
## best............ 2.351843e+02
## mean............ 2.476643e+02
## variance........ 6.178393e+03
##
## GENERATION: 8
## Lexical Fit..... 1.712549e-01 1.725861e-01 2.972509e-01 3.173109e-01 3.199033e-01 4.683888e-01 5.249102e-01 1.000000e+00
## #unique......... 135, #Total UniqueCount: 1343
## var 1:
## best............ 3.182247e+02
## mean............ 3.391247e+02
## variance........ 8.605922e+03
## var 2:
## best............ 3.240045e+02
## mean............ 3.405463e+02
## variance........ 7.948977e+03
## var 3:
## best............ 8.953540e+02
## mean............ 8.740219e+02
## variance........ 8.496369e+03
## var 4:
## best............ 2.351843e+02
## mean............ 2.521853e+02
## variance........ 9.615054e+03
##
## GENERATION: 9
## Lexical Fit..... 1.712549e-01 1.725861e-01 2.972509e-01 3.173109e-01 3.199033e-01 4.683888e-01 5.249102e-01 1.000000e+00
## #unique......... 142, #Total UniqueCount: 1485
## var 1:
## best............ 3.182247e+02
## mean............ 3.315015e+02
## variance........ 6.563391e+03
## var 2:
## best............ 3.240045e+02
## mean............ 3.335956e+02
## variance........ 5.253204e+03
## var 3:
## best............ 8.953540e+02
## mean............ 8.749940e+02
## variance........ 5.737406e+03
## var 4:
## best............ 2.351843e+02
## mean............ 2.583928e+02
## variance........ 9.073086e+03
##
## GENERATION: 10
## Lexical Fit..... 1.712549e-01 1.725861e-01 2.972509e-01 3.173109e-01 3.199033e-01 4.683888e-01 5.249102e-01 1.000000e+00
## #unique......... 140, #Total UniqueCount: 1625
## var 1:
## best............ 3.182247e+02
## mean............ 3.297201e+02
## variance........ 6.951976e+03
## var 2:
## best............ 3.240045e+02
## mean............ 3.449407e+02
## variance........ 5.356912e+03
## var 3:
## best............ 8.953540e+02
## mean............ 8.632919e+02
## variance........ 1.690202e+04
## var 4:
## best............ 2.351843e+02
## mean............ 2.507560e+02
## variance........ 5.750340e+03
##
## 'wait.generations' limit reached.
## No significant improvement in 4 generations.
##
## Solution Lexical Fitness Value:
## 1.712549e-01 1.725861e-01 2.972509e-01 3.173109e-01 3.199033e-01 4.683888e-01 5.249102e-01 1.000000e+00
##
## Parameters at the Solution:
##
## X[ 1] : 3.182247e+02
## X[ 2] : 3.240045e+02
## X[ 3] : 8.953540e+02
## X[ 4] : 2.351843e+02
##
## Solution Found Generation 5
## Number of Generations Run 10
##
## Sat Dec 2 11:41:11 2023
## Total run time : 0 hours 3 minutes and 53 seconds
matched <- Match(Y = df1[[outcome]], Tr = df1[[treatment]], X = df1[confounders], Weight.matrix = gen_match)
# Extracting matched treated and control units
matched_treated_units <- df1[matched$index.treated, ]
matched_control_units <- df1[matched$index.control, ]
# Calculate quantile effects
quantiles_to_estimate <- c(0.25, 0.5, 0.75)
quantile_effects <- sapply(quantiles_to_estimate, function(q) {
quantile(matched_treated_units[[outcome]], probs = q) - quantile(matched_control_units[[outcome]], probs = q)
})
# Printing quantile effects
print(quantile_effects)
## 25% 50% 75%
## 1.100 0.105 -0.130
estimate. Briefly evaluate the robustness of your result based on the partial r^2, robustness values, and the plot. Explain your results in a paragraph, including a mention of why this analysis is potentially useful and interesting.
The results from the sensitivity analysis indicate that the estimated positive effect of green ratings on the leasing rates, at 3.935, is somewhat robust to potential unobserved confounding. The partial R^2 value for the treatment effect, being only 0.002, is quite low. This suggests that any unobserved confounder explaining 100% of the residual variance of the outcome would need to be extremely strong to fully account for the estimated effect. A very influential unobserved variable would be required to negate the observed effect of green ratings on leasing rates.
The robustness value of 0.0438 indicates that any unmeasured factor linked to both green ratings and leasing rates would need to influence at least 4.38% of their variability to negate the observed beneficial effect of green ratings on leasing rates.
The robustness value of 0.0224 serves as a cautious benchmark, indicating that any unmeasured factor explaining just over 2.24% of the variation in both green rating and leasing rates could render the observed effect statistically equivalent to zero.
The relatively low robustness values suggest that my model’s findings are quite stable, but they also imply a small chance exists that an unobserved factor could influence the conclusions.
install.packages("sensemakr", repos='http://cran.rstudio.com/')
##
## The downloaded binary packages are in
## /var/folders/fj/bzw0pc4x1jj02gb727vblf6h0000gn/T//RtmpwTb6IK/downloaded_packages
library(sensemakr)
## See details in:
## Carlos Cinelli and Chad Hazlett (2020). Making Sense of Sensitivity: Extending Omitted Variable Bias. Journal of the Royal Statistical Society, Series B (Statistical Methodology).
# Read the data
data_url <- "https://docs.google.com/spreadsheets/d/e/2PACX-1vQnNuE89lhtg3pxJDfp95VSO_FU5w-H23fL-Ps4ljoXQ6JxJn7kReIV9jIfOUWwe0-jUqBaYipGBGdI/pub?gid=1918397729&single=true&output=csv"
d <- read.csv(data_url)
# Convert 'class' to numeric
d$class <- as.numeric(as.factor(d$class))
# Run a linear regression model
model <- lm(leasing_rate ~ green_rating + size + stories + age + class, data = d)
# Perform sensitivity analysis using sensemakr
sensitivity_analysis <- sensemakr(model = model,
treatment = "green_rating",
benchmark_covariates = c("size", "stories", "age", "class"),
kd = 1:3,
ky = 1:3,
q = 1,
alpha = 0.05)
# Show the results of the sensitivity analysis
show(summary(sensitivity_analysis))
## Sensitivity Analysis to Unobserved Confounding
##
## Model Formula: leasing_rate ~ green_rating + size + stories + age + class
##
## Null hypothesis: q = 1 and reduce = TRUE
## -- This means we are considering biases that reduce the absolute value of the current estimate.
## -- The null hypothesis deemed problematic is H0:tau = 0
##
## Unadjusted Estimates of 'green_rating':
## Coef. estimate: 3.3953
## Standard Error: 0.8575
## t-value (H0:tau = 0): 3.9596
##
## Sensitivity Statistics:
## Partial R2 of treatment with outcome: 0.002
## Robustness Value, q = 1: 0.0438
## Robustness Value, q = 1, alpha = 0.05: 0.0224
##
## Verbal interpretation of sensitivity statistics:
##
## -- Partial R2 of the treatment with the outcome: an extreme confounder (orthogonal to the covariates) that explains 100% of the residual variance of the outcome, would need to explain at least 0.2% of the residual variance of the treatment to fully account for the observed estimated effect.
##
## -- Robustness Value, q = 1: unobserved confounders (orthogonal to the covariates) that explain more than 4.38% of the residual variance of both the treatment and the outcome are strong enough to bring the point estimate to 0 (a bias of 100% of the original estimate). Conversely, unobserved confounders that do not explain more than 4.38% of the residual variance of both the treatment and the outcome are not strong enough to bring the point estimate to 0.
##
## -- Robustness Value, q = 1, alpha = 0.05: unobserved confounders (orthogonal to the covariates) that explain more than 2.24% of the residual variance of both the treatment and the outcome are strong enough to bring the estimate to a range where it is no longer 'statistically different' from 0 (a bias of 100% of the original estimate), at the significance level of alpha = 0.05. Conversely, unobserved confounders that do not explain more than 2.24% of the residual variance of both the treatment and the outcome are not strong enough to bring the estimate to a range where it is no longer 'statistically different' from 0, at the significance level of alpha = 0.05.
##
## Bounds on omitted variable bias:
##
## --The table below shows the maximum strength of unobserved confounders with association with the treatment and the outcome bounded by a multiple of the observed explanatory power of the chosen benchmark covariate(s).
##
## Bound Label R2dz.x R2yz.dx Treatment Adjusted Estimate Adjusted Se
## 1x size 0.0039 0.0001 green_rating 3.3439 0.8592
## 2x size 0.0078 0.0002 green_rating 3.2924 0.8608
## 3x size 0.0117 0.0004 green_rating 3.2406 0.8625
## 1x stories 0.0070 0.0036 green_rating 3.0137 0.8590
## 2x stories 0.0139 0.0072 green_rating 2.6294 0.8605
## 3x stories 0.0209 0.0108 green_rating 2.2422 0.8620
## 1x age 0.0112 0.0001 green_rating 3.3375 0.8624
## 2x age 0.0225 0.0001 green_rating 3.2789 0.8673
## 3x age 0.0337 0.0002 green_rating 3.2197 0.8723
## 1x class 0.0221 0.0245 green_rating 1.6083 0.8565
## 2x class 0.0443 0.0491 green_rating -0.2218 0.8554
## 3x class 0.0664 0.0738 green_rating -2.0972 0.8542
## Adjusted T Adjusted Lower CI Adjusted Upper CI
## 3.8920 1.6597 5.0282
## 3.8247 1.6049 4.9798
## 3.7573 1.5499 4.9312
## 3.5084 1.3298 4.6976
## 3.0557 0.9426 4.3161
## 2.6013 0.5526 3.9319
## 3.8700 1.6470 5.0280
## 3.7806 1.5788 4.9791
## 3.6910 1.5097 4.9297
## 1.8777 -0.0707 3.2872
## -0.2593 -1.8985 1.4550
## -2.4552 -3.7716 -0.4227
## Bound Label R2dz.x R2yz.dx Treatment Adjusted Estimate Adjusted Se
## 1 1x size 0.0039 0.0001 green_rating 3.3439 0.8592
## 2 2x size 0.0078 0.0002 green_rating 3.2924 0.8608
## 3 3x size 0.0117 0.0004 green_rating 3.2406 0.8625
## 4 1x stories 0.0070 0.0036 green_rating 3.0137 0.8590
## 5 2x stories 0.0139 0.0072 green_rating 2.6294 0.8605
## 6 3x stories 0.0209 0.0108 green_rating 2.2422 0.8620
## 7 1x age 0.0112 0.0001 green_rating 3.3375 0.8624
## 8 2x age 0.0225 0.0001 green_rating 3.2789 0.8673
## 9 3x age 0.0337 0.0002 green_rating 3.2197 0.8723
## 10 1x class 0.0221 0.0245 green_rating 1.6083 0.8565
## 11 2x class 0.0443 0.0491 green_rating -0.2218 0.8554
## 12 3x class 0.0664 0.0738 green_rating -2.0972 0.8542
## Adjusted T Adjusted Lower CI Adjusted Upper CI
## 1 3.8920 1.6597 5.0282
## 2 3.8247 1.6049 4.9798
## 3 3.7573 1.5499 4.9312
## 4 3.5084 1.3298 4.6976
## 5 3.0557 0.9426 4.3161
## 6 2.6013 0.5526 3.9319
## 7 3.8700 1.6470 5.0280
## 8 3.7806 1.5788 4.9791
## 9 3.6910 1.5097 4.9297
## 10 1.8777 -0.0707 3.2872
## 11 -0.2593 -1.8985 1.4550
## 12 -2.4552 -3.7716 -0.4227
# Plot sensitivity contour plot
plot(sensitivity_analysis, type = "contour")
install.packages("Synth", repos='http://cran.rstudio.com/')
##
## The downloaded binary packages are in
## /var/folders/fj/bzw0pc4x1jj02gb727vblf6h0000gn/T//RtmpwTb6IK/downloaded_packages
library(Synth)
## ##
## ## Synth Package: Implements Synthetic Control Methods.
## ## See https://web.stanford.edu/~jhain/synthpage.html for additional information.
data(basque)
# Preparing the Synth Data
dataprep.out <- dataprep(
foo = basque,
predictors = c("invest"),
predictors.op = "mean",
dependent = "gdpcap",
unit.variable = "regionno",
time.variable = "year",
special.predictors = list(
list("invest", 1990, "mean")
),
treatment.identifier = 7, #the region number for Cantabria
controls.identifier = c(2:6, 8:16, 18), # Excluding 7 (Cantabria)
time.predictors.prior = c(1955:1974),
time.optimize.ssr = c(1955:1974),
unit.names.variable = "regionname",
time.plot = 1955:1997
)
##
## Missing data- treated unit; predictor: invest ; for period: 1955
## We ignore (na.rm = TRUE) all missing values for predictors.op.
##
## Missing data- treated unit; predictor: invest ; for period: 1956
## We ignore (na.rm = TRUE) all missing values for predictors.op.
##
## Missing data- treated unit; predictor: invest ; for period: 1957
## We ignore (na.rm = TRUE) all missing values for predictors.op.
##
## Missing data- treated unit; predictor: invest ; for period: 1958
## We ignore (na.rm = TRUE) all missing values for predictors.op.
##
## Missing data- treated unit; predictor: invest ; for period: 1959
## We ignore (na.rm = TRUE) all missing values for predictors.op.
##
## Missing data- treated unit; predictor: invest ; for period: 1960
## We ignore (na.rm = TRUE) all missing values for predictors.op.
##
## Missing data- treated unit; predictor: invest ; for period: 1961
## We ignore (na.rm = TRUE) all missing values for predictors.op.
##
## Missing data- treated unit; predictor: invest ; for period: 1962
## We ignore (na.rm = TRUE) all missing values for predictors.op.
##
## Missing data- treated unit; predictor: invest ; for period: 1963
## We ignore (na.rm = TRUE) all missing values for predictors.op.
##
## Missing data - control unit: 2 ; predictor: invest ; for period: 1955
## We ignore (na.rm = TRUE) all missing values for predictors.op.
# Creating the synthetic control
synth.out <- synth(dataprep.out)
##
## X1, X0, Z1, Z0 all come directly from dataprep object.
##
##
## ****************
## searching for synthetic control unit
##
##
## ****************
## ****************
## ****************
##
## MSPE (LOSS V): 0.01765056
##
## solution.v:
## 0.288616 0.711384
##
## solution.w:
## 1.6876e-06 1.0836e-05 1.24694e-05 9.851e-06 0.6401554 6.1166e-06 1.9546e-06 0.3597569 6.977e-06 2.4478e-06 9.7447e-06 1.10942e-05 2.261e-06 5.253e-06 6.9488e-06
# Extract weights for the synthetic control
weights <- synth.out$solution.w
# Retrieve the names of the control units
control.unit.names <- basque$regionname[basque$regionno %in% c(2:6, 8:16, 18)]
# Create a table showing the unit weights
unit_weights_table <- data.frame(Region = control.unit.names, Weights = weights)
## Warning in data.frame(Region = control.unit.names, Weights = weights): row
## names were found from a short variable and have been discarded
# Display the unit weights table
print(unit_weights_table)
## Region w.weight
## 1 Andalucia 1.687559e-06
## 2 Andalucia 1.083603e-05
## 3 Andalucia 1.246939e-05
## 4 Andalucia 9.850992e-06
## 5 Andalucia 6.401554e-01
## 6 Andalucia 6.116624e-06
## 7 Andalucia 1.954600e-06
## 8 Andalucia 3.597569e-01
## 9 Andalucia 6.977008e-06
## 10 Andalucia 2.447839e-06
## 11 Andalucia 9.744698e-06
## 12 Andalucia 1.109421e-05
## 13 Andalucia 2.261039e-06
## 14 Andalucia 5.252966e-06
## 15 Andalucia 6.948790e-06
## 16 Andalucia 1.687559e-06
## 17 Andalucia 1.083603e-05
## 18 Andalucia 1.246939e-05
## 19 Andalucia 9.850992e-06
## 20 Andalucia 6.401554e-01
## 21 Andalucia 6.116624e-06
## 22 Andalucia 1.954600e-06
## 23 Andalucia 3.597569e-01
## 24 Andalucia 6.977008e-06
## 25 Andalucia 2.447839e-06
## 26 Andalucia 9.744698e-06
## 27 Andalucia 1.109421e-05
## 28 Andalucia 2.261039e-06
## 29 Andalucia 5.252966e-06
## 30 Andalucia 6.948790e-06
## 31 Andalucia 1.687559e-06
## 32 Andalucia 1.083603e-05
## 33 Andalucia 1.246939e-05
## 34 Andalucia 9.850992e-06
## 35 Andalucia 6.401554e-01
## 36 Andalucia 6.116624e-06
## 37 Andalucia 1.954600e-06
## 38 Andalucia 3.597569e-01
## 39 Andalucia 6.977008e-06
## 40 Andalucia 2.447839e-06
## 41 Andalucia 9.744698e-06
## 42 Andalucia 1.109421e-05
## 43 Andalucia 2.261039e-06
## 44 Aragon 5.252966e-06
## 45 Aragon 6.948790e-06
## 46 Aragon 1.687559e-06
## 47 Aragon 1.083603e-05
## 48 Aragon 1.246939e-05
## 49 Aragon 9.850992e-06
## 50 Aragon 6.401554e-01
## 51 Aragon 6.116624e-06
## 52 Aragon 1.954600e-06
## 53 Aragon 3.597569e-01
## 54 Aragon 6.977008e-06
## 55 Aragon 2.447839e-06
## 56 Aragon 9.744698e-06
## 57 Aragon 1.109421e-05
## 58 Aragon 2.261039e-06
## 59 Aragon 5.252966e-06
## 60 Aragon 6.948790e-06
## 61 Aragon 1.687559e-06
## 62 Aragon 1.083603e-05
## 63 Aragon 1.246939e-05
## 64 Aragon 9.850992e-06
## 65 Aragon 6.401554e-01
## 66 Aragon 6.116624e-06
## 67 Aragon 1.954600e-06
## 68 Aragon 3.597569e-01
## 69 Aragon 6.977008e-06
## 70 Aragon 2.447839e-06
## 71 Aragon 9.744698e-06
## 72 Aragon 1.109421e-05
## 73 Aragon 2.261039e-06
## 74 Aragon 5.252966e-06
## 75 Aragon 6.948790e-06
## 76 Aragon 1.687559e-06
## 77 Aragon 1.083603e-05
## 78 Aragon 1.246939e-05
## 79 Aragon 9.850992e-06
## 80 Aragon 6.401554e-01
## 81 Aragon 6.116624e-06
## 82 Aragon 1.954600e-06
## 83 Aragon 3.597569e-01
## 84 Aragon 6.977008e-06
## 85 Aragon 2.447839e-06
## 86 Aragon 9.744698e-06
## 87 Principado De Asturias 1.109421e-05
## 88 Principado De Asturias 2.261039e-06
## 89 Principado De Asturias 5.252966e-06
## 90 Principado De Asturias 6.948790e-06
## 91 Principado De Asturias 1.687559e-06
## 92 Principado De Asturias 1.083603e-05
## 93 Principado De Asturias 1.246939e-05
## 94 Principado De Asturias 9.850992e-06
## 95 Principado De Asturias 6.401554e-01
## 96 Principado De Asturias 6.116624e-06
## 97 Principado De Asturias 1.954600e-06
## 98 Principado De Asturias 3.597569e-01
## 99 Principado De Asturias 6.977008e-06
## 100 Principado De Asturias 2.447839e-06
## 101 Principado De Asturias 9.744698e-06
## 102 Principado De Asturias 1.109421e-05
## 103 Principado De Asturias 2.261039e-06
## 104 Principado De Asturias 5.252966e-06
## 105 Principado De Asturias 6.948790e-06
## 106 Principado De Asturias 1.687559e-06
## 107 Principado De Asturias 1.083603e-05
## 108 Principado De Asturias 1.246939e-05
## 109 Principado De Asturias 9.850992e-06
## 110 Principado De Asturias 6.401554e-01
## 111 Principado De Asturias 6.116624e-06
## 112 Principado De Asturias 1.954600e-06
## 113 Principado De Asturias 3.597569e-01
## 114 Principado De Asturias 6.977008e-06
## 115 Principado De Asturias 2.447839e-06
## 116 Principado De Asturias 9.744698e-06
## 117 Principado De Asturias 1.109421e-05
## 118 Principado De Asturias 2.261039e-06
## 119 Principado De Asturias 5.252966e-06
## 120 Principado De Asturias 6.948790e-06
## 121 Principado De Asturias 1.687559e-06
## 122 Principado De Asturias 1.083603e-05
## 123 Principado De Asturias 1.246939e-05
## 124 Principado De Asturias 9.850992e-06
## 125 Principado De Asturias 6.401554e-01
## 126 Principado De Asturias 6.116624e-06
## 127 Principado De Asturias 1.954600e-06
## 128 Principado De Asturias 3.597569e-01
## 129 Principado De Asturias 6.977008e-06
## 130 Baleares (Islas) 2.447839e-06
## 131 Baleares (Islas) 9.744698e-06
## 132 Baleares (Islas) 1.109421e-05
## 133 Baleares (Islas) 2.261039e-06
## 134 Baleares (Islas) 5.252966e-06
## 135 Baleares (Islas) 6.948790e-06
## 136 Baleares (Islas) 1.687559e-06
## 137 Baleares (Islas) 1.083603e-05
## 138 Baleares (Islas) 1.246939e-05
## 139 Baleares (Islas) 9.850992e-06
## 140 Baleares (Islas) 6.401554e-01
## 141 Baleares (Islas) 6.116624e-06
## 142 Baleares (Islas) 1.954600e-06
## 143 Baleares (Islas) 3.597569e-01
## 144 Baleares (Islas) 6.977008e-06
## 145 Baleares (Islas) 2.447839e-06
## 146 Baleares (Islas) 9.744698e-06
## 147 Baleares (Islas) 1.109421e-05
## 148 Baleares (Islas) 2.261039e-06
## 149 Baleares (Islas) 5.252966e-06
## 150 Baleares (Islas) 6.948790e-06
## 151 Baleares (Islas) 1.687559e-06
## 152 Baleares (Islas) 1.083603e-05
## 153 Baleares (Islas) 1.246939e-05
## 154 Baleares (Islas) 9.850992e-06
## 155 Baleares (Islas) 6.401554e-01
## 156 Baleares (Islas) 6.116624e-06
## 157 Baleares (Islas) 1.954600e-06
## 158 Baleares (Islas) 3.597569e-01
## 159 Baleares (Islas) 6.977008e-06
## 160 Baleares (Islas) 2.447839e-06
## 161 Baleares (Islas) 9.744698e-06
## 162 Baleares (Islas) 1.109421e-05
## 163 Baleares (Islas) 2.261039e-06
## 164 Baleares (Islas) 5.252966e-06
## 165 Baleares (Islas) 6.948790e-06
## 166 Baleares (Islas) 1.687559e-06
## 167 Baleares (Islas) 1.083603e-05
## 168 Baleares (Islas) 1.246939e-05
## 169 Baleares (Islas) 9.850992e-06
## 170 Baleares (Islas) 6.401554e-01
## 171 Baleares (Islas) 6.116624e-06
## 172 Baleares (Islas) 1.954600e-06
## 173 Canarias 3.597569e-01
## 174 Canarias 6.977008e-06
## 175 Canarias 2.447839e-06
## 176 Canarias 9.744698e-06
## 177 Canarias 1.109421e-05
## 178 Canarias 2.261039e-06
## 179 Canarias 5.252966e-06
## 180 Canarias 6.948790e-06
## 181 Canarias 1.687559e-06
## 182 Canarias 1.083603e-05
## 183 Canarias 1.246939e-05
## 184 Canarias 9.850992e-06
## 185 Canarias 6.401554e-01
## 186 Canarias 6.116624e-06
## 187 Canarias 1.954600e-06
## 188 Canarias 3.597569e-01
## 189 Canarias 6.977008e-06
## 190 Canarias 2.447839e-06
## 191 Canarias 9.744698e-06
## 192 Canarias 1.109421e-05
## 193 Canarias 2.261039e-06
## 194 Canarias 5.252966e-06
## 195 Canarias 6.948790e-06
## 196 Canarias 1.687559e-06
## 197 Canarias 1.083603e-05
## 198 Canarias 1.246939e-05
## 199 Canarias 9.850992e-06
## 200 Canarias 6.401554e-01
## 201 Canarias 6.116624e-06
## 202 Canarias 1.954600e-06
## 203 Canarias 3.597569e-01
## 204 Canarias 6.977008e-06
## 205 Canarias 2.447839e-06
## 206 Canarias 9.744698e-06
## 207 Canarias 1.109421e-05
## 208 Canarias 2.261039e-06
## 209 Canarias 5.252966e-06
## 210 Canarias 6.948790e-06
## 211 Canarias 1.687559e-06
## 212 Canarias 1.083603e-05
## 213 Canarias 1.246939e-05
## 214 Canarias 9.850992e-06
## 215 Canarias 6.401554e-01
## 216 Castilla Y Leon 6.116624e-06
## 217 Castilla Y Leon 1.954600e-06
## 218 Castilla Y Leon 3.597569e-01
## 219 Castilla Y Leon 6.977008e-06
## 220 Castilla Y Leon 2.447839e-06
## 221 Castilla Y Leon 9.744698e-06
## 222 Castilla Y Leon 1.109421e-05
## 223 Castilla Y Leon 2.261039e-06
## 224 Castilla Y Leon 5.252966e-06
## 225 Castilla Y Leon 6.948790e-06
## 226 Castilla Y Leon 1.687559e-06
## 227 Castilla Y Leon 1.083603e-05
## 228 Castilla Y Leon 1.246939e-05
## 229 Castilla Y Leon 9.850992e-06
## 230 Castilla Y Leon 6.401554e-01
## 231 Castilla Y Leon 6.116624e-06
## 232 Castilla Y Leon 1.954600e-06
## 233 Castilla Y Leon 3.597569e-01
## 234 Castilla Y Leon 6.977008e-06
## 235 Castilla Y Leon 2.447839e-06
## 236 Castilla Y Leon 9.744698e-06
## 237 Castilla Y Leon 1.109421e-05
## 238 Castilla Y Leon 2.261039e-06
## 239 Castilla Y Leon 5.252966e-06
## 240 Castilla Y Leon 6.948790e-06
## 241 Castilla Y Leon 1.687559e-06
## 242 Castilla Y Leon 1.083603e-05
## 243 Castilla Y Leon 1.246939e-05
## 244 Castilla Y Leon 9.850992e-06
## 245 Castilla Y Leon 6.401554e-01
## 246 Castilla Y Leon 6.116624e-06
## 247 Castilla Y Leon 1.954600e-06
## 248 Castilla Y Leon 3.597569e-01
## 249 Castilla Y Leon 6.977008e-06
## 250 Castilla Y Leon 2.447839e-06
## 251 Castilla Y Leon 9.744698e-06
## 252 Castilla Y Leon 1.109421e-05
## 253 Castilla Y Leon 2.261039e-06
## 254 Castilla Y Leon 5.252966e-06
## 255 Castilla Y Leon 6.948790e-06
## 256 Castilla Y Leon 1.687559e-06
## 257 Castilla Y Leon 1.083603e-05
## 258 Castilla Y Leon 1.246939e-05
## 259 Castilla-La Mancha 9.850992e-06
## 260 Castilla-La Mancha 6.401554e-01
## 261 Castilla-La Mancha 6.116624e-06
## 262 Castilla-La Mancha 1.954600e-06
## 263 Castilla-La Mancha 3.597569e-01
## 264 Castilla-La Mancha 6.977008e-06
## 265 Castilla-La Mancha 2.447839e-06
## 266 Castilla-La Mancha 9.744698e-06
## 267 Castilla-La Mancha 1.109421e-05
## 268 Castilla-La Mancha 2.261039e-06
## 269 Castilla-La Mancha 5.252966e-06
## 270 Castilla-La Mancha 6.948790e-06
## 271 Castilla-La Mancha 1.687559e-06
## 272 Castilla-La Mancha 1.083603e-05
## 273 Castilla-La Mancha 1.246939e-05
## 274 Castilla-La Mancha 9.850992e-06
## 275 Castilla-La Mancha 6.401554e-01
## 276 Castilla-La Mancha 6.116624e-06
## 277 Castilla-La Mancha 1.954600e-06
## 278 Castilla-La Mancha 3.597569e-01
## 279 Castilla-La Mancha 6.977008e-06
## 280 Castilla-La Mancha 2.447839e-06
## 281 Castilla-La Mancha 9.744698e-06
## 282 Castilla-La Mancha 1.109421e-05
## 283 Castilla-La Mancha 2.261039e-06
## 284 Castilla-La Mancha 5.252966e-06
## 285 Castilla-La Mancha 6.948790e-06
## 286 Castilla-La Mancha 1.687559e-06
## 287 Castilla-La Mancha 1.083603e-05
## 288 Castilla-La Mancha 1.246939e-05
## 289 Castilla-La Mancha 9.850992e-06
## 290 Castilla-La Mancha 6.401554e-01
## 291 Castilla-La Mancha 6.116624e-06
## 292 Castilla-La Mancha 1.954600e-06
## 293 Castilla-La Mancha 3.597569e-01
## 294 Castilla-La Mancha 6.977008e-06
## 295 Castilla-La Mancha 2.447839e-06
## 296 Castilla-La Mancha 9.744698e-06
## 297 Castilla-La Mancha 1.109421e-05
## 298 Castilla-La Mancha 2.261039e-06
## 299 Castilla-La Mancha 5.252966e-06
## 300 Castilla-La Mancha 6.948790e-06
## 301 Castilla-La Mancha 1.687559e-06
## 302 Cataluna 1.083603e-05
## 303 Cataluna 1.246939e-05
## 304 Cataluna 9.850992e-06
## 305 Cataluna 6.401554e-01
## 306 Cataluna 6.116624e-06
## 307 Cataluna 1.954600e-06
## 308 Cataluna 3.597569e-01
## 309 Cataluna 6.977008e-06
## 310 Cataluna 2.447839e-06
## 311 Cataluna 9.744698e-06
## 312 Cataluna 1.109421e-05
## 313 Cataluna 2.261039e-06
## 314 Cataluna 5.252966e-06
## 315 Cataluna 6.948790e-06
## 316 Cataluna 1.687559e-06
## 317 Cataluna 1.083603e-05
## 318 Cataluna 1.246939e-05
## 319 Cataluna 9.850992e-06
## 320 Cataluna 6.401554e-01
## 321 Cataluna 6.116624e-06
## 322 Cataluna 1.954600e-06
## 323 Cataluna 3.597569e-01
## 324 Cataluna 6.977008e-06
## 325 Cataluna 2.447839e-06
## 326 Cataluna 9.744698e-06
## 327 Cataluna 1.109421e-05
## 328 Cataluna 2.261039e-06
## 329 Cataluna 5.252966e-06
## 330 Cataluna 6.948790e-06
## 331 Cataluna 1.687559e-06
## 332 Cataluna 1.083603e-05
## 333 Cataluna 1.246939e-05
## 334 Cataluna 9.850992e-06
## 335 Cataluna 6.401554e-01
## 336 Cataluna 6.116624e-06
## 337 Cataluna 1.954600e-06
## 338 Cataluna 3.597569e-01
## 339 Cataluna 6.977008e-06
## 340 Cataluna 2.447839e-06
## 341 Cataluna 9.744698e-06
## 342 Cataluna 1.109421e-05
## 343 Cataluna 2.261039e-06
## 344 Cataluna 5.252966e-06
## 345 Comunidad Valenciana 6.948790e-06
## 346 Comunidad Valenciana 1.687559e-06
## 347 Comunidad Valenciana 1.083603e-05
## 348 Comunidad Valenciana 1.246939e-05
## 349 Comunidad Valenciana 9.850992e-06
## 350 Comunidad Valenciana 6.401554e-01
## 351 Comunidad Valenciana 6.116624e-06
## 352 Comunidad Valenciana 1.954600e-06
## 353 Comunidad Valenciana 3.597569e-01
## 354 Comunidad Valenciana 6.977008e-06
## 355 Comunidad Valenciana 2.447839e-06
## 356 Comunidad Valenciana 9.744698e-06
## 357 Comunidad Valenciana 1.109421e-05
## 358 Comunidad Valenciana 2.261039e-06
## 359 Comunidad Valenciana 5.252966e-06
## 360 Comunidad Valenciana 6.948790e-06
## 361 Comunidad Valenciana 1.687559e-06
## 362 Comunidad Valenciana 1.083603e-05
## 363 Comunidad Valenciana 1.246939e-05
## 364 Comunidad Valenciana 9.850992e-06
## 365 Comunidad Valenciana 6.401554e-01
## 366 Comunidad Valenciana 6.116624e-06
## 367 Comunidad Valenciana 1.954600e-06
## 368 Comunidad Valenciana 3.597569e-01
## 369 Comunidad Valenciana 6.977008e-06
## 370 Comunidad Valenciana 2.447839e-06
## 371 Comunidad Valenciana 9.744698e-06
## 372 Comunidad Valenciana 1.109421e-05
## 373 Comunidad Valenciana 2.261039e-06
## 374 Comunidad Valenciana 5.252966e-06
## 375 Comunidad Valenciana 6.948790e-06
## 376 Comunidad Valenciana 1.687559e-06
## 377 Comunidad Valenciana 1.083603e-05
## 378 Comunidad Valenciana 1.246939e-05
## 379 Comunidad Valenciana 9.850992e-06
## 380 Comunidad Valenciana 6.401554e-01
## 381 Comunidad Valenciana 6.116624e-06
## 382 Comunidad Valenciana 1.954600e-06
## 383 Comunidad Valenciana 3.597569e-01
## 384 Comunidad Valenciana 6.977008e-06
## 385 Comunidad Valenciana 2.447839e-06
## 386 Comunidad Valenciana 9.744698e-06
## 387 Comunidad Valenciana 1.109421e-05
## 388 Extremadura 2.261039e-06
## 389 Extremadura 5.252966e-06
## 390 Extremadura 6.948790e-06
## 391 Extremadura 1.687559e-06
## 392 Extremadura 1.083603e-05
## 393 Extremadura 1.246939e-05
## 394 Extremadura 9.850992e-06
## 395 Extremadura 6.401554e-01
## 396 Extremadura 6.116624e-06
## 397 Extremadura 1.954600e-06
## 398 Extremadura 3.597569e-01
## 399 Extremadura 6.977008e-06
## 400 Extremadura 2.447839e-06
## 401 Extremadura 9.744698e-06
## 402 Extremadura 1.109421e-05
## 403 Extremadura 2.261039e-06
## 404 Extremadura 5.252966e-06
## 405 Extremadura 6.948790e-06
## 406 Extremadura 1.687559e-06
## 407 Extremadura 1.083603e-05
## 408 Extremadura 1.246939e-05
## 409 Extremadura 9.850992e-06
## 410 Extremadura 6.401554e-01
## 411 Extremadura 6.116624e-06
## 412 Extremadura 1.954600e-06
## 413 Extremadura 3.597569e-01
## 414 Extremadura 6.977008e-06
## 415 Extremadura 2.447839e-06
## 416 Extremadura 9.744698e-06
## 417 Extremadura 1.109421e-05
## 418 Extremadura 2.261039e-06
## 419 Extremadura 5.252966e-06
## 420 Extremadura 6.948790e-06
## 421 Extremadura 1.687559e-06
## 422 Extremadura 1.083603e-05
## 423 Extremadura 1.246939e-05
## 424 Extremadura 9.850992e-06
## 425 Extremadura 6.401554e-01
## 426 Extremadura 6.116624e-06
## 427 Extremadura 1.954600e-06
## 428 Extremadura 3.597569e-01
## 429 Extremadura 6.977008e-06
## 430 Extremadura 2.447839e-06
## 431 Galicia 9.744698e-06
## 432 Galicia 1.109421e-05
## 433 Galicia 2.261039e-06
## 434 Galicia 5.252966e-06
## 435 Galicia 6.948790e-06
## 436 Galicia 1.687559e-06
## 437 Galicia 1.083603e-05
## 438 Galicia 1.246939e-05
## 439 Galicia 9.850992e-06
## 440 Galicia 6.401554e-01
## 441 Galicia 6.116624e-06
## 442 Galicia 1.954600e-06
## 443 Galicia 3.597569e-01
## 444 Galicia 6.977008e-06
## 445 Galicia 2.447839e-06
## 446 Galicia 9.744698e-06
## 447 Galicia 1.109421e-05
## 448 Galicia 2.261039e-06
## 449 Galicia 5.252966e-06
## 450 Galicia 6.948790e-06
## 451 Galicia 1.687559e-06
## 452 Galicia 1.083603e-05
## 453 Galicia 1.246939e-05
## 454 Galicia 9.850992e-06
## 455 Galicia 6.401554e-01
## 456 Galicia 6.116624e-06
## 457 Galicia 1.954600e-06
## 458 Galicia 3.597569e-01
## 459 Galicia 6.977008e-06
## 460 Galicia 2.447839e-06
## 461 Galicia 9.744698e-06
## 462 Galicia 1.109421e-05
## 463 Galicia 2.261039e-06
## 464 Galicia 5.252966e-06
## 465 Galicia 6.948790e-06
## 466 Galicia 1.687559e-06
## 467 Galicia 1.083603e-05
## 468 Galicia 1.246939e-05
## 469 Galicia 9.850992e-06
## 470 Galicia 6.401554e-01
## 471 Galicia 6.116624e-06
## 472 Galicia 1.954600e-06
## 473 Galicia 3.597569e-01
## 474 Madrid (Comunidad De) 6.977008e-06
## 475 Madrid (Comunidad De) 2.447839e-06
## 476 Madrid (Comunidad De) 9.744698e-06
## 477 Madrid (Comunidad De) 1.109421e-05
## 478 Madrid (Comunidad De) 2.261039e-06
## 479 Madrid (Comunidad De) 5.252966e-06
## 480 Madrid (Comunidad De) 6.948790e-06
## 481 Madrid (Comunidad De) 1.687559e-06
## 482 Madrid (Comunidad De) 1.083603e-05
## 483 Madrid (Comunidad De) 1.246939e-05
## 484 Madrid (Comunidad De) 9.850992e-06
## 485 Madrid (Comunidad De) 6.401554e-01
## 486 Madrid (Comunidad De) 6.116624e-06
## 487 Madrid (Comunidad De) 1.954600e-06
## 488 Madrid (Comunidad De) 3.597569e-01
## 489 Madrid (Comunidad De) 6.977008e-06
## 490 Madrid (Comunidad De) 2.447839e-06
## 491 Madrid (Comunidad De) 9.744698e-06
## 492 Madrid (Comunidad De) 1.109421e-05
## 493 Madrid (Comunidad De) 2.261039e-06
## 494 Madrid (Comunidad De) 5.252966e-06
## 495 Madrid (Comunidad De) 6.948790e-06
## 496 Madrid (Comunidad De) 1.687559e-06
## 497 Madrid (Comunidad De) 1.083603e-05
## 498 Madrid (Comunidad De) 1.246939e-05
## 499 Madrid (Comunidad De) 9.850992e-06
## 500 Madrid (Comunidad De) 6.401554e-01
## 501 Madrid (Comunidad De) 6.116624e-06
## 502 Madrid (Comunidad De) 1.954600e-06
## 503 Madrid (Comunidad De) 3.597569e-01
## 504 Madrid (Comunidad De) 6.977008e-06
## 505 Madrid (Comunidad De) 2.447839e-06
## 506 Madrid (Comunidad De) 9.744698e-06
## 507 Madrid (Comunidad De) 1.109421e-05
## 508 Madrid (Comunidad De) 2.261039e-06
## 509 Madrid (Comunidad De) 5.252966e-06
## 510 Madrid (Comunidad De) 6.948790e-06
## 511 Madrid (Comunidad De) 1.687559e-06
## 512 Madrid (Comunidad De) 1.083603e-05
## 513 Madrid (Comunidad De) 1.246939e-05
## 514 Madrid (Comunidad De) 9.850992e-06
## 515 Madrid (Comunidad De) 6.401554e-01
## 516 Madrid (Comunidad De) 6.116624e-06
## 517 Murcia (Region de) 1.954600e-06
## 518 Murcia (Region de) 3.597569e-01
## 519 Murcia (Region de) 6.977008e-06
## 520 Murcia (Region de) 2.447839e-06
## 521 Murcia (Region de) 9.744698e-06
## 522 Murcia (Region de) 1.109421e-05
## 523 Murcia (Region de) 2.261039e-06
## 524 Murcia (Region de) 5.252966e-06
## 525 Murcia (Region de) 6.948790e-06
## 526 Murcia (Region de) 1.687559e-06
## 527 Murcia (Region de) 1.083603e-05
## 528 Murcia (Region de) 1.246939e-05
## 529 Murcia (Region de) 9.850992e-06
## 530 Murcia (Region de) 6.401554e-01
## 531 Murcia (Region de) 6.116624e-06
## 532 Murcia (Region de) 1.954600e-06
## 533 Murcia (Region de) 3.597569e-01
## 534 Murcia (Region de) 6.977008e-06
## 535 Murcia (Region de) 2.447839e-06
## 536 Murcia (Region de) 9.744698e-06
## 537 Murcia (Region de) 1.109421e-05
## 538 Murcia (Region de) 2.261039e-06
## 539 Murcia (Region de) 5.252966e-06
## 540 Murcia (Region de) 6.948790e-06
## 541 Murcia (Region de) 1.687559e-06
## 542 Murcia (Region de) 1.083603e-05
## 543 Murcia (Region de) 1.246939e-05
## 544 Murcia (Region de) 9.850992e-06
## 545 Murcia (Region de) 6.401554e-01
## 546 Murcia (Region de) 6.116624e-06
## 547 Murcia (Region de) 1.954600e-06
## 548 Murcia (Region de) 3.597569e-01
## 549 Murcia (Region de) 6.977008e-06
## 550 Murcia (Region de) 2.447839e-06
## 551 Murcia (Region de) 9.744698e-06
## 552 Murcia (Region de) 1.109421e-05
## 553 Murcia (Region de) 2.261039e-06
## 554 Murcia (Region de) 5.252966e-06
## 555 Murcia (Region de) 6.948790e-06
## 556 Murcia (Region de) 1.687559e-06
## 557 Murcia (Region de) 1.083603e-05
## 558 Murcia (Region de) 1.246939e-05
## 559 Murcia (Region de) 9.850992e-06
## 560 Navarra (Comunidad Foral De) 6.401554e-01
## 561 Navarra (Comunidad Foral De) 6.116624e-06
## 562 Navarra (Comunidad Foral De) 1.954600e-06
## 563 Navarra (Comunidad Foral De) 3.597569e-01
## 564 Navarra (Comunidad Foral De) 6.977008e-06
## 565 Navarra (Comunidad Foral De) 2.447839e-06
## 566 Navarra (Comunidad Foral De) 9.744698e-06
## 567 Navarra (Comunidad Foral De) 1.109421e-05
## 568 Navarra (Comunidad Foral De) 2.261039e-06
## 569 Navarra (Comunidad Foral De) 5.252966e-06
## 570 Navarra (Comunidad Foral De) 6.948790e-06
## 571 Navarra (Comunidad Foral De) 1.687559e-06
## 572 Navarra (Comunidad Foral De) 1.083603e-05
## 573 Navarra (Comunidad Foral De) 1.246939e-05
## 574 Navarra (Comunidad Foral De) 9.850992e-06
## 575 Navarra (Comunidad Foral De) 6.401554e-01
## 576 Navarra (Comunidad Foral De) 6.116624e-06
## 577 Navarra (Comunidad Foral De) 1.954600e-06
## 578 Navarra (Comunidad Foral De) 3.597569e-01
## 579 Navarra (Comunidad Foral De) 6.977008e-06
## 580 Navarra (Comunidad Foral De) 2.447839e-06
## 581 Navarra (Comunidad Foral De) 9.744698e-06
## 582 Navarra (Comunidad Foral De) 1.109421e-05
## 583 Navarra (Comunidad Foral De) 2.261039e-06
## 584 Navarra (Comunidad Foral De) 5.252966e-06
## 585 Navarra (Comunidad Foral De) 6.948790e-06
## 586 Navarra (Comunidad Foral De) 1.687559e-06
## 587 Navarra (Comunidad Foral De) 1.083603e-05
## 588 Navarra (Comunidad Foral De) 1.246939e-05
## 589 Navarra (Comunidad Foral De) 9.850992e-06
## 590 Navarra (Comunidad Foral De) 6.401554e-01
## 591 Navarra (Comunidad Foral De) 6.116624e-06
## 592 Navarra (Comunidad Foral De) 1.954600e-06
## 593 Navarra (Comunidad Foral De) 3.597569e-01
## 594 Navarra (Comunidad Foral De) 6.977008e-06
## 595 Navarra (Comunidad Foral De) 2.447839e-06
## 596 Navarra (Comunidad Foral De) 9.744698e-06
## 597 Navarra (Comunidad Foral De) 1.109421e-05
## 598 Navarra (Comunidad Foral De) 2.261039e-06
## 599 Navarra (Comunidad Foral De) 5.252966e-06
## 600 Navarra (Comunidad Foral De) 6.948790e-06
## 601 Navarra (Comunidad Foral De) 1.687559e-06
## 602 Navarra (Comunidad Foral De) 1.083603e-05
## 603 Rioja (La) 1.246939e-05
## 604 Rioja (La) 9.850992e-06
## 605 Rioja (La) 6.401554e-01
## 606 Rioja (La) 6.116624e-06
## 607 Rioja (La) 1.954600e-06
## 608 Rioja (La) 3.597569e-01
## 609 Rioja (La) 6.977008e-06
## 610 Rioja (La) 2.447839e-06
## 611 Rioja (La) 9.744698e-06
## 612 Rioja (La) 1.109421e-05
## 613 Rioja (La) 2.261039e-06
## 614 Rioja (La) 5.252966e-06
## 615 Rioja (La) 6.948790e-06
## 616 Rioja (La) 1.687559e-06
## 617 Rioja (La) 1.083603e-05
## 618 Rioja (La) 1.246939e-05
## 619 Rioja (La) 9.850992e-06
## 620 Rioja (La) 6.401554e-01
## 621 Rioja (La) 6.116624e-06
## 622 Rioja (La) 1.954600e-06
## 623 Rioja (La) 3.597569e-01
## 624 Rioja (La) 6.977008e-06
## 625 Rioja (La) 2.447839e-06
## 626 Rioja (La) 9.744698e-06
## 627 Rioja (La) 1.109421e-05
## 628 Rioja (La) 2.261039e-06
## 629 Rioja (La) 5.252966e-06
## 630 Rioja (La) 6.948790e-06
## 631 Rioja (La) 1.687559e-06
## 632 Rioja (La) 1.083603e-05
## 633 Rioja (La) 1.246939e-05
## 634 Rioja (La) 9.850992e-06
## 635 Rioja (La) 6.401554e-01
## 636 Rioja (La) 6.116624e-06
## 637 Rioja (La) 1.954600e-06
## 638 Rioja (La) 3.597569e-01
## 639 Rioja (La) 6.977008e-06
## 640 Rioja (La) 2.447839e-06
## 641 Rioja (La) 9.744698e-06
## 642 Rioja (La) 1.109421e-05
## 643 Rioja (La) 2.261039e-06
## 644 Rioja (La) 5.252966e-06
## 645 Rioja (La) 6.948790e-06
# Filter control units
control.units <- basque[basque$regionno %in% c(2:6, 8:16, 18), ]
# Initialize a vector to store synthetic control predictors
synthetic.control.predictors <- numeric()
# Loop over each year in the pre-treatment period
for(year in unique(control.units$year)) {
# Filter the data for the specific year
year.data <- control.units[control.units$year == year, ]
# Calculate the weighted average for this year
weighted.avg <- sum(year.data$invest * weights)
# Append the weighted average to the synthetic control predictors vector
synthetic.control.predictors <- c(synthetic.control.predictors, weighted.avg)
}
# Calculate average of predictors for the treated unit (Cantabria)
treated.unit.predictors <- basque[basque$regionno == 7, "invest"]
# Combine into a data frame for comparison
covariate.balance <- data.frame(
Year = unique(control.units$year),
Treated = treated.unit.predictors,
Synthetic = synthetic.control.predictors
)
# Display the covariate balance
print(covariate.balance)
## Year Treated Synthetic
## 1 1955 NA NA
## 2 1956 NA NA
## 3 1957 NA NA
## 4 1958 NA NA
## 5 1959 NA NA
## 6 1960 NA NA
## 7 1961 NA NA
## 8 1962 NA NA
## 9 1963 NA NA
## 10 1964 25.91898 16.85889
## 11 1965 28.16317 20.65346
## 12 1966 29.71924 25.66349
## 13 1967 28.96760 28.18085
## 14 1968 29.93792 29.85054
## 15 1969 31.72036 27.10337
## 16 1970 27.29768 23.07661
## 17 1971 24.14626 22.53430
## 18 1972 26.64633 26.11632
## 19 1973 25.93579 25.87907
## 20 1974 27.25174 23.39940
## 21 1975 25.41833 20.81156
## 22 1976 23.32227 19.40202
## 23 1977 21.72188 19.65466
## 24 1978 20.85492 19.36353
## 25 1979 19.33496 18.34987
## 26 1980 19.47961 17.59870
## 27 1981 23.02975 15.57289
## 28 1982 20.20423 15.42382
## 29 1983 18.77109 15.29824
## 30 1984 18.22849 14.99904
## 31 1985 19.65163 16.98268
## 32 1986 17.64414 17.94271
## 33 1987 20.14746 19.80665
## 34 1988 20.37456 21.92008
## 35 1989 22.83785 23.18228
## 36 1990 22.03008 23.12190
## 37 1991 20.61010 21.66613
## 38 1992 21.62926 20.47832
## 39 1993 23.06522 17.87544
## 40 1994 21.56840 19.18838
## 41 1995 22.59112 19.20795
## 42 1996 NA NA
## 43 1997 NA NA
# Generating Plots
path.plot <- path.plot(
synth.res = synth.out,
dataprep.res = dataprep.out,
Main = "",
Xlab = "",
Ylab = ""
)
title(main = "Trajectory of Real GDP per Capita: Treated vs. Synthetic",
xlab = "Year",
ylab = "Real GDP per Capita")
# Generating Gaps Plot
gaps_plot <- gaps.plot(
synth.res = synth.out,
dataprep.res = dataprep.out,
Main = "",
Xlab = "",
Ylab = ""
)
# Adding custom titles with the title function
title(main = "Gaps: Treated Unit vs. Synthetic Control",
xlab = "Year",
ylab = "Gap in GDP per Capita (Treated - Synthetic)")
The MSPE for the synthetic control is 0.01765. The low value indicates that there is a good fit between the observed values and the values predicted by the model. There were two regions that dominated the synthetic control with weights of 64% and 36%, which is quite significant. This suggests that these regions are very similar to Cantabria in the weighted characteristics. It can mean a few things: first, these regions are very dominant in the final results, so I will need to check what will happen if I take one of them out of my synthetic control and see if my results are still robust. Secondly, it means that I need to check if these regions have unique characteristics that are not representative of the broader set of control units—because then the estimated effects might not generalize well to other settings. Thirdly, the concentration of weights in a few units can be a sign of overfitting, rather than capturing a more generalized, counterfactual scenario.
Looking at the synthetic and treated groups plot, most of it fits pretty well. The treatment was applied in 1975. Before 1975, there is a slight difference where the synthetic control peaks a little bit higher than the treated group, but other than that, it fits closely. It can be seen that after the mid-1970s, there is a gap between the synthetic control, which has a higher GDP per capita, and the treated group, which has a lower one. This suggests that the treatment had an effect on Cantabria’s GDP.
In the plot gap, it can be seen that the gaps are relatively small and close to zero before the mid-1970s, suggesting that the synthetic control is a good match for Cantabria during the pre-intervention period. From the mid-1970s onwards, the gaps increase and become more negative, indicating that the treated unit’s outcome variable is lower than that of the synthetic control. This change can be potentially interpreted as the treatment effect of political change.
I used AI to help me with the code, and with grammar.