draw_binary_icc does not error if prob is of length N - but arbitrarily/randomly selects probs not of length k
Opened this issue · 1 comments
graemeblair commented
tau <- 0.1
design <-
declare_model(
clusters = add_level(N = 100, prob = runif(N, min = 0, max = 0.9), prob = if_else(prob < 0.2, 0, prob)),
people = add_level(N = 10)
) +
declare_model(
potential_outcomes(bin ~ draw_binary_icc(prob = prob * (1 + Z * tau), clusters = clusters, ICC = 0.1))
)
design |> draw_data() |> group_by(zero = prob == 0) |> summarize(mean(bin_Z_0))
should have no 1's in the outcome in control when prob is 0 but it has lots
Need to handle prob of length N (or at minimum error if not)
nfultz commented
Replication with fabricatr only:
df <- fabricate(
clusters = add_level(N = 100, prob = runif(N, min = 0, max = 0.9), prob = ifelse(prob < 0.2, 0, prob)),
people = add_level(N = 10, Y_Z0 = draw_binary_icc(prob = prob, clusters = clusters, ICC = 0.1))
)xtabs(~Y_Z0+I(prob==0), df)
Would like you to double check this but I think issue is this line:
Line 50 in ac0716f
I think the issue is the code's interaction with the people
level. In this case, 'cluster_prob' is length 1000 (eg clusters * people), but drawing k
(100) which uses first 100 probs (eg first 10 clusters, 10 copies each).