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

draw_normal_icc() doesn't allow for full range of ICC [0,1] #149

Open
clarabicalho opened this issue Aug 20, 2018 · 4 comments
Open

draw_normal_icc() doesn't allow for full range of ICC [0,1] #149

clarabicalho opened this issue Aug 20, 2018 · 4 comments

Comments

@clarabicalho
Copy link

Designers in the DesignLibrary relying on draw_normal_icc () should allow for to return values when ICC = 0 or 1 without requiring the designer to condition the distribution function on the icc value, oder? Also odd that it doesn't allow for ICC <= 0.001 or ICC >= 0.999. Could the default behavior be a warning instead?

clusters = rep(1:5, 10)
draw_normal_icc(clusters = clusters, ICC = 0.001)

Error in draw_normal_icc(clusters = clusters, ICC = 0.001) : An ICC of 0 with a finite within-cluster variance implies zero between-cluster variance. You can generate data with zero ICC using R's standard rnorm command to generate normal data independent of the cluster variable.

draw_normal_icc(clusters = clusters, ICC = 1)

Error in draw_normal_icc(clusters = clusters, ICC = 0.999) : An ICC of 1 with a finite within-cluster variance requires division by zero to infer between-cluster variance. Try a lower ICC or specify between- and within-cluster variance (sd_between and sd) to infer ICC.

@macartan
Copy link

macartan commented Aug 20, 2018 via email

@graemeblair
Copy link
Member

Hi all -- @aaronrudkin weighed in on this:

The way we set up draw_normal_icc was designed to have the user specify one of sd_between or sd_within and ICC. Mathematically, sd_between^2 = (ICC * sd_within^2) / (1 - ICC). So when ICC = 1, this is a divide by zero. Where ICC is very near 1, sd_between goes to near infinity. And similar problems happen with ICC=0. I believe we preferred errors to producing near-nonsense data or allowing R to NaN and causing less interpretable errors later.

I think we should do special casing in the designer, but that this is the right behavior in fabricatr. Feel free to reopen if you disagree.

@macartan macartan reopened this Aug 22, 2018
@macartan
Copy link

Understand why this is happening but not sure this is the best handling of these cases.

  • for the first case just implementing the normal in this case would make sense --- why not just do that instead of giving an error
  • for the second I think the error should be " An ICC of 1 is not possible with positive within-cluster variance. " not "An ICC of 1 with a finite within-cluster variance requires division by zero to infer between-cluster variance. "
  • in the second case also it ought to be possible with within cluster variance of 0 by assigning same values to all units in a cluster

@graemeblair
Copy link
Member

ok sounds good. think this should be done with the #133 change and also draw_binary_icc should have the same behaviors so a bit of work. given time constraints, will leave out for this version.

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

3 participants