K****a 发帖数: 67 | 1 请版上好心人帮帮我一下,感激不尽
需要用SAS Monte Carlo simulation,模拟一组实验数据 group randomization trial:
要求outcomes within a group are correlated and binary(0/1),given
correlation coefficient as rho=0.01.
predictor variables 有categorical (e.g. treatment, gender ....)和continous
类型。
我搜了许多文献,许多写道要用beta-binomial distribution 来生成数据,可是依然
没有弄明白怎么写code,把这个outcome的相关系数rho插进去,或者我怎么确定相关度
是我想要的呢?
谢谢各位
这是网上一个例子:
data test;
>> b0 = -1.3;
>> b1 = 2.2;
>> b2 = 0;
>> s = 0.6;
>> do group=1 to 30;
>> gamma = s*rannor(123);
>> do id=1 to 25;
>> x1 = ranbin(123,1,0.5);
>> x2 = ranbin(123,1,0.5);
>> eta = gamma + b0 + b1*x1 + b2*x2;
>> p = exp(eta) / (1 + exp(eta));
>> y = ranbin(123,1,p);
>> output;
>> end;
>> end;
>> keep group id x1 x2 y;
>> run; |
|