Closed a-torgovitsky closed 3 years ago
Done! I have updated the code by setting the default of beta.tgt
as NULL
.
The part of checking beta.tgt
will be ignored if ci = TRUE
as well.
Thanks!
Sorry, I think this is not quite settled. I think the default should be this:
beta.tgt
nor ci
is passed, then build a confidence intervalbeta.tgt
is passed, but ci
is not, then test beta.tgt
ci = TRUE
, then build a confidence interval regardless of whether beta.tgt
is passed.Currently, the second thing is not being done, which seems a bit weird.
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))
r <- chorussell(data = df, lpmodel = lpm)
print(r) # good, confidence interval
r <- chorussell(data = df, lpmodel = lpm, beta.tgt = .2)
print(r) # bad, confidence interval
r <- chorussell(data = df, lpmodel = lpm, beta.tgt = .2, ci = FALSE)
print(r) # good, test
r <- chorussell(data = df, lpmodel = lpm, beta.tgt = .2, ci = TRUE)
print(r) # good, confidence interval
produces
95%-confidence interval: [0.62693, 0.84418]
95%-confidence interval: [0.63283, 0.84376]
p-value: 6e-05
95%-confidence interval: [0.63751, 0.85403]
Done! The above code now gives the followings:
95%-confidence interval: [0.62704, 0.85177]
p-value: 6e-05
p-value: 6e-05
95%-confidence interval: [0.63767, 0.85478]
Thanks!
beta.tgt
plays no role inchorussell
whenci = TRUE
.leads to