R2WinBUGS: Nonlinear regression model
Revisiting Example
7.3 (pages 251-2) on non-linear regression models
Data presented by Ratkowski (1983) on the temporal evolution of the dry weight of onion bulbs.
One of the nonlinear models considered by Gelfand, Dey and Chang (1992) is
y ~ N(a-bgx, t -2)
with p(a,b,g,t2) = p(a) p(b) p(g) p(t2) and
a ~
N(0.0,1000000)
b ~
N(0.0,1000000)
g ~ U(0,1)
t2 ~ G(0.01,0.01)
WINBUGS CODE FOR THE NONLINEAR MODEL
# This
model is stored in file “nonlinearmodel.bug”
model{
for( i in 1 : N ) {
y[i] ~
dnorm(mu[i], tau2)
mu[i] <- alpha
- beta * pow(gamma,x[i])
}
alpha ~ dnorm(0.0, 1.0E-6)
beta ~ dnorm(0.0, 1.0E-6)
gamma ~ dunif(0.0, 1.0)
tau2
~ dgamma(0.01, 0.01)
}
Evoking WinBUGS from R
x =
c(1.0,1.5,1.5,1.5,2.5,4.0,5.0,5.0,7.0,8.0,8.5,9.0,9.5,9.5,10.0,
12.0,12.0,13.0,13.0,14.5,15.5,15.5,16.5,17.0,22.5,29.0,31.5)
y =
c(1.80,1.85,1.87,1.77,2.02,2.27,2.15,2.26,2.47,2.19,2.26,2.40,2.39,2.41,
2.50,2.32,2.32,2.43,2.47,2.56,2.65,2.47,2.64,2.56,2.70,2.72,2.57)
N = length(x)
data = list("x","y","N")
inits = function(){
list(alpha=1,beta=1,tau2=1,gamma=0.9)
}
nonlinear.sim =
bugs(data,inits,
model.file="nonlinearmodel.bug",
parameters=c("alpha","beta","tau2","gamma"),
n.chains=1,n.iter=10000,n.burnin=5000,n.thin=1,
bugs.directory="c:/Program
Files/WinBUGS14/",
codaPkg=FALSE)