[R] R to winbugs interface

135 views
Skip to first unread message

PRAGYA SUR

unread,
Jul 9, 2012, 1:20:46 AM7/9/12
to r-h...@r-project.org
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]]

______________________________________________
R-h...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

S Ellison

unread,
Jul 9, 2012, 7:04:09 AM7/9/12
to PRAGYA SUR, r-h...@r-project.org


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

This tells you that you do not have operating system permission to create a file in the program files area referred to.

> 2: In file(con, "wb") :
> cannot open file 'c:/Program
> Files/WinBUGS14//System/Rsrc/Registry.odc':
> Permission denied

.. and this tells you you don't have permission to open a file for writing (mode 'w' in the same location

Conclusion; you're trying to write to an area you don;t have permission to write to.

Either change the permissions for that area (insecure) or use a different file location for temporary files.

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}

PRAGYA SUR

unread,
Jul 9, 2012, 12:19:43 PM7/9/12
to r-h...@r-project.org
I ran the same program in a different computer where it had run proper a
week ago. This time around in the log file in WinBUGS the program stopped
at a line which said :
save(C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/RtmpU3u46p/log.odc)
save(C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/RtmpU3u46p/log.txt)
and did not proceed any further.
Can anyone tell me what migh tbe the possible error here?

On Mon, Jul 9, 2012 at 7:04 AM, S Ellison <S.El...@lgcgroup.com> wrote:

>
>
> > -----Original 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'
>
> This tells you that you do not have operating system permission to create
> a file in the program files area referred to.
>
> > 2: In file(con, "wb") :
> > cannot open file 'c:/Program
> > Files/WinBUGS14//System/Rsrc/Registry.odc':
> > Permission denied
>
> .. and this tells you you don't have permission to open a file for writing
> (mode 'w' in the same location
>
> Conclusion; you're trying to write to an area you don;t have permission to
> write to.
>
> Either change the permissions for that area (insecure) or use a different
> file location for temporary files.
>
> *******************************************************************
> This email and any attachments are confidential. Any u...{{dropped:11}}

Uwe Ligges

unread,
Jul 9, 2012, 1:15:26 PM7/9/12
to PRAGYA SUR, r-h...@r-project.org


On 09.07.2012 18:19, PRAGYA SUR wrote:
> I ran the same program in a different computer where it had run proper a
> week ago. This time around in the log file in WinBUGS the program stopped
> at a line which said :
> save(C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/RtmpU3u46p/log.odc)
> save(C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/RtmpU3u46p/log.txt)
> and did not proceed any further.
> Can anyone tell me what migh tbe the possible error here?

Although unstated, I guess it was finished and did not close because you
used bugs(....., debug=TRUE)?

Uwe Ligges

PRAGYA SUR

unread,
Jul 9, 2012, 1:27:50 PM7/9/12
to Uwe Ligges, r-h...@r-project.org
Yes that was the problem. Thank you very much. Can anyone tell me the
meaning of
The following object(s) are masked _by_ '.GlobalEnv':

beta
i was shown this notification after the results were printed.

On Mon, Jul 9, 2012 at 1:15 PM, Uwe Ligges
<lig...@statistik.tu-dortmund.de>wrote:

>
>
> On 09.07.2012 18:19, PRAGYA SUR wrote:
>
>> I ran the same program in a different computer where it had run proper a
>> week ago. This time around in the log file in WinBUGS the program stopped
>> at a line which said :
>> save(C:/DOCUME~1/ADMINI~1/**LOCALS~1/Temp/RtmpU3u46p/log.**odc)
>> save(C:/DOCUME~1/ADMINI~1/**LOCALS~1/Temp/RtmpU3u46p/log.**txt)
>> and did not proceed any further.
>> Can anyone tell me what migh tbe the possible error here?
>>
>
> Although unstated, I guess it was finished and did not close because you
> used bugs(....., debug=TRUE)?
>
> Uwe Ligges
>
>
>> On Mon, Jul 9, 2012 at 7:04 AM, S Ellison <S.El...@lgcgroup.com> wrote:
>>
>>
>>>
>>> -----Original 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'
>>>>
>>>
>>> This tells you that you do not have operating system permission to create
>>> a file in the program files area referred to.
>>>
>>> 2: In file(con, "wb") :
>>>> cannot open file 'c:/Program
>>>> Files/WinBUGS14//System/Rsrc/**Registry.odc':
>>>> Permission denied
>>>>
>>>
>>> .. and this tells you you don't have permission to open a file for
>>> writing
>>> (mode 'w' in the same location
>>>
>>> Conclusion; you're trying to write to an area you don;t have permission
>>> to
>>> write to.
>>>
>>> Either change the permissions for that area (insecure) or use a different
>>> file location for temporary files.
>>>
>>> ***********************************************************************
>>> This email and any attachments are confidential. Any u...{{dropped:11}}
>>>
>>
>> ______________________________**________________
>> R-h...@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>

[[alternative HTML version deleted]]

Uwe Ligges

unread,
Jul 10, 2012, 1:40:51 PM7/10/12
to PRAGYA SUR, r-h...@r-project.org


On 09.07.2012 19:27, PRAGYA SUR wrote:
> Yes that was the problem. Thank you very much. Can anyone tell me the
> meaning of
> The following object(s) are masked _by_ '.GlobalEnv':
>
> beta


It means you have two instances of "beta", one in your workspace
('.GlobalEnv') and one that is probably in some data.frame that was
attached to the search path.

Best,
Uwe Ligges


> i was shown this notification after the results were printed.
>
> On Mon, Jul 9, 2012 at 1:15 PM, Uwe Ligges
> <lig...@statistik.tu-dortmund.de
> <mailto:lig...@statistik.tu-dortmund.de>> wrote:
>
>
>
> On 09.07.2012 18:19, PRAGYA SUR wrote:
>
> I ran the same program in a different computer where it had run
> proper a
> week ago. This time around in the log file in WinBUGS the
> program stopped
> at a line which said :
> save(C:/DOCUME~1/ADMINI~1/__LOCALS~1/Temp/RtmpU3u46p/log.__odc)
> save(C:/DOCUME~1/ADMINI~1/__LOCALS~1/Temp/RtmpU3u46p/log.__txt)
> and did not proceed any further.
> Can anyone tell me what migh tbe the possible error here?
>
>
> Although unstated, I guess it was finished and did not close because
> you used bugs(....., debug=TRUE)?
>
> Uwe Ligges
>
>
> On Mon, Jul 9, 2012 at 7:04 AM, S Ellison
> <S.El...@lgcgroup.com <mailto:S.El...@lgcgroup.com>> wrote:
>
>
>
> -----Original 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'
>
>
> This tells you that you do not have operating system
> permission to create
> a file in the program files area referred to.
>
> 2: In file(con, "wb") :
> cannot open file 'c:/Program
> Files/WinBUGS14//System/Rsrc/__Registry.odc':
> Permission denied
>
>
> .. and this tells you you don't have permission to open a
> file for writing
> (mode 'w' in the same location
>
> Conclusion; you're trying to write to an area you don;t have
> permission to
> write to.
>
> Either change the permissions for that area (insecure) or
> use a different
> file location for temporary files.
>
> ******************************__******************************__*******
> This email and any attachments are confidential. Any
> u...{{dropped:11}}
>
>
> ________________________________________________
> R-h...@r-project.org <mailto:R-h...@r-project.org> mailing list
> https://stat.ethz.ch/mailman/__listinfo/r-help
> <https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide
> http://www.R-project.org/__posting-guide.html
> <http://www.R-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>
>
>

Reply all
Reply to author
Forward
0 new messages