conroylau / lpinfer

lpinfer: An R Package for Inference in Linear Programs
GNU General Public License v3.0
3 stars 5 forks source link

Chorussell handling of +/- Inf confidence interval bounds #102

Closed a-torgovitsky closed 3 years ago

a-torgovitsky commented 4 years ago

The upper bound should be the minimum of +Inf and the logical upper bound. For example,

library("lpinfer")
source("~/R/x86_64-pc-linux-gnu-library/3.6/lpinfer/example/dgp_mixedlogit.R")

set.seed(5)
dgp <- mixedlogit_dgp()
df <- mixedlogit_draw(dgp, n = 4000)

lpm <- lpmodel(A.obs = mixedlogit_Aobs(dgp),
               beta.obs = function(d) mixedlogit_betaobs(d, dgp),
               A.shp = rep(1, nrow(dgp$vdist)),
               beta.shp = 1,
               A.tgt = mixedlogit_Atgt_dfelast(dgp, w2eval = 1, eeval = -1))

set.seed(5)
r <- chorussell(data = df, lpmodel = lpm, ci = TRUE, beta.tgt = .2)
print(r)

which gives

95%-confidence interval: [0.63708, Inf]                                                        

should instead be

95%-confidence interval: [0.63708, 1]

since in this case we can determine that A.tgt * x must be within [0,1].
And analogously for the lower bound, of course.

conroylau commented 4 years ago

Done! I have updated the code to reflect the change. I am assigning the upper/lower bound of the confidence interval as the logical upper/lower bound when none of the candidates for the upper/lower bound satisfy the constraints of the minimization problem.

On the other hand, if the point estimate for the upper bound is Inf, then I am going to set the upper bound of the confidence interval as Inf (and similarly for the lower bound) as discussed in #79.

Thanks!