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

Error after grid expansion #228

Closed johnnybonney closed 1 year ago

johnnybonney commented 2 years ago

I've run into an error when the initial grid is automatically expanding because the initial model was unbounded. I'm not sure that the error has to do with the grid expansion (since it shows up right after Obtaining bounds...), but I'm only able to reproduce it in cases where the audit restarts with an expanded grid.

Here's an example:

library(ivmte)
knots <- seq(0.1, 0.9, 0.1) 

args <- list(data = ivmteSimData,
             outcome = "y",
             m0 = ~factor(x) * uSplines(degree = 0, knots = knots),
             m1 = ~factor(x) * uSplines(degree = 0, knots = knots),
             propensity = d ~ factor(z)*factor(x),
             target = "ate",
             direct = "LP",
             solver = "gurobi",
             solver.options = list(presolve = 0),
             initgrid.nu = 1,
             noisy = T)
do.call(ivmte, args)

produces

Obtaining propensity scores...

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

Performing direct MTR regression...
    MTR is not point identified.

Performing audit procedure...
    Solver: Gurobi ('gurobi')
    Generating initial constraint grid...

    Audit count: 1
    Minimum criterion: 0
    Obtaining bounds...
    Model was unbounded.

    Restarting audit with new settings:
    initgrid.nx =  30 
    initgrid.nu =  2 
    Solver: Gurobi ('gurobi')
    Generating initial constraint grid...

    Audit count: 1
    Minimum criterion: 0
    Obtaining bounds...
    Model was unbounded.

    Restarting audit with new settings:
    initgrid.nx =  45 
    initgrid.nu =  3 
    Solver: Gurobi ('gurobi')
    Generating initial constraint grid...

    Audit count: 1
    Minimum criterion: 0
    Obtaining bounds...
    Model was unbounded.

    Restarting audit with new settings:
    initgrid.nx =  68 
    initgrid.nu =  5 
    Solver: Gurobi ('gurobi')
    Generating initial constraint grid...

    Audit count: 1
    Minimum criterion: 0.0003169575
    Obtaining bounds...
Error in abs(x) : non-numeric argument to mathematical function
jkcshea commented 2 years ago

Done!

The error arose because ivmte was trying to format and report bounds that did not exist.

johnnybonney commented 1 year ago

This same issue seems to be occurring again (but now replace direct = "LP" with direct = "l1" in the example above).

jkcshea commented 1 year ago

Done!

The example was resulting in an unboundedness error. ivmte was not properly catching these errors, though. This has now been resolved. Users are also told to increase the size of the initial grid whenever running into unbounded problems.