Yes Virginia, there is a Santa Clause.
The zeros (or ones) trick can be used at any location in a hierarchical
model, so long as you actually DRAW a value for the variable defined by
the pdf. This is accomplished by adding a line
y[i]~dflat[]
This can be added to any variable definition. (if it is instantiated, it
will neither hurt nor help). This then allows the zeros (or ones) trick
to be extended to
-missing data nodes
-parent nodes such as random effects
-any other node in your model
Finn Krogstad
University of Washington
College of Forest Resources
Seattle, WA 98195
-----Original Message-----
From: (The BUGS software mailing list) [mailto:[log in to unmask]] On
Behalf Of Simon Frost
Sent: Wednesday, January 30, 2002 2:55 AM
To: [log in to unmask]
Subject: Arbitrary distribution of random effects?
Dear BUGS group,
I'm interested in fitting a random effects model with an arbitrary
distribution for the random effects using e.g. Serguei Smirnov's
'zeroes' trick.
I can fit a custom distribution to some data, y[i], easily. For
example, a skew-normal distribution can be fitted using the following
code
for(i in 1:N){
zeros[i] <- 0
zeros[i] ~ dexp(lambda[i])
z[i] <- (y[i]-mu)/sigma
lambda[i] <-
exp(-log(2.506628274631*sigma)-0.5*pow(z[i],2)+log(phi(alpha*z[i])))
# Density function of a skew normal distribution with direct
parameters mu=location, sigma=scale, alpha=shape
# See http://azzalini.stat.unipd.it/SN/ for details
}
[I include a dataset at the end of the email.]
with whatever priors for mu, sigma, and alpha one fancies (although it
may be preferable to used the transformed 'centred' parameters). I can
use dflat priors and recover estimates that are the same as ML estimated
using SAS PROC NLMIXED and the general distribution, omitting random
effects.
Now lets treat y as a random effect rather than the data. Now we have
two variables, y2[i], and index[i] (which denotes the cluster), with M
datapoints and N indices. I'd like to fit a model where the data, y2[i]
~ dnorm(y[index[i]],tau).
However, when I add in the following to the above program
for(i in 1:M){
y2[i] ~ dnorm(y[index[i]],tau)
}
I get an error message saying that variable not defined or no data for y
(the random effect). My question is; is it possible to mix arbitrary
distributions using the 'zeroes' or the 'ones' trick with built in
distributions, or do I have to include the full density function in
lambda? Any suggestions on how I do this?
Best wishes
Simon
*****
# Data produced using the sn library in R
# > library(sn)
# Library `sn', version 0.22.2; Copyright (C) 1998-2001 A.Azzalini #
type `help(SN,package=sn)' for summary information # >
rsn(n=100,location=0,scale=2,shape=-2)
y[]
-0.2508620
-1.912147
-3.807066
-1.764390
0.7919929
-2.051529
-3.357441
-2.443514
0.2627832
0.6892151
-0.1790350
0.9173185
-1.475269
-2.269911
-2.660823
-0.8671588
-1.485623
-1.741673
-2.054933
-1.775245
0.7274718
-0.3106162
-2.217274
-2.290044
-1.993706
-0.6117704
-2.342965
-1.394308
-0.6113908
-2.598696
-3.035334
-0.1404732
-1.285618
-4.974342
0.1187851
-1.398792
-3.255255
-1.520970
-0.2656756
-0.08196213
0.5788954
-2.682151
-0.36258
-4.419496
-0.2968835
-0.8236729
-1.160044
-1.286190
-2.212385
-1.653726
-1.895113
-2.865276
-0.1030049
-2.773344
-0.9258938
0.1402832
-3.486838
-1.534142
-1.954224
-0.7199487
-0.8255952
-2.128894
-0.9851322
-3.256231
-1.684541
0.01352935
-2.928381
-1.482657
-3.46294
-0.9257169
-2.017813
-3.083161
-1.534017
-2.19764
0.5600642
-1.968406
-0.4291309
-1.559001
-1.899889
-1.80445
-3.454116
-0.2065735
0.1309555
-0.6007833
-1.433647
-1.118903
-1.145059
0.5251544
-1.156224
-3.653544
-0.7364311
-4.57898
-1.855022
0.4552624
0.3104281
-0.6072877
-2.061703
-2.195438
-1.317463
-0.616981
Simon D.W. Frost, M.A., D.Phil.
Department of Pathology
University of California, San Diego
Antiviral Research Center
(Formerly: UCSD Treatment Center)
150 W. Washington St., Suite 100
San Diego, CA 92103
USA
Tel: +1 619 543 8080 x275
Fax: +1 619 298 0177
Email: [log in to unmask]
Work W3: http://www.avrctrials.org
Personal W3: http://www.simonfrost.com
-------------------------------------------------------------------
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
-------------------------------------------------------------------
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
|