Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird issue with constraint in 'taxes' data #24

Open
leeper opened this Issue Mar 15, 2019 · 1 comment

Comments

Projects
None yet
1 participant
@leeper
Copy link
Owner

leeper commented Mar 15, 2019

Please specify whether your issue is about:

  • a possible bug
  • a question about package functionality
  • a suggested code or documentation change, improvement to the code, or feature request

Something weird going on here:

> amce(taxes, chose_plan ~ taxrate2 * taxrev)
Waiting for profiling to be done...
Error in coefs_tmp[!aliased, ] <- coef_summary : 
  number of items to replace is not a multiple of replacement length
> traceback()
2: get_coef_summary(mod = mod, data = data, id = id, alpha = alpha) at amce.R#135
1: amce(taxes, chose_plan ~ taxrate2 * taxrev)
> cj(taxes, chose_plan ~ taxrate2 * taxrev, estimate = "amce")
Waiting for profiling to be done...
Error in coefs_tmp[!aliased, ] <- coef_summary : 
  number of items to replace is not a multiple of replacement length
> traceback()
3: get_coef_summary(mod = mod, data = data, id = id, alpha = alpha) at amce.R#135
2: amce(data = data, formula = formula, id = id, weights = weights, 
       feature_order = feature_order, feature_labels = feature_labels, 
       level_order = level_order, ...) at cj.R#89
1: cj(taxes, chose_plan ~ taxrate2 * taxrev, estimate = "amce")

Seems to only occur with this feature combination, but not without constraint:

> amce(taxes, chose_plan ~ taxrate2 + taxrev)
Waiting for profiling to be done...
     outcome statistic                      feature       level    estimate   std.error         z            p        lower       upper
1 chose_plan      amce Tax rate for $10,000-$35,000  10-35k: 5%  0.00000000          NA        NA           NA           NA          NA
2 chose_plan      amce Tax rate for $10,000-$35,000 10-35k: 15%  0.02907463 0.008612538  3.375849 7.358823e-04  0.012194365  0.04595489
3 chose_plan      amce Tax rate for $10,000-$35,000 10-35k: 25%  0.01679525 0.010284125  1.633124 1.024430e-01 -0.003361265  0.03695176
4 chose_plan      amce Tax rate for $10,000-$35,000 10-35k: 35% -0.04091056 0.011919199 -3.432324 5.984314e-04 -0.064271757 -0.01754936
5 chose_plan      amce                  Tax revenue        <75%  0.00000000          NA        NA           NA           NA          NA
6 chose_plan      amce                  Tax revenue      75-95% -0.04588052 0.008989190 -5.103965 3.326091e-07 -0.063499005 -0.02826203
7 chose_plan      amce                  Tax revenue     95-105% -0.05998096 0.011307260 -5.304641 1.128948e-07 -0.082142777 -0.03781913
8 chose_plan      amce                  Tax revenue    105-125% -0.07391775 0.011029219 -6.701994 2.055952e-11 -0.095534623 -0.05230088
9 chose_plan      amce                  Tax revenue       >125% -0.12287030 0.012610874 -9.743202 1.972386e-22 -0.147587158 -0.09815344

Doesn't happen with unconstrained features:

> cj(taxes, chose_plan ~ taxrate1 * taxrev, estimate = "amce")
Waiting for profiling to be done...
     outcome statistic               feature     level     estimate   std.error           z            p        lower        upper
1 chose_plan      amce Tax rate for <$10,000  <10k: 0%  0.000000000          NA          NA           NA           NA           NA
2 chose_plan      amce Tax rate for <$10,000  <10k: 5%  0.006844784 0.008657404   0.7906278 4.291612e-01 -0.007395378  0.021084946
3 chose_plan      amce Tax rate for <$10,000 <10k: 15% -0.050383031 0.008578737  -5.8730128 4.279453e-09 -0.064493798 -0.036272265
4 chose_plan      amce Tax rate for <$10,000 <10k: 25% -0.167008614 0.009084111 -18.3846949 1.742172e-75 -0.181950648 -0.152066581
5 chose_plan      amce           Tax revenue      <75%  0.000000000          NA          NA           NA           NA           NA
6 chose_plan      amce           Tax revenue    75-95% -0.002781705 0.009200863  -0.3023309 7.623998e-01 -0.017915778  0.012352367
7 chose_plan      amce           Tax revenue   95-105% -0.011051298 0.010595316  -1.0430362 2.969315e-01 -0.028479042  0.006376446
8 chose_plan      amce           Tax revenue  105-125% -0.034789897 0.009172065  -3.7930278 1.488215e-04 -0.049876602 -0.019703193
9 chose_plan      amce           Tax revenue     >125% -0.072428072 0.010124390  -7.1538211 8.439503e-13 -0.089081211 -0.055774933

Doesn't occur with immigration:

> cj(immigration, ChosenImmigrant ~ Education * Job, id = ~ CaseID)
           outcome statistic                feature               level     estimate  std.error          z            p        lower      upper
1  ChosenImmigrant      amce Educational Attainment           No Formal  0.000000000         NA         NA           NA           NA         NA
2  ChosenImmigrant      amce Educational Attainment           4th Grade  0.032242795 0.01564257  2.0612208 3.928198e-02  0.006513054 0.05797254
3  ChosenImmigrant      amce Educational Attainment           8th Grade  0.055971117 0.01568247  3.5690243 3.583132e-04  0.030175749 0.08176649
4  ChosenImmigrant      amce Educational Attainment         High School  0.117940436 0.01569985  7.5122007 5.814154e-14  0.092116478 0.14376439
5  ChosenImmigrant      amce Educational Attainment    Two-Year College  0.164346505 0.02408703  6.8230296 8.914028e-12  0.124726870 0.20396614
6  ChosenImmigrant      amce Educational Attainment      College Degree  0.191558995 0.02414755  7.9328533 2.141674e-15  0.151839805 0.23127818
7  ChosenImmigrant      amce Educational Attainment     Graduate Degree  0.178682719 0.01774300 10.0706030 7.451979e-24  0.149498080 0.20786736
8  ChosenImmigrant      amce                    Job             Janitor  0.000000000         NA         NA           NA           NA         NA
9  ChosenImmigrant      amce                    Job              Waiter -0.004555776 0.01742414 -0.2614635 7.937351e-01 -0.033215933 0.02410438
10 ChosenImmigrant      amce                    Job Child Care Provider  0.013684131 0.01745927  0.7837744 4.331725e-01 -0.015033819 0.04240208
11 ChosenImmigrant      amce                    Job            Gardener  0.015863618 0.01760330  0.9011731 3.674963e-01 -0.013091228 0.04481846
12 ChosenImmigrant      amce                    Job   Financial Analyst  0.065638780 0.03093098  2.1221049 3.382893e-02  0.014761848 0.11651571
13 ChosenImmigrant      amce                    Job Construction Worker  0.033689581 0.01758459  1.9158585 5.538311e-02  0.004765508 0.06261365
14 ChosenImmigrant      amce                    Job             Teacher  0.074107007 0.01752927  4.2276146 2.361819e-05  0.045273920 0.10294009
15 ChosenImmigrant      amce                    Job Computer Programmer  0.078108991 0.03011503  2.5936881 9.495257e-03  0.028574178 0.12764380
16 ChosenImmigrant      amce                    Job               Nurse  0.089129556 0.01748420  5.0977211 3.437667e-07  0.060370613 0.11788850
17 ChosenImmigrant      amce                    Job  Research Scientist  0.135076380 0.03014113  4.4814640 7.413274e-06  0.085498637 0.18465412
18 ChosenImmigrant      amce                    Job              Doctor  0.166308291 0.03004119  5.5360091 3.094415e-08  0.116894933 0.21572165

What's going on here?

@leeper leeper added the question label Mar 15, 2019

@leeper

This comment has been minimized.

Copy link
Owner Author

leeper commented Mar 15, 2019

Unstated constraint in the design?

> subset(cj_props(taxes, ~ taxrate2 + taxrev), Proportion == 0)
      taxrate2 taxrev Proportion
4  10-35k: 35%   <75%          0
17  10-35k: 5%  >125%          0

Maybe so but why doesn't the interaction capture this? Probably because taxrev == "<75%" is the reference category.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.