Thanks, @mjskay, for this very helpful insight. I am doing this to account for Uncertainty in the Design Stage.
If I am understanding correctly your explanation, the solution to my problem would be to change the structure of the weights from wide to long format with this:
library(tidyr)
#convert to long format
dt_bind <- tibble::rowid_to_column(dt_bind, "id")
dt_bind$id <- factor(dt_bind$id)
dt_long <- gather(dt_bind, draw, weight, weights.w_1:weights.w_10, factor_key=TRUE)
head(dt_long, 12)
id N n r p group treat c1 c2 draw weight
1 10 62 3 0.04838710 1 0 1.941115 0.1438 weights.w_1 1.941115
2 10 96 1 0.01041667 1 0 1.186583 0.2370 weights.w_1 1.186583
3 10 17 0 0.00000000 0 0 1.159883 0.2774 weights.w_1 3.159883
4 10 41 2 0.04878049 1 0 1.159883 0.2774 weights.w_1 3.159883
5 10 212 170 0.80188679 0 0 1.133398 0.2093 weights.w_1 1.133398
6 10 143 21 0.14685315 1 1 1.128993 0.1206 weights.w_1 1.128993
7 10 143 0 0.00000000 1 1 1.128993 0.1707 weights.w_1 2.128993
8 10 143 33 0.23076923 0 1 1.128993 0.0699 weights.w_1 1.128993
9 10 73 62 0.84931507 0 1 1.121927 0.1351 weights.w_1 1.121927
10 10 73 17 0.23287671 0 1 1.121927 0.1206 weights.w_1 1.121927
1 10 62 3 0.04838710 1 0 1.941115 0.1438 weights.w_2 1.931115
2 10 96 1 0.01041667 1 0 1.186583 0.2370 weights.w_2 1.176583
Is that right?
Assuming I am getting it right, how would I then account in my brms
or rstanarm
model for the fact that each id
has a distribution of weights represented by the variable draw
, rather than a single weight?
Thanks in advance.