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

Erroneous warning message for lpSolveAPI #212

Closed a-torgovitsky closed 2 years ago

a-torgovitsky commented 2 years ago

Is this desired behavior?

ivmte(
  data = AE,
  ivlike = c(worked ~ morekids + samesex + morekids * samesex),
  target = "ate",
  m0 = ~ u,
  m1 = ~ u,
  propensity = morekids ~ samesex
)
Warning: The R package 'lpSolveAPI' interfaces with 'lp_solve', which is outdated and potentially unreliable. It is recommended to use commercial solvers Gurobi (solver = 'gurobi'), CPLEX (solver = 'cplexAPI'), or MOSEK (solver = 'Rmosek') instead. Free academic licenses can be obtained for these commercial solvers.

Point estimate of the target parameter: -0.07791036

Warning message:
MTR is point identified via GMM. Shape constraints are ignored. 

I'm focusing on the first warning message. Actually, the second is a problem too, but let me open a different issue for that.

If I specify gurobi then the first error message goes away. But this is for a point identified specification, so why should I get some annoying error about lpSolveAPI? Gurobi isn't being used at all here.

ivmte(
  data = AE,
  ivlike = c(worked ~ morekids + samesex + morekids * samesex),
  target = "ate",
  m0 = ~ u,
  m1 = ~ u,
  propensity = morekids ~ samesex,
  solver = "gurobi"
)

Point estimate of the target parameter: -0.07791036

Warning message:
MTR is point identified via GMM. Shape constraints are ignored. 
jkcshea commented 2 years ago

Okay, this has been corrected now. The warning about lpSolveAPI now pops up when the solver is lpSolveAPI and an LP problem is being solved.

But I'm not sure why you got that message when you did not specify the solver. If no solver is stated, the package first checks whether Gurobi is available. If it is, it should use Gurobi.

So what happens if you run requireNamespace("gurobi")? Nothing should happen. But if you get an error message like

> requireNamespace("gurobi")
Loading required namespace: gurobi
Failed with error:  'there is no package called 'gurobi''

Then I'll find a different way to check what solvers the user has available.

a-torgovitsky commented 2 years ago

Ok, this second part was my problem. I was checking this in RStudio, and for some reason I have path issues (LD_LIBRARY_PATH) in RStudio that I don't have in R console. This lead Gurobi not to load in RStudio. So I think we can close this now if the first part has been corrected.

jkcshea commented 2 years ago

Very good!