Hey,
Sorry for bothering everyone.
I used WINBUGS to estimate a multilevel binary model using a data set
which I generated a in SAS, and repeated this procedure 500 times. But
the averaged results were not very good. Is there any one who also
interested in this question or have some suggestions on that?
I really really appreciate!
Best wishes,
Tianji Cai
SAS code for data generation
%let beta0=0.5;
%let beta1=1;
%let beta2=3;
%let beta3=-4;
%let sigma1=.25;
*specify constans for simulation;
%let times=1;
%let seed=1257877;
%let npair=200;
%let nind=10;
data _temp;
do i=1 to &npair;
u=rannor(&seed)*sqrt(&sigma1);
do j=1 to &nind;
x1=ranuni(&seed);
x2=ranuni(&seed);
x3=ranuni(&seed);
p=exp(&beta0+&beta1*x1+&beta2*x2+&beta3*x3+u)/(1+exp(&beta0+&beta1*x1+&beta2*x2+&beta3*x3+u));
y=ranbin(&seed,1,p);
output;
end;
end;
run;
WINBUGS code for estimation
model
{ for( i in 1 : 200 ) {
mu[i] ~ dnorm (0.0,tau)
for( j in 1 : 10 ) {
y[i,j] ~ dbin(k[i,j],1)
logit(k[i,j]) <- beta0 + beta1*x1[i,j]+ beta2*x2[i,j]+ beta3*x3[i,j]+mu[i]
}
}
beta0 ~ dflat()
beta1 ~ dflat()
beta2 ~ dflat()
beta3 ~ dflat()
tau~ dgamma(0.001,0.001)
sigma <- 1 / sqrt(tau)
}
list(beta0 = 1,beta1 = 0,beta2 = 1,beta3 = 2,
mu=c(0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9), tau =
1)
Results
The MEANS Procedure
Variable N Mean Std Dev Minimum
Maximum
???????????????????????????????????????????????????????????????????????????????
beta0 500 0.4783718 0.1726851 -0.0317700
0.9595000
beta1 500 0.8635372 0.1912628 0.0253100
1.3260000
beta2 500 2.5657540 0.2033581 1.8820000
3.2020000
beta3 500 -3.4349880 0.2178086 -4.1460000
-2.8360000
sigma 500 0.5715244 0.1049929 0.1909000
0.8254000
sd_beta0 500 0.0938734 0.0116369 0.0803800
0.1916000
sd_beta1 500 0.1907900 0.0057146 0.1726000
0.2082000
sd_beta2 500 0.2036386 0.0069660 0.1822000
0.2268000
sd_beta3 500 0.2138558 0.0081562 0.1931000
0.2429000
sd_sigma 500 0.0938734 0.0116369 0.0803800
0.1916000
???????????????????????????????????????????????????????????????????????????????
-------------------------------------------------------------------
This list is for discussion of modelling issues and the BUGS software.
For help with crashes and error messages, first mail [log in to unmask]
To mail the BUGS list, mail to [log in to unmask]
Before mailing, please check the archive at www.jiscmail.ac.uk/lists/bugs.html
Please do not mail attachments to the list.
To leave the BUGS list, send LEAVE BUGS to [log in to unmask]
If this fails, mail [log in to unmask], NOT the whole list
|