问题
For the following data,
mydata
ID Y x z
1 1 5.302956 1 1
2 1 3.358249 2 1
3 1 4.976734 3 1
4 1 4.290459 4 1
5 1 0.000000 5 0
6 2 5.975351 1 1
7 2 6.620773 2 1
8 2 8.045909 3 1
9 2 7.378384 4 1
10 2 6.908755 5 1
11 2 8.672657 6 1
12 2 8.284252 7 1
13 2 8.455531 8 1
14 2 7.415175 9 1
15 2 8.634265 10 1
16 3 7.356993 1 1
17 3 6.607598 2 1
18 3 0.000000 3 0
19 3 0.000000 4 0
20 3 0.000000 5 0
21 3 0.000000 6 0
22 3 0.000000 7 0
23 3 0.000000 8 0
24 3 6.398595 9 1
25 3 6.580639 10 1
26 4 5.525104 1 1
27 4 2.326914 2 1
28 4 6.744059 3 1
29 4 6.710523 4 1
30 4 6.876265 5 1
I would like to write a conditional model as (Y|z=1)~LogNormal(mu_i, sig2)
, Where mu_i=theta_i+beta0*x+beta1*x^2
.
I am trying to write in the following way, but it is not working.
model{
for (i in 1:N) {
Y[z[i]<-1]~ dlnorm(mu[i], tau)
mu[i] <- beta0+beta1*x[i]+beta2*pow(x[i],2)
z[i]~dbern(p[i])
logit(p[i])<-alpha_0+alpha_1*x[i]+alpha_2*pow(x[i],2)
}
Any help is appreciated.
来源:https://stackoverflow.com/questions/58810405/writing-conditional-distribution-in-the-winbugs-using-r2winbugs-package-in-r