Hello everyone,
I need some help regarding calling WinBUGS from R. I
have a model for WinBUGS and an R code which calls WinBUGS. On running the
code I am being shown the error message :
Error in file(con, "wb") : cannot open the connection
In addition: Warning messages:
1: In file.create(to[okay]) :
cannot create file 'c:/Program
Files/WinBUGS14//System/Rsrc/Registry_Rsave.odc', reason 'Permission
denied'
2: In file(con, "wb") :
cannot open file 'c:/Program
Files/WinBUGS14//System/Rsrc/Registry.odc':
Permission denied
In addition in WinBUGS a window crops up which is named black box. and says
trap #060 and then gives some details. I am not being able to understand
what all hese error messages mean. I am also giving the R code and the code
for the model here :
R code :
regpractwo=function(Ytilde,D,Xtilde,a,b,n,FEV,Age,Smoke)
{
Xtildeinv=solve(Xtilde)
beta0=c(t(Xtildeinv%*%Ytilde))
C0=Xtildeinv%*%D%*%t(Xtildeinv)
C0inv=solve(C0)
r=dim(Xtildeinv)[1]
FEVdataBUGS=list("n","r","beta0","C0inv","a","b","FEV","Age","Smoke")
#creates list of imputs for winbugs code
parameters=c("beta","tau","meanFEVs","meanFEVns","FEV20s","FEV20ns")
#parameters to be monitored by winbugs
inits=list(list(tau=1,beta=c(0,0,0,0),FEV20s=2,FEV20ns=2)) # giving initial
values
FEV.fit=bugs(FEVdataBUGS,inits,parameters,"FEVWBModel.txt",n.chains=1,n.iter=60000,n.thin=1,n.burnin=10000)
print(FEV.fit,digits=3)
attach.bugs(FEV.fit)
}
The model :
model
{
for (i in 1:n)
{
FEV[i]~dnorm(mu[i],tau)
mu[i]<-beta[1]+beta[2]*Age[i]+beta[3]*Smoke[i]+beta[4]*Age[i]*Smoke[i]
}
beta[1:r]~dmnorm(beta0[1:r],C0inv[1:r,1:r])
tau~dgamma(a,b)
for (i in 1:10)
{
meanFEVs[i] <- beta[1] + (beta[2]+beta[4])*(i+9) + beta[3]
meanFEVns[i] <- beta[1] + beta[2]*(i+9)
}
FEV20s ~ dnorm(mu20s,tau)
FEV20ns ~ dnorm(mu20ns,tau)
mu20s <- beta[1] + (beta[2]+beta[4])*20 + beta[3]
mu20ns <- beta[1] + beta[2]*20
}
Please help me with this problem.
[[alternative HTML version deleted]]