Good. In the meanwhile I have put together a rewrite of the example in
the jags documentation as a stylistic statement. Consider using using
Python variables and call R functions through their Python
representation: it makes the code easier to read for Python programmers
without an R background.
from rpy2.robjects.vectors import FloatVector, StrVector
from rpy2.robjects import r, globalenv
from rpy2.robjects.packages import importr
base = importr('base')
r2jags = importr('R2jags')
# An example model file is given in:
model_file = base.system_file("model", "schools.txt", package="R2jags")
# data
J = 8.0
y = FloatVector((28.4,7.9,-2.8,6.8,-0.6,0.6,18.0,12.2))
sd = FloatVector((14.9,10.2,16.3,11.0,9.4,11.4,10.4,17.6))
# using a separate environment might be cleaner and evaluate the call
# in that environment might be cleaner, but let's keep it simple
globalenv['J'] = J
globalenv['y'] = y
globalenv['sd'] = sd
jags_data = StrVector(("y","sd","J"))
jags_params = StrVector(("mu","sigma","theta"))
jags_inits = r('''function(){
list("mu"=rnorm(1),"sigma"=runif(1),"theta"=rnorm(J))
}''')
jagsfit = r2jags.jags(data = jags_data, inits = jags_inits,
parameters_to_save = jags_params,
n_iter = 5000,
model_file = model_file)
On 30/10/10 19:47, Burak B wrote:
> There was a problem with the county variable. It's fixed.
>
> Burak B<burakbayramli<at> gmail.com> writes:
>
>> Hi everyone, I am trying to convert a JAGS example from R into Python using
>> rpy2. The example code is here:
>>
>> http://dl.dropbox.com/u/1570604/radon-example.zip
>>
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps& games for the Nokia N8 for consumers in U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> rpy-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/rpy-list
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
rpy-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rpy-list