Print

Print


Final pre-Christmas post re this - Mark Brewer pointed out that in
WinBUGS 1.4.3 using the 'round' function produces almost exactly correct
results, at least in this simple example - see below (also shows that
using 'trunc' does not...)
 
David 
[log in to unmask]
Immpact Project
University of Aberdeen
 
################# #######################
Simple eg of problem poisson code - 
 
{
MuTrunc~dunif(0,100)
MuRound~dunif(0,100)
MuEqual~dunif(0,100)
MuCheck~dunif(0,100)
 
Trunc~dpois(MuTrunc)     
Round~dpois(MuRound)      
Equal~dpois(MuEqual)        
Check~dpois(MuCheck)             
 
Trunc2 <- trunc(Trunc)
Round2 <- round(Round)
Equal2 <- Equal
 
ChF1<-equals(Check, 1)
RoF1<-equals(Round2, 1)
TrF1<-equals(Trunc2, 1)
 
ChF2<-equals(Check, 2)
RoF2<-equals(Round2, 2)
TrF2<-equals(Trunc2, 2)
 
ChF3<-equals(Check, 3)
RoF3<-equals(Round2, 3)
TrF3<-equals(Trunc2, 3)
 
ObsTrunc~dbin(0.7,Trunc2) 
ObsRound~dbin(0.7,Round2) 
ObsEqual~dbin(0.7,Equal2) 
ObsCheck~dbin(0.7,Check)
}
 
Data   list( ObsCheck=1 ,  ObsEqual=1 , ObsRound=1 , ObsTrunc=1 )
 
Inits   list( MuRound=2 ,  MuCheck=2 ,  MuEqual=2 , MuTrunc=2 ,
                        Trunc=3 , Round=3 , Equal=3, Check=3  ) 
 
WinBUGS 1.4.3 output
 
node       mean     sd          MC error              2.5%        5.0%
10.0%      25.0%      median  75.0%      90.0%      95.0%      97.5%
start       
 
                Check      1.863       1.112       0.003662 1.0
1.0           1.0           1.0           2.0           2.0
3.0           4.0           5.0           23001                178000
                
                Equal       2.208       1.086       0.004199 1.038
1.077       1.155       1.407       1.908       2.695       3.658
4.36         5.05         23001                178000
                Equal2     2.208       1.086       0.004199 1.038
1.077       1.155       1.407       1.908       2.695       3.658
4.36         5.05         23001      
                Round      1.856       1.141       0.004516 0.5505
0.6013     0.7052     1.01         1.538       2.385       3.375
4.12         4.762       23001      
                Round2    1.857       1.105       0.004434 1.0
1.0           1.0           1.0           2.0           2.0
3.0           4.0           5.0           23001                178000
                Trunc       2.352       1.133       0.004155 1.052
1.104       1.205       1.509       2.033       2.878       3.866
4.623       5.251       23001      
                Trunc2     1.852       1.095       0.004025 1.0
1.0           1.0           1.0           2.0           2.0
3.0           4.0           5.0           23001                178000
 
                MuCheck 2.864       2.024       0.006693 0.3463
0.5092     0.7644     1.373       2.401       3.863       5.564
6.788       8.014       23001
                MuEqual   3.201       2.089       0.006871 0.4908
0.6885     0.984       1.668       2.764       4.254       5.985
7.217       8.391       23001
                MuRound 2.858       2.036       0.007194 0.323
0.4821     0.7339     1.357       2.4           3.866       5.583
6.818       7.987       23001      
                MuTrunc  3.353       2.151       0.006642 0.5226
0.7343     1.048       1.769       2.913       4.461       6.231
7.489       8.69         23001      
 
                ChF1        0.4884     0.4999     0.001504 
                ChF2        0.2938     0.4555     0.001123 
                ChF3        0.133       0.3396     8.901E-4  
                
                RoF1        0.4888     0.4999     0.001767 
                RoF2        0.2952     0.4561     0.001329 
                RoF3        0.133       0.3396     0.001035 
                
                TrF1         0.4898     0.4999     0.001693 
                TrF2         0.2959     0.4564     0.001371 
       TrF3   0.1319 0.3383 9.848E-4      
 
################# #######################
 
-----Original Message-----
From: Braunholtz, David A. 
Sent: 19 December 2007 17:57
To: [log in to unmask]
Subject: RE: non integer poisson variates ?
 
Following earlier Q re this, it was suggested I try Openbugs - see
results below!   I think I'll stick to Winbugs for the moment...(for
this at least)
 
It was also suggested I try JAGS - & and some output sent looked
promising, but I haven't yet worked out how to get JAGS scripts to
run... (in Windows) if anyone can give a hint... 
 
David 
 
################# #######################
Even Simpler eg of problem-with-poisson code
 
In WinBUGS 1.4   produces non-integer D and Db, contrary to expectations
(low auto-correlations) but fairly close to correct
 
In OpenBUGS 3.03 produces integer D & Db (but distribution is just
slightly wrong!!) ( & huge auto-correlations)
 
{
MuProblem~dunif(0,100)
MuCheck~dunif(0,100)
 
Problem~dpois(MuProblem)        
Check~dpois(MuCheck)             
 
Prob2 <- Problem
 
ObsP~dbin(0.7,Prob2) 
ObsCheck~dbin(0.7,Check)
 
}
 
Data         list( ObsCheck=1 ,  ObsP=1  )
 
Inits          list( MuProblem=2 ,  MuCheck=2 ,  Problem=3 , Check=3  ) 
 
Results:
 
OpenBugs 3.03
                  mean  sd    MC_error    val2.5pc    median   val97.5pc
      Check       1.863 1.106 0.007267    1.0         2.0         5.0   
      MuCheck     2.865 2.022 0.01484     0.3502      2.412       8.004
      MuProblem   17.74 12.0  0.1325      2.38        15.11       47.66 
      Prob2       16.74 11.26 0.1284      2.0         14.0        45.0
      Problem     16.74 11.26 0.1284      2.0         14.0        45.0

      
WinBUGS 1.4
       node       mean sd   MC error   2.5%        median      97.5% 
      Check       1.855 1.111 0.005552    1.0         2.0         5.0   
      MuCheck     2.851 2.032 0.01117     0.3545      2.392       7.968 
      MuProblem   3.202 2.099 0.01078     0.4907      2.761       8.473
      Prob2       2.202 1.089 0.008205    1.038       1.894       5.055 
      Problem     2.202 1.083 0.005855    1.039       1.903       4.998 
      
################# #######################
 
-----Original Message-----
From: Braunholtz, David A. 
Sent: 17 December 2007 22:26
To: [log in to unmask]
Subject: non integer poisson variates ?
 
Dear Bugsers,
 
I have noticed that code like the below results in non integer D (& Db).
Is this is intentional ?  Is there a way of forcing the poisson to
produce integral D ?  It seems unlikely, but is the distribution for MU
correct despite this ?  
 
Incidentally, while looking into this, I noticed that i was able (in the
simplest possible program) to use the same poisson N for the order of
two binomials - without producing the error message mentioned in 'tips &
troubleshooting
 / restrictions ... / e) ?
 
Thanks for any help ...
 
[log in to unmask]
Immpact Project
University of Aberdeen 
 

-------------------------------------------------------------------
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