conroylau / lpinfer

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

Allow for multiple tau in DKQS #39

Closed a-torgovitsky closed 4 years ago

a-torgovitsky commented 4 years ago

Same as #25 with lambda for fsst.

Currently I get rather strange behavior:

rdkqs <- dkqs(data = data,
              lpmodel = lpm,
              beta.tgt = .3,
              R = 100,
              tau = c(.2, .5),
              solver = "gurobi",
              cores = 1,
              progress = TRUE)
print(rdkqs)
Test statistic: 99.35703.             
p-value: 0.32.
Value of tau used: 0.2.
 Value of tau used: 0.5.
Solver used: gurobi.
Number of cores used: 1.
Warning messages:
1: In temp[1] <- coeff.tau :
  number of items to replace is not a multiple of replacement length
2: In temp[1] <- coeff.tau :
  number of items to replace is not a multiple of replacement length
3: In temp[1] <- coeff.tau :
  number of items to replace is not a multiple of replacement length
4: In temp[1] <- coeff.tau :
  number of items to replace is not a multiple of replacement length
5: In temp[1] <- coeff.tau :
  number of items to replace is not a multiple of replacement length
6: In temp[1] <- coeff.tau :
  number of items to replace is not a multiple of replacement length
7: In temp[1] <- coeff.tau :
  number of items to replace is not a multiple of replacement length
8: In temp[1] <- coeff.tau :
  number of items to replace is not a multiple of replacement length
9: In if (tau > tau.return$objval) { :
  the condition has length > 1 and only the first element will be used
10: In if (tau <= tau.return$objval) { :
  the condition has length > 1 and only the first element will be used
conroylau commented 4 years ago

I am updating the code for multiple tau and I am thinking what would be the best output in the following hypothetical example:

Hence, in the case of having multiple taus in dkqs, should the code only run and print the results with tau = 0.1, 0.2 and 0.4, and then add a remark saying that tau = 0.5 and 0.9 are infeasible?

Thanks!

a-torgovitsky commented 4 years ago

That sounds like a good solution to me!

conroylau commented 4 years ago

Done! The code now allows for multiple taus. The following is a sample output with multiple taus:

Input (following the example file earlier)

rdkqs <- dkqs(data = data,
              lpmodel = lpm,
              beta.tgt = .3,
              R = 100,
              tau = c(.2, .5, 2, 10),
              solver = "gurobi",
              cores = 2,
              progress = TRUE)

Output for print(rdkqs):

p-values:
 tau p-value
 0.2    0.29
 0.5    0.31
 1.0    0.39
The following taus from the input are infeasible: 2, 10

Output for summary(rdkqs):

p-values:
 tau p-value
 0.2    0.29
 0.5    0.31
 1.0    0.39
Test statistic: 99.35703
Solver used: gurobi
Number of cores used: 2
Maximum feasible tau: 1
The following taus from the input are infeasible: 2, 10

Thanks!

a-torgovitsky commented 4 years ago

Looks good, but maybe to keep it more coherent, it would be better to add the infeasible ones also to the table with p-value listed as infeasible Also, I don't think there is any need for the first p-values: in the top line

conroylau commented 4 years ago

Done! The updated messages look like the followings:

Print:

 tau    p-value
 0.2       0.29
 0.5       0.31
   1       0.39
   2 infeasible
  10 infeasible

Summary:

 tau    p-value
 0.2       0.29
 0.5       0.31
   1       0.39
   2 infeasible
  10 infeasible
 Maximum feasible tau: 1
 Test statistic: 99.35703
 Solver used: gurobi
 Number of cores used: 2
a-torgovitsky commented 4 years ago

Looks good!