I'm trying to get started with WinBugs and am getting results that I don't
understand. I'd appreciate any help you can give.
I'm using the Line example (I've appended it to the end of the email) that
comes with WinBugs to calculate a linear regression, but rather than using
the provided data I'm using a set of my own:
list(Y = c(10323.2, 11305.7, 9311.7, 5742.8, 10423.8, 3861.8, 13191.2,
4917.3, 5437.8, 9404.4, 6458.4, 4029.6, 2076, 2626.49, 813, 6841.7,
6235.45, 5214.9, 14069, 12145.84, 4700.69), x = c(1, 2, 3, 4, 5, 6, 7, 8,
9, 10 ,11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21), xbar=0, N=21)
Using Excel, I know the best-fit line to be y=-120.8x + 8430.3.
The inits I'm using in Winbugs are:
list(alpha = 8400, beta = -120, tau = 1)
I'm *expecting* to get similar results in WinBugs and Excel. However,
after 10000 interations, WinBugs insists on alpha=8114 and beta=-98.7.
This seems surprisingly far off. Am I doing something wrong here or do I
not understand the statistics I'm using?? Thank you for the advice you can
give.
Malin Pinsky
Williams College
[log in to unmask]
----------------------
Line Example
model
{
for( i in 1 : N ) {
Y[i] ~ dnorm(mu[i],tau)
mu[i] <- alpha + beta * (x[i] - xbar)
}
tau ~ dgamma(0.001,0.001) sigma <- 1 / sqrt(tau)
alpha ~ dnorm(8000,1.0E-6)
beta ~ dnorm(0.0,1.0E-6)
}
-------------------------------------------------------------------
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
|