conroylau / lpinfer

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

Chorussell returns are needlessly lists #103

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(class(r$lb.bs))

It is a list with one element. That element is a vector with 100 (for bootstrap reps) elements. Why not just make it a single vector?

conroylau commented 4 years ago

My rationale for making them as a list is to cater the case when the user passes a vector to the tuning parameter kappa. If they do so, then each element in the list corresponds to the bounds for each tuning parameter. For instance, if kappa = c(.1, .2), then r$lb.bs will be a list of two elements, where each element contains R bootstrap bounds.

But I agree that when the user passes only one parameter, I can just make it a single vector to make things simpler and save some memory. I have just updated the code to reflect this.

I did the same for other procedures where the tuning parameter can be a vector. I will check again to turn the lists into vectors if the user only passes one tuning parameter.

Thanks!

conroylau commented 4 years ago

I have also checked through the other procedures and did the same for the list objects when the tuning parameter is single-valued.