> I have not gone through all your code yet, but the main difference between
> how you would code a BUGS model and a PyMC model relevent to your model is
> that in PyMC is that you should vectorize your model. Instead of looping
> through your variables, you should create arrays of variables and give those
> as arguments to other parts of your model.
> For example, instead of your second loop, you should do something like:
> T = pymc.Categorical('T', p=p1,p2)
> mu = pymc.Deterministic(eval=lambda t=T,lambda_0=lambdas[0],
> lambda_1=lambdas[1]: t < 0.5 & lambda_0 | lambda_1,
> name='mu')
> Y = pymc.Binomial('Y', n=mu, p=tau, value=y_data, observed=True)
> (note that numpy arrays sadly do not work with the 'and' and 'or'
> operators. You must use & and | or use the functions.
> PyMC *should* be able to deal with how you have written you model, but it
> is not how PyMC is meant to be used so it will be harder to debug your
> model. PyMC should also normally be able to deal with natural expressions of
> your variables to create deterministics, but I am not certain whether this
> works with the & and | operators. For example, you might try,
> mu = T < .5 & (lambdas[0] | lambdas[1])
> However, I am not 100% certain that will work (some of the operators might
> not be implemented).
> I also notice you have the expression "tau**(-1/2)" in your program.
> Unfortunately Python does integer division for 1/2 so this will evaluate as
> -1 (this will be fixed soon), so use tau**(-.5) or just sigma = tau
> **-.5.
> I am not certain what your specific error is due to.
> John
> On Sun, Jun 20, 2010 at 3:27 PM, Saeed Siam <saeed.s...@gmail.com> wrote:
>> Hi,
>> I am new to PyMC. For starting, I was trying to convert WinBUGS <a
>> href="http://users.aims.ac.za/~mackay/BUGS/Examples/Eyes.html<http://users.aims.ac.za/%7Emackay/BUGS/Examples/Eyes.html>">
>> Eyes
>> example </a> to PyMC.
>> I have assumed that Categorical() in the PyMC is equivalent the
>> WinBUGS' dcat(), So for the following WinBUGS model,
>> model
>> {
>> for( i in 1 : N ) {
>> y[i] ~ dnorm(mu[i], tau)
>> mu[i] <- lambda[T[i]]
>> T[i] ~ dcat(P[])
>> }
>> P[1:2] ~ ddirch(alpha[])
>> theta ~ dnorm(0.0, 1.0E-6)I(0.0, )
>> lambda[2] <- lambda[1] + theta
>> lambda[1] ~ dnorm(0.0, 1.0E-6)
>> tau ~ dgamma(0.001, 0.001) sigma <- 1 / sqrt(tau)
>> }
>> I have done similar to <a href="http://pastebin.com/GXwLs5bC">this </
>> a>. But it raises pymc.Node.ZeroProbability exception with the
>> message "Stochastic T_1's value is outside its support,
>> or it forbids its parents' current values."
>> I would really appreciate if you can point out what I am doing wrong.
>> regards,
>> Saeed
>> --
>> You received this message because you are subscribed to the Google Groups
>> "PyMC" group.
>> To post to this group, send email to pymc@googlegroups.com.
>> To unsubscribe from this group, send email to
>> pymc+unsubscribe@googlegroups.com <pymc%2Bunsubscribe@googlegroups.com>.
>> For more options, visit this group at
>> http://groups.google.com/group/pymc?hl=en.