jkcshea / ivmte

An R package for implementing the method in Mogstad, Santos, and Torgovitsky (2018, Econometrica).
GNU General Public License v3.0
18 stars 2 forks source link

Infeasible monotonicity constraints #193

Closed jkcshea closed 3 years ago

jkcshea commented 3 years ago

This example is the same as in #191, but with m0.dec = TRUE. This causes an error since m0 is declared to be just the intercept.

> data <- fread("data_example.csv")
> r <- ivmte(data = data,
+            target = "ate",
+            ivlike = YD ~ Z1,
+            propensity = D ~ Z1,
+            m1 = ~ 0 + uSplines(degree = 0, knots = c(.5)),
+            m0 = ~ 1,
+            m0.lb = 0,
+            m0.ub = 0,
+            m0.dec = TRUE,
+            audit.nu = 200,
+            noisy = TRUE)

LP solver: Gurobi ('gurobi')

Obtaining propensity scores...

Generating target moments...
    Integrating terms for control group...

Generating IV-like moments...
    Moment 1...
    Moment 2...
    Independent moments: 2 

Performing audit procedure...
    Generating initial constraint grid...
Error in dimnames(x) <- dn : 
  length of 'dimnames' [2] not equal to array extent
jkcshea commented 3 years ago

This was because the code was trying to include the monotonicity shape constraints in the A matrix (see #191). But this unnecessary if neither m0 nor m1 includes the u variable or a spline. This has been corrected, and the following warning message is thrown out instead.

> library(data.table)
> data <- fread("data_example.csv")
> ivmte(data = data,
+       target = "ate",
+       ivlike = YD ~ Z1,
+       propensity = D ~ Z1,
+       m1 = ~ 1,
+       m0 = ~ 1,
+       m1.dec = TRUE)

Bounds on the target parameter: [0.6624073, 0.6624073]
Audit terminated successfully after 1 round 

Warning message:
Neither 'm0' nor 'm1' contains the unobserved variable 'u'. 
Monotonicity constraints only apply to the unobserved variable, 
so will be ignored.