Edit 2: Feel free to correct me if I am wrong, but I feel I have misunderstood “sample”. After Sample I should have a model with fit parameters, but I do not necessarily have any predictive simulations. For that, I need to do a second sample of a different type (e.x. an approx fit sample or a posterior predictive sample). So I am under the impression that the reason I didn’t have the output I expected is because I didn’t do the operation I wanted. Cheers.
Edit 3: I have tested and confirmed my suspicions. The behaviour I am looking for is pm.sample_ppc. I was using the wrong function. I’m doing a final update here in case anyone as green as I am stumbles across this via google. I am still having a couple issues I don’t understand, but they do not belong in this question. I will move them to another.
Hi,
I am having trouble understanding the use of ObservedRV. I am setting up a model on data that I expect to follow a StudentT distribution, so I make the following very basic model
import pymc3 as pm
model = pm.Model()
with model:
sd=pm.HalfNormal('sigma', 0.1)
nu=pm.HalfNormal('nu',1)
mu=pm.Normal('mu',0.0)
r=pm.StudentT('output', mu=mu, nu=nu, sd=sd, observed=train)
step=pm.NUTS(vars=[r,mu,nu,sigma])
trace=pm.sample(draws=60, step=step, tune=500, chains=20, cores=10)
But in the trace, I only have nu, mu, and sigma. As my model is supposed to describe r, I would expect there to be 60 values of r in the result. This is not the case. Instead, I have only the fit parameters in the trace. What am I misunderstanding? I feel like I am missing the most basic result of a monte carlo simulation.
Edit: To add a bit more information:
I would expect trace[‘output’] to give me points, but it doesn’t exist.
trace.varnames gives only
[‘sigma_log__’, ‘nu_log__’, ‘mu’, ‘sigma’, ‘nu’]
which are all expected, but still do not include any sampled values of the function I initially tried to fit to my data.