conroylau / lpinfer

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

Chorussell example that seems wrong/questionable #101

Closed a-torgovitsky closed 3 years ago

a-torgovitsky commented 4 years ago
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)
set.seed(5)
r <- chorussell(data = df, lpmodel = lpm, ci = FALSE, beta.tgt = .634)
print(r)

produces

95%-confidence interval: [0.63708, Inf]                                                        
p-value: 0.32001

But .634 is not in the 95% confidence interval [.637, Inf]. So how can the p-value at that point be larger than .05?

conroylau commented 4 years ago

I have just updated the code in #104. An updated output of the above example is:

95%-confidence interval: [0.63392, 0.88549]
p-value: 0.33002

Since .634 is inside the 95% confidence interval, I think the p-value for this updated output makes sense now.

On the other hand, I tried to test another point that is slightly smaller than the lower bound of the confidence interval:

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

This gives a p-value smaller than 0.05 because it is outside the 95%-confidence interval above.

p-value: 0.01996

Thanks!

a-torgovitsky commented 4 years ago

Ok, that's good. Let's leave this open until solving #104 though, since they are undoubtedly related.

conroylau commented 4 years ago

Sure, I agree. Thanks!