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

Unable to plot powerCurve #187

Open
weijiexu-charlie opened this issue Aug 22, 2020 · 2 comments
Open

Unable to plot powerCurve #187

weijiexu-charlie opened this issue Aug 22, 2020 · 2 comments

Comments

@weijiexu-charlie
Copy link

weijiexu-charlie commented Aug 22, 2020

Hi,

My code is as follows:

fit2 <- extend(fit, along='Worker.id', n=100) 
powerSim(fit2, test=fixed('X1:X2', 'lr'), nsim=1000)
pc2 <- powerCurve(fit2, fixed('X1:X2', 'lr'), along='Worker.id', nsim=20)

The powerSim function works well, but the powerCurve function gives me a quite strange result for print(pc2):

by largest value of Worker.id:
    100: 30.00% (11.89, 54.28) - 53 rows
     20: 20.00% ( 5.73, 43.66) - 271 rows
     30: 45.00% (23.06, 68.47) - 485 rows
      4: 45.00% (23.06, 68.47) - 680 rows
      5: 65.00% (40.78, 84.61) - 895 rows
      6: 70.00% (45.72, 88.11) - 1110 rows
      7: 75.00% (50.90, 91.34) - 1327 rows
     79: 85.00% (62.11, 96.79) - 1520 rows
     89: 90.00% (68.30, 98.77) - 1738 rows
     99: 90.00% (68.30, 98.77) - 1954 rows

The Worker.id here is not monotonic, which may be the reason that plot(pc2) cannot return a plot as expected.

Also, here's what the summary(pc2) function returns, which looks quite normal:

   nrow nlevels successes trials mean      lower     upper
1    53       3         5     20 0.25 0.08657147 0.4910459
2   271      14         5     20 0.25 0.08657147 0.4910459
3   485      25         8     20 0.40 0.19119006 0.6394574
4   680      35         6     20 0.30 0.11893159 0.5427892
5   895      46         9     20 0.45 0.23057790 0.6847219
6  1110      57        15     20 0.75 0.50895413 0.9134285
7  1327      68        15     20 0.75 0.50895413 0.9134285
8  1520      78        15     20 0.75 0.50895413 0.9134285
9  1738      89        16     20 0.80 0.56338600 0.9426660
10 1954     100        18     20 0.90 0.68301729 0.9876515

Is there any possible reason for the weird results of print(pc2) and plot(pc2)?

Thanks!

@pitakakariki pitakakariki mentioned this issue Sep 2, 2020
19 tasks
@pitakakariki
Copy link
Owner

It's getting confused because Worker.id is a character vector, rather than a factor or a number - note the lexicographic order in the print statement.

If you make your id a factor it should work normally.

@pitakakariki
Copy link
Owner

Note that there might be deeper problems here. How many times in the codebase do I assume something is either a number or a factor?

Need to fix the immediate problem for print and plot, but also add plenty of test to the unit test suite to make sure all three kinds of grouping variable work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants