Hello
I am generating a model with binary outcome.
Here's my code:
p0 is 0.2, p1 are 0.3 and 0.4, nlist 200 400, number of clusters: 20 40; u0list 0 0.1
I generate the model by using the following code:
set obs `n'
gen index = _n
gen site = 1 + int(runiform(0,`cluster'))
sort site
bysort site: gen trt = mod(_n,2)
gen u0 = rnormal(0,`u0')
by site: replace u0 = u0[1]
gen p = `p0' * (trt==0) + `p1' * (trt==1)
gen y = rbinomial(1,p)
and I use these two methods to analyse:
* chi-square
logistic y trt
local chip = e(p)
local chiEST = _b[trt]
local chiSE = _se[trt]
*fixed regression adjusted by site
logistic y trt i.site
local fep = e(p)
local feEST = _b[trt]
local feSE = _se[trt]
I have 2 questions:
i)
I don't know how to add a random slope u1 into my model (e.g. u1 = rnormal (0, 0.1) ).
ii)
Also, I have two values of p1, I local the estimate of each method, I want to calculate the bias of estimate for each method.
May I ask how can I generate the true effect and minus it? (e.g. bias = chiEST - true effect)
Thank you very much!
I am generating a model with binary outcome.
Here's my code:
p0 is 0.2, p1 are 0.3 and 0.4, nlist 200 400, number of clusters: 20 40; u0list 0 0.1
I generate the model by using the following code:
set obs `n'
gen index = _n
gen site = 1 + int(runiform(0,`cluster'))
sort site
bysort site: gen trt = mod(_n,2)
gen u0 = rnormal(0,`u0')
by site: replace u0 = u0[1]
gen p = `p0' * (trt==0) + `p1' * (trt==1)
gen y = rbinomial(1,p)
and I use these two methods to analyse:
* chi-square
logistic y trt
local chip = e(p)
local chiEST = _b[trt]
local chiSE = _se[trt]
*fixed regression adjusted by site
logistic y trt i.site
local fep = e(p)
local feEST = _b[trt]
local feSE = _se[trt]
I have 2 questions:
i)
I don't know how to add a random slope u1 into my model (e.g. u1 = rnormal (0, 0.1) ).
ii)
Also, I have two values of p1, I local the estimate of each method, I want to calculate the bias of estimate for each method.
May I ask how can I generate the true effect and minus it? (e.g. bias = chiEST - true effect)
Thank you very much!
Comment