Pystan, changing maximum treedepth

For a current fit I need to adjust the maximum treedepth. I am using Pystan.
In the forum I found:

fit = sm.sampling(..., control=dict(max_treedepth=15))

This however yields me just another error “{‘json’: {‘control’: [‘Unknown field.’]}}”.
Thanks in advance.

Hi,

PyStan 3 follows similar names as CmdStan.

https://pystan.readthedocs.io/en/latest/reference.html#stan.model.Model.hmc_nuts_diag_e_adapt

Following should work.

posterior = stan.Model(data=data)
fit = posterior.sample(..., max_depth=11)

Read also upgrading guide in PyStan docs.

1 Like

Hi Ari,

Following on the same topic of using extra keywords in pystan 3.2

I’d like to get the output CSV file with samples, so that I can do some monitoring in realtime.

CmdStan specifies the use of " output file=XXX.csv". How can I specify this in pystan? I’ve tried different options without success.

Apologies if I’ve missed something obvious.

Thanks!
Jesus

There is no output csv file.

To do realtime things, you need to somehow edit pystan codebase so you have access to samples when they come in from httpstan.

Understood. Thanks for the prompt reply.

Cheers,
Jesus