{"action":"created","issue":{"url":"https://api.github.com/repos/stan-dev/pystan/issues/268","repository_url":"https://api.github.com/repos/stan-dev/pystan","labels_url":"https://api.github.com/repos/stan-dev/pystan/issues/268/labels{/name}","comments_url":"https://api.github.com/repos/stan-dev/pystan/issues/268/comments","events_url":"https://api.github.com/repos/stan-dev/pystan/issues/268/events","html_url":"https://github.com/stan-dev/pystan/issues/268","id":188011001,"number":268,"title":"Plot of multidimensional node fails with ValueError","user":{"login":"fonnesbeck","id":81476,"avatar_url":"https://avatars.githubusercontent.com/u/81476?v=3","gravatar_id":"","url":"https://api.github.com/users/fonnesbeck","html_url":"https://github.com/fonnesbeck","followers_url":"https://api.github.com/users/fonnesbeck/followers","following_url":"https://api.github.com/users/fonnesbeck/following{/other_user}","gists_url":"https://api.github.com/users/fonnesbeck/gists{/gist_id}","starred_url":"https://api.github.com/users/fonnesbeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fonnesbeck/subscriptions","organizations_url":"https://api.github.com/users/fonnesbeck/orgs","repos_url":"https://api.github.com/users/fonnesbeck/repos","events_url":"https://api.github.com/users/fonnesbeck/events{/privacy}","received_events_url":"https://api.github.com/users/fonnesbeck/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-08T14:49:15Z","updated_at":"2016-11-11T22:33:34Z","closed_at":null,"body":"While `plot` seems to work for simple vector-valued nodes, multidimensional nodes currently fail. For example, for a correlation matrix `corr_matrix[2] Omega_b;` that is modeled with a `lkj_corr` distribution, I get this failure:\r\n\r\n```\r\n>>> fit.plot(pars=['Omega_b'])\r\n\r\n---------------------------------------------------------------------------\r\nValueError                                Traceback (most recent call last)\r\n<ipython-input-34-8e77554e34ed> in <module>()\r\n----> 1 fit.plot(pars=['Omega_b'])\r\n\r\nstanfit4anon_model_456ec81631c7e21b1d5f3580dbc6353b_6997922924549208434.pyx in stanfit4anon_model_456ec81631c7e21b1d5f3580dbc6353b_6997922924549208434.StanFit4Model.plot (/var/folders/z_/kgsm76k94s7_jhnkfydfnd380000gn/T/tmp0k60d8b1/stanfit4anon_model_456ec81631c7e21b1d5f3580dbc6353b_6997922924549208434.cpp:10206)()\r\n\r\n/Users/fonnescj/anaconda3/envs/dev/lib/python3.5/site-packages/pystan/plots.py in traceplot(fit, pars, **kwargs)\r\n     17         logger.critical(\"matplotlib required for plotting.\")\r\n     18         raise\r\n---> 19     return plots.traceplot(fit.extract(), pars, **kwargs)\r\n\r\n/Users/fonnescj/anaconda3/envs/dev/lib/python3.5/site-packages/pystan/external/pymc/plots.py in traceplot(trace, vars)\r\n     39             ax[i, 0].hist(d, bins=sqrt(d.size))\r\n     40         else:\r\n---> 41             kdeplot_op(ax[i, 0], d)\r\n     42         ax[i, 0].set_title(str(v))\r\n     43         ax[i, 1].plot(d, alpha=.35)\r\n\r\n/Users/fonnescj/anaconda3/envs/dev/lib/python3.5/site-packages/pystan/external/pymc/plots.py in kdeplot_op(ax, data)\r\n     58         x = np.linspace(0, 1, 100) * (u - l) + l\r\n     59 \r\n---> 60         ax.plot(x, density(x))\r\n     61 \r\n     62 \r\n\r\n/Users/fonnescj/anaconda3/envs/dev/lib/python3.5/site-packages/scipy/stats/kde.py in evaluate(self, points)\r\n    202                 msg = \"points have dimension %s, dataset has dimension %s\" % (d,\r\n    203                     self.d)\r\n--> 204                 raise ValueError(msg)\r\n    205 \r\n    206         result = zeros((m,), dtype=float)\r\n\r\nValueError: points have dimension 1, dataset has dimension 4000\r\n```\r\n\r\nThe dimensionality of this node is:\r\n\r\n```\r\nfit.extract(pars=['Omega_b']).shape\r\n\r\n(4000, 2, 2)\r\n```\r\n\r\nRunning PyStan built from master on Python 3.5.2 (anaconda) and macOS 10.12."},"comment":{"url":"https://api.github.com/repos/stan-dev/pystan/issues/comments/260071236","html_url":"https://github.com/stan-dev/pystan/issues/268#issuecomment-260071236","issue_url":"https://api.github.com/repos/stan-dev/pystan/issues/268","id":260071236,"user":{"login":"ariddell","id":19950,"avatar_url":"https://avatars.githubusercontent.com/u/19950?v=3","gravatar_id":"","url":"https://api.github.com/users/ariddell","html_url":"https://github.com/ariddell","followers_url":"https://api.github.com/users/ariddell/followers","following_url":"https://api.github.com/users/ariddell/following{/other_user}","gists_url":"https://api.github.com/users/ariddell/gists{/gist_id}","starred_url":"https://api.github.com/users/ariddell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ariddell/subscriptions","organizations_url":"https://api.github.com/users/ariddell/orgs","repos_url":"https://api.github.com/users/ariddell/repos","events_url":"https://api.github.com/users/ariddell/events{/privacy}","received_events_url":"https://api.github.com/users/ariddell/received_events","type":"User","site_admin":false},"created_at":"2016-11-11T22:33:33Z","updated_at":"2016-11-11T22:33:33Z","body":"Thanks. We should do something about this. Does RStan handle this?\r\n\r\nThere was/is an attempt to build a more robust plotting library for everyone who has data like this, https://github.com/mcmcplotlib/mcmcplotlib but there hasn't been much progress. After PyStan 3 gets done (which will fix all the pickling problems for good) I may have some time to work on plots. Any help would be appreciated."}}
{"actor":{"display_login":"ariddell"}}