Print

Print


Hi there,


I hope this email finds you well. Last week I come up with a problem with my code for initializations as the P[] values in priors where not satisfied for 0<p<1. I received very helpful advice to change the P[] prior to Dirichlet. I think the problem with priors are now fixed

but again the code cannot be initialized. I received this error "error of node k[1] of type graphmultinom, node invalid integer value".

I used integer value for k[], but do not get what is the issue. I just guess it is a problem with reading k[] values. I will be thankful if you help me with this. Here is the final code:


model
{
# MPT Category Probabilities for Word Pairs
  theta[1] <- p[1] * u1     
 theta[2] <-  p[2] * u2   
  theta[3] <-  p[3] * u3    
  theta[4] <-  p[4] * u4  
 theta[5] <-  p[5] * u5  
 theta[6] <-  p[6] * u6 
 theta[7] <-  p[7] * u7 
 theta[8] <-  p[8] * u8 
 theta[9] <-  (1-(p[1]+p[2]+p[3]+p[4]+p[5]+p[6]+p[7]+p[8]) )* (u9) 
 theta[10] <-  (p[1] * (1-u1)) +(p[2]* (1-u2))+(p[3]* (1-u3))+(p[4]* (1-u4))+(p[5]* (1-u5))+(p[6]* (1-u6))+(p[7]* (1-u7))+(p[8]* (1-u8))+ ((1-(p[1]+p[2]+p[3]+p[4]+p[5]+p[6]+p[7]+p[8]) )*(1-u9))

for (i in 1:N){
 k[i,1:10]~dmulti(theta[1:10],N)
 #N<- sum(k[i,1:10])
}

 p[1:8]~ddirch(alpha[1:8])
  u1 ~ dbeta(1,1)
 u2 ~ dbeta(1,1)
 u3 ~ dbeta(1,1)
 u4 ~ dbeta(1,1)
 u5 ~ dbeta(1,1)
 u6 ~ dbeta(1,1)
 u7 ~ dbeta(1,1)
 u8 ~ dbeta(1,1)
 u9 ~ dbeta(1,1)
}

data
list(N=9, alpha=c(1,1,1,1,1,1,1,1), k = structure(.Data = c(1,0,0,0,0,0,0,0,0,6,0,1,0,0,0,0,0,0,0,5,0,0,1,0,0,0,0,0,0,8,0,0,0,1,0,0,0,0,0,3,0,0,0,0,1,0,0,0,0,6,0,0,0,0,0,2,0,0,0,4,0,0,0,0,0,0,1,0,0,6,0,0,0,0,0,0,0,1,0,4,0,0,0,0,0,0,0,0,1,2), .Dim = c(9, 10)))  

Many thanks for your considerations, in advance.

Regards,
Mahdi







From: Sujit Ghosh <[log in to unmask]>
Sent: 14 June 2019 05:34:29
To: Mohammad Abaei
Cc: [log in to unmask]
Subject: Re: Error in Initializing
 
In your original email with 10 theta's, the parametrization does theoretically sum to one as long as sum of the p's don't exceed one. So, you can simply use a ddirch prior on p[1:9] but just use p[1:8]. You may use any dbeta priors for the u's. 

Also when specify the dmulti for k, make sure sum of entries of k[i, ] is specified correctly in dmulti (theta[1:10], N[i]). N[i]'s should be entered as data.

Hope this helps.

Prof. Sujit Ghosh, Dept of Statistics, NC State University, Raleigh, USA (9195152570)
"simplicity is the key to satisfaction"
[sent from Android phone]

On Thu, Jun 13, 2019, 12:57 PM Mohammad Abaei <[log in to unmask]> wrote:

Dear Bob,


Thank you for your valuable advice. I did what you suggest. when i used Dirichlet distribution, i received just this error "Dirichlet35" after pushing get initials. it may be useful to know that, i have no problem with the code if the theta is less than 4, but when i increase the number of theta then this problem occurs. here is the code:


model{
  # MPT Category Probabilities for Word Pairs
  theta[1] <- p1 * u1     
 theta[2] <-  (p2) * u2   
 theta[3] <- (p3) * u3    
 theta[4] <- (p4) * u4    
 theta[5] <- (p5) * u5    
 theta[6] <- (1-p1-p2-p3-p4-p5) * u6    

 theta[7] <-  1-theta[1]-theta[2]-theta[3]-theta[4]-theta[5]-theta[6]

  # Data     
for (i in 1:n) {
  k[i,1:7] ~ ddirch(theta[1:7])
}
  # Priors
  p1 ~ dbeta(1,1)
  p2 ~ dbeta(1,1)
  p3 ~ dbeta(1,1)
  p4 ~ dbeta(1,1)
  p5 ~ dbeta(1,1)


  

  u1 ~ dunif(0,1)
 u2 ~ dunif(0,1)
   u3 ~ dunif(0,1)
  u4 ~ dunif(0,1)
 u5 ~ dunif(0,1)
   u6 ~ dunif(0,1)



}
 
list(n= 6, k = structure(.Data = c(1,0,0,0,0,0,6,0,1,0,0,0,0,5,0,0,1,0,0,0,8,0,0,0,1,0,0,3,0,0,0,0,1,0,6,0,0,0,0,0,2,4), .Dim = c(6, 7)))  



From: Bob OHara <[log in to unmask]>
Sent: 13 June 2019 17:41:39
To: Mohammad Abaei; [log in to unmask]
Subject: Re: [BUGS] Error in Initializing
 

There is nothing in the code to stop (say) theta[1] + theta[2] being greater than 1.


One solution is to use a Dirichlet distribution. Another is to divide the theta's by their sum. Which is better is difficult to say without knowing the modelling context.


Bob


On 6/13/19 4:03 PM, Mohammad Abaei wrote:

Hi there,


I will be thankful if you guide me on running my code. 

The code is synthetically correct and I can choose the chains to compile the code. However, winbugs would not allow me to get the initials and give this error "Elements of proportion vector of multinomial k[1,1] must be between zero and one. However, i satisfied this requirement in my code when i defined theta [9] and [10]. could you kindly advice me on this issue? 


Here is the code:



model{
  theta[1] <- p1 * u1     
 theta[2] <-  p2 * u2   
  theta[3] <-  p3 * u3    
  theta[4] <-  p4 * u4  
 theta[5] <-  p5 * u5  
 theta[6] <-  p6 * u6 
 theta[7] <-  p7 * u7 
 theta[8] <-  p8 * u8 
 theta[9] <-  (1-(p1+p2+p3+p4+p5+p6+p7+p8) )* (u9) 
 theta[10] <-  (p1 * (1-u1)) +(p2* (1-u2))+(p3* (1-u3))+(p4* (1-u4))+(p5* (1-u5))+(p6* (1-u6))+(p7* (1-u7))+(p8* (1-u8))+ ((1-(p1+p2+p3+p4+p5+p6+p7+p8) )*(1-u9))

  # Data     
for (i in 1:n) {
  k[i,1:10] ~ dmulti(theta[1:10],n)
}
  # Priors
  p1 ~ dbeta(1,1)
  p2  ~ dbeta(1,1)
  p3 ~ dbeta(1,1)
  p4 ~ dbeta(1,1)
  p5 ~ dbeta(1,1)
  p6 ~ dbeta(1,1)
  p7 ~ dbeta(1,1)
  p8 ~ dbeta(1,1)

  u1 ~ dbeta(1,1)
 u2 ~ dbeta(1,1)
 u3 ~ dbeta(1,1)
 u4 ~ dbeta(1,1)
 u5 ~ dbeta(1,1)
 u6 ~ dbeta(1,1)
 u7 ~ dbeta(1,1)
 u8 ~ dbeta(1,1)
 u9 ~ dbeta(1,1)

}
 
list(n= 9, k = structure(.Data = c(1,0,0,0,0,0,0,0,0,6,0,1,0,0,0,0,0,0,0,5,0,0,1,0,0,0,0,0,0,8,0,0,0,1,0,0,0,0,0,3,0,0,0,0,1,0,0,0,0,6,0,0,0,0,0,2,0,0,0,4,0,0,0,0,0,0,1,0,0,6,0,0,0,0,0,0,0,1,0,4,0,0,0,0,0,0,0,0,1,2

), .Dim = c(9, 10)))  

Thank you for your consideration, in advance.

Regards,
Mahdi

------------------------------------------------------------------- This list is for BUGS users to support each other, ask questions or share ideas. 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
-- 
Bob O'Hara
Institutt for matematiske fag
NTNU
7491 Trondheim
Norway

Mobile: +47 915 54 416
Journal of Negative Results - EEB: www.jnr-eeb.org 
------------------------------------------------------------------- This list is for BUGS users to support each other, ask questions or share ideas. 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
------------------------------------------------------------------- This list is for BUGS users to support each other, ask questions or share ideas. 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