{"action":"created","issue":{"url":"https://api.github.com/repos/pymc-devs/pymc3/issues/1597","repository_url":"https://api.github.com/repos/pymc-devs/pymc3","labels_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/1597/labels{/name}","comments_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/1597/comments","events_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/1597/events","html_url":"https://github.com/pymc-devs/pymc3/issues/1597","id":195225711,"number":1597,"title":"Scenarios in multivariate timeseries","user":{"login":"ferrine","id":11705326,"avatar_url":"https://avatars.githubusercontent.com/u/11705326?v=3","gravatar_id":"","url":"https://api.github.com/users/ferrine","html_url":"https://github.com/ferrine","followers_url":"https://api.github.com/users/ferrine/followers","following_url":"https://api.github.com/users/ferrine/following{/other_user}","gists_url":"https://api.github.com/users/ferrine/gists{/gist_id}","starred_url":"https://api.github.com/users/ferrine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ferrine/subscriptions","organizations_url":"https://api.github.com/users/ferrine/orgs","repos_url":"https://api.github.com/users/ferrine/repos","events_url":"https://api.github.com/users/ferrine/events{/privacy}","received_events_url":"https://api.github.com/users/ferrine/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2016-12-13T11:16:11Z","updated_at":"2016-12-13T22:14:06Z","closed_at":"2016-12-13T11:51:58Z","body":"A am doing multivariate time series analysis and got a problem with modelling scenarios.\r\nThe problem is as follows:\r\n1) suppose you have a multivariate time series with shape (T, p)\r\n2) then you want to know the distribution in periods [T+1:T+10] conditioned on scenario\r\n3) scenario can be described with one observed variable (or distribution over it) in time series while others are unobserved\r\nso the dataset looks like:\r\n```python\r\n[[1,2,3],\r\n [4,5,6],\r\n [nan,7,nan]\r\n]\r\n```\r\nDistribution I use for modelling dynamics\r\n```python\r\nclass MvGaussianRandomWalk(Continuous):\r\n    def __init__(self, mu=0., cov=None, tau=None, init=Flat.dist(),\r\n                 *args, **kwargs):\r\n        super(MvGaussianRandomWalk, self).__init__(*args, **kwargs)\r\n        tau, cov = get_tau_cov(mu, tau=tau, cov=cov)\r\n        self.tau = tau\r\n        self.cov = cov\r\n        self.mu = mu\r\n        self.init = init\r\n        self.mean = 0.\r\n\r\n    def logp(self, x):\r\n        tau = self.tau\r\n        mu = self.mu\r\n        init = self.init\r\n\r\n        x_im1 = x[:-1]\r\n        x_i = x[1:]\r\n\r\n        innov_like = pm.MvNormal.dist(mu=x_im1 + mu, tau=tau).logp(x_i)\r\n        return init.logp(x[0]) + tt.sum(innov_like)\r\n```\r\nModel\r\n```python\r\ndef covm(sd, corr):\r\n    n_var = sd.tag.test_value.shape[0]\r\n    n_elem = int(n_var * (n_var - 1) / 2)\r\n    tri_index = np.zeros([n_var, n_var], dtype=int)\r\n    tri_index[np.triu_indices(n_var, k=1)] = np.arange(n_elem)\r\n    tri_index[np.triu_indices(n_var, k=1)[::-1]] = np.arange(n_elem)\r\n    corrm = corr[tri_index]\r\n    corrm = tt.fill_diagonal(corrm, 1)\r\n    return tt.diag(sd).dot(corrm).dot(tt.diag(sd))\r\np = data.shape[1]\r\nwith pm.Model() as model:\r\n    corr = LKJCorr('corr', n=3, p=p)\r\n    sd = Exponential('sd', lam=1, shape=(p,))\r\n    cov = Deterministic('cov', covm(sd, corr))\r\n    walk = MvGaussianRandomWalk('walk', cov=cov, observed=data_with_unobserved)\r\n```\r\nWhen running metropolis(NUTS fails on observed even!!) on observed only, I get tight distribution for innovation covariance, sampling with observed fails, I get the following error when plotting trace:\r\n```python\r\nValueError: v cannot be empty\r\n```\r\nIt seems that it sampled constant or something like this\r\n\r\nI can't figure out what I'm doing wrong but suppose that my case is supported by pymc3\r\n[data_with_unobserved.csv.zip](https://github.com/pymc-devs/pymc3/files/648704/sample_data.csv.zip)"},"comment":{"url":"https://api.github.com/repos/pymc-devs/pymc3/issues/comments/266878935","html_url":"https://github.com/pymc-devs/pymc3/issues/1597#issuecomment-266878935","issue_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/1597","id":266878935,"user":{"login":"ferrine","id":11705326,"avatar_url":"https://avatars.githubusercontent.com/u/11705326?v=3","gravatar_id":"","url":"https://api.github.com/users/ferrine","html_url":"https://github.com/ferrine","followers_url":"https://api.github.com/users/ferrine/followers","following_url":"https://api.github.com/users/ferrine/following{/other_user}","gists_url":"https://api.github.com/users/ferrine/gists{/gist_id}","starred_url":"https://api.github.com/users/ferrine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ferrine/subscriptions","organizations_url":"https://api.github.com/users/ferrine/orgs","repos_url":"https://api.github.com/users/ferrine/repos","events_url":"https://api.github.com/users/ferrine/events{/privacy}","received_events_url":"https://api.github.com/users/ferrine/received_events","type":"User","site_admin":false},"created_at":"2016-12-13T22:14:06Z","updated_at":"2016-12-13T22:14:06Z","body":"Thanks, didn't notice it"}}
{"actor":{"display_login":"ferrine"}}