{"action":"created","comment":{"url":"https://api.github.com/repos/statsmodels/statsmodels/pulls/comments/24351679","id":24351679,"diff_hunk":"@@ -0,0 +1,82 @@\n+\"\"\"\n+State Space Model\n+\n+Author: Chad Fulton\n+License: Simplified-BSD\n+\"\"\"\n+from __future__ import division, absolute_import, print_function\n+\n+import numpy as np\n+from .representation import Representation\n+from .kalman_filter import KalmanFilter\n+\n+import statsmodels.tsa.base.tsa_model as tsbase\n+\n+\n+class Model(KalmanFilter, Representation, tsbase.TimeSeriesModel):\n+    \"\"\"\n+    State space model\n+\n+    Parameters\n+    ----------\n+    endog : array_like\n+        The observed time-series process :math:`y`\n+    k_states : int\n+        The dimension of the unobserved state process.\n+    exog : array_like, optional\n+        Array of exogenous regressors, shaped nobs x k. Default is no\n+        exogenous regressors.\n+    dates : array-like of datetime, optional\n+        An array-like object of datetime objects. If a Pandas object is given\n+        for endog, it is assumed to have a DateIndex.\n+    freq : str, optional\n+        The frequency of the time-series. A Pandas offset or 'B', 'D', 'W',\n+        'M', 'A', or 'Q'. This is optional if dates are given.\n+\n+    Attributes\n+    ----------\n+    start_params : array\n+        Starting parameters for maximum likelihood estimation.\n+    params_names : list of str\n+        List of human readable parameter names (for parameters actually\n+        included in the model).\n+    model_names : list of str\n+        The plain text names of all possible model parameters.\n+    model_latex_names : list of str\n+        The latex names of all possible model parameters.\n+\n+    See Also\n+    --------\n+    statsmodels.tsa.statespace.KalmanFilter\n+    \"\"\"\n+    def __init__(self, endog, k_states, exog=None, dates=None, freq=None,\n+                 *args, **kwargs):\n+        # Initialize the model base\n+        tsbase.TimeSeriesModel.__init__(self, endog=endog, exog=exog,\n+                                        dates=dates, freq=freq, missing='none')\n+\n+        # Need to modify the endog variable\n+        endog = self.endog\n+\n+        # Base class may allow 1-dim data, whereas we need 2-dim\n+        if endog.ndim == 1:\n+            endog.shape = (endog.shape[0], 1)  # this will be C-contiguous\n+\n+        # Base classes data may be either C-ordered or F-ordered - we want it\n+        # to be C-ordered since it will also be in shape (nobs, k_endog), and\n+        # then we can just transpose it.\n+        if not endog.flags['C_CONTIGUOUS']:\n+            # TODO this breaks the reference link between the model endog","path":"statsmodels/tsa/statespace/model.py","position":69,"original_position":69,"commit_id":"3c634a6218514332f131971c3d9d0248d18caa1e","original_commit_id":"3c634a6218514332f131971c3d9d0248d18caa1e","user":{"login":"ChadFulton","id":280864,"avatar_url":"https://avatars.githubusercontent.com/u/280864?v=3","gravatar_id":"","url":"https://api.github.com/users/ChadFulton","html_url":"https://github.com/ChadFulton","followers_url":"https://api.github.com/users/ChadFulton/followers","following_url":"https://api.github.com/users/ChadFulton/following{/other_user}","gists_url":"https://api.github.com/users/ChadFulton/gists{/gist_id}","starred_url":"https://api.github.com/users/ChadFulton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChadFulton/subscriptions","organizations_url":"https://api.github.com/users/ChadFulton/orgs","repos_url":"https://api.github.com/users/ChadFulton/repos","events_url":"https://api.github.com/users/ChadFulton/events{/privacy}","received_events_url":"https://api.github.com/users/ChadFulton/received_events","type":"User","site_admin":false},"body":"Unless someone weighs in on this with another opinion, I'm going to leave it as-is, and keep the TODO note in there for future reference.","created_at":"2015-02-09T18:30:18Z","updated_at":"2015-02-09T18:30:18Z","html_url":"https://github.com/statsmodels/statsmodels/pull/1698#discussion_r24351679","pull_request_url":"https://api.github.com/repos/statsmodels/statsmodels/pulls/1698","_links":{"self":{"href":"https://api.github.com/repos/statsmodels/statsmodels/pulls/comments/24351679"},"html":{"href":"https://github.com/statsmodels/statsmodels/pull/1698#discussion_r24351679"},"pull_request":{"href":"https://api.github.com/repos/statsmodels/statsmodels/pulls/1698"}}},"pull_request":{"url":"https://api.github.com/repos/statsmodels/statsmodels/pulls/1698","id":16382284,"html_url":"https://github.com/statsmodels/statsmodels/pull/1698","diff_url":"https://github.com/statsmodels/statsmodels/pull/1698.diff","patch_url":"https://github.com/statsmodels/statsmodels/pull/1698.patch","issue_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/1698","number":1698,"state":"open","locked":false,"title":"Multivariate Kalman Filter","user":{"login":"ChadFulton","id":280864,"avatar_url":"https://avatars.githubusercontent.com/u/280864?v=3","gravatar_id":"","url":"https://api.github.com/users/ChadFulton","html_url":"https://github.com/ChadFulton","followers_url":"https://api.github.com/users/ChadFulton/followers","following_url":"https://api.github.com/users/ChadFulton/following{/other_user}","gists_url":"https://api.github.com/users/ChadFulton/gists{/gist_id}","starred_url":"https://api.github.com/users/ChadFulton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChadFulton/subscriptions","organizations_url":"https://api.github.com/users/ChadFulton/orgs","repos_url":"https://api.github.com/users/ChadFulton/repos","events_url":"https://api.github.com/users/ChadFulton/events{/privacy}","received_events_url":"https://api.github.com/users/ChadFulton/received_events","type":"User","site_admin":false},"body":"Here's a simple branch with the code added into statsmodels.tsa.statespace. A couple of thoughts\r\n\r\n- At least in the dev process, I thought it might be nicer to keep it in its own module, rather than putting it with the kalmanf. I don't know what makes the most sense in the long run.\r\n- I have unit tests that rely on the statespace model, but I'm rewriting them so the KF pull request can be done on its own without other dependencies, especially since the statespace model is likely to change.\r\n\r\n**Edit**: Original line comments.\r\n\r\n**L72**\r\n> Question: do we want to keep the single-precision version (and the complex single precision, below)? I don't really see a use case, and it appears from preliminary tests that the results tend to overflow. Maybe I'll post a unit test to demonstrate and we can go from there.\r\n\r\n**L332**\r\n> Question: there are a bunch of ways to initialize the KF, depending on the theory underlying the data. This one is only valid for stationary processes. Probably best to move out to the Python wrapper?\r\n\r\n**L444**\r\nQuestion: I think we'll want to add the ability to specify whether or not to check for convergence and alter the tolerance.\r\n\r\n**L414**\r\n> This inversion is using an LU decomposition, but I think in this case I can rely on f to be positive definite since it's the covariance matrix of the forecast error, in which case I could use the much faster Cholesky decomposition approach. This is something I'm looking into, but if you happen to know one way or the other, that would be great too.\r\n> \r\n> Related to this is the idea that you should \"never take inverses\", and I guess I need to look into replacing this with a linear solver routine if possible, in the updating stage below.","created_at":"2014-05-27T16:40:33Z","updated_at":"2015-02-09T18:30:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a83af39d6edb6672602d500b22f57a8ee56f3ca8","assignee":null,"milestone":{"url":"https://api.github.com/repos/statsmodels/statsmodels/milestones/7","labels_url":"https://api.github.com/repos/statsmodels/statsmodels/milestones/7/labels","id":756183,"number":7,"title":"0.7","description":"","creator":{"login":"josef-pkt","id":440735,"avatar_url":"https://avatars.githubusercontent.com/u/440735?v=3","gravatar_id":"","url":"https://api.github.com/users/josef-pkt","html_url":"https://github.com/josef-pkt","followers_url":"https://api.github.com/users/josef-pkt/followers","following_url":"https://api.github.com/users/josef-pkt/following{/other_user}","gists_url":"https://api.github.com/users/josef-pkt/gists{/gist_id}","starred_url":"https://api.github.com/users/josef-pkt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josef-pkt/subscriptions","organizations_url":"https://api.github.com/users/josef-pkt/orgs","repos_url":"https://api.github.com/users/josef-pkt/repos","events_url":"https://api.github.com/users/josef-pkt/events{/privacy}","received_events_url":"https://api.github.com/users/josef-pkt/received_events","type":"User","site_admin":false},"open_issues":107,"closed_issues":57,"state":"open","created_at":"2014-08-16T23:51:52Z","updated_at":"2015-02-08T13:20:14Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/statsmodels/statsmodels/pulls/1698/commits","review_comments_url":"https://api.github.com/repos/statsmodels/statsmodels/pulls/1698/comments","review_comment_url":"https://api.github.com/repos/statsmodels/statsmodels/pulls/comments/{number}","comments_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/1698/comments","statuses_url":"https://api.github.com/repos/statsmodels/statsmodels/statuses/3c634a6218514332f131971c3d9d0248d18caa1e","head":{"label":"ChadFulton:kalman","ref":"kalman","sha":"3c634a6218514332f131971c3d9d0248d18caa1e","user":{"login":"ChadFulton","id":280864,"avatar_url":"https://avatars.githubusercontent.com/u/280864?v=3","gravatar_id":"","url":"https://api.github.com/users/ChadFulton","html_url":"https://github.com/ChadFulton","followers_url":"https://api.github.com/users/ChadFulton/followers","following_url":"https://api.github.com/users/ChadFulton/following{/other_user}","gists_url":"https://api.github.com/users/ChadFulton/gists{/gist_id}","starred_url":"https://api.github.com/users/ChadFulton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChadFulton/subscriptions","organizations_url":"https://api.github.com/users/ChadFulton/orgs","repos_url":"https://api.github.com/users/ChadFulton/repos","events_url":"https://api.github.com/users/ChadFulton/events{/privacy}","received_events_url":"https://api.github.com/users/ChadFulton/received_events","type":"User","site_admin":false},"repo":{"id":9765991,"name":"statsmodels","full_name":"ChadFulton/statsmodels","owner":{"login":"ChadFulton","id":280864,"avatar_url":"https://avatars.githubusercontent.com/u/280864?v=3","gravatar_id":"","url":"https://api.github.com/users/ChadFulton","html_url":"https://github.com/ChadFulton","followers_url":"https://api.github.com/users/ChadFulton/followers","following_url":"https://api.github.com/users/ChadFulton/following{/other_user}","gists_url":"https://api.github.com/users/ChadFulton/gists{/gist_id}","starred_url":"https://api.github.com/users/ChadFulton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChadFulton/subscriptions","organizations_url":"https://api.github.com/users/ChadFulton/orgs","repos_url":"https://api.github.com/users/ChadFulton/repos","events_url":"https://api.github.com/users/ChadFulton/events{/privacy}","received_events_url":"https://api.github.com/users/ChadFulton/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ChadFulton/statsmodels","description":"Statsmodels: statistical modeling and econometrics in Python","fork":true,"url":"https://api.github.com/repos/ChadFulton/statsmodels","forks_url":"https://api.github.com/repos/ChadFulton/statsmodels/forks","keys_url":"https://api.github.com/repos/ChadFulton/statsmodels/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ChadFulton/statsmodels/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ChadFulton/statsmodels/teams","hooks_url":"https://api.github.com/repos/ChadFulton/statsmodels/hooks","issue_events_url":"https://api.github.com/repos/ChadFulton/statsmodels/issues/events{/number}","events_url":"https://api.github.com/repos/ChadFulton/statsmodels/events","assignees_url":"https://api.github.com/repos/ChadFulton/statsmodels/assignees{/user}","branches_url":"https://api.github.com/repos/ChadFulton/statsmodels/branches{/branch}","tags_url":"https://api.github.com/repos/ChadFulton/statsmodels/tags","blobs_url":"https://api.github.com/repos/ChadFulton/statsmodels/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ChadFulton/statsmodels/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ChadFulton/statsmodels/git/refs{/sha}","trees_url":"https://api.github.com/repos/ChadFulton/statsmodels/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ChadFulton/statsmodels/statuses/{sha}","languages_url":"https://api.github.com/repos/ChadFulton/statsmodels/languages","stargazers_url":"https://api.github.com/repos/ChadFulton/statsmodels/stargazers","contributors_url":"https://api.github.com/repos/ChadFulton/statsmodels/contributors","subscribers_url":"https://api.github.com/repos/ChadFulton/statsmodels/subscribers","subscription_url":"https://api.github.com/repos/ChadFulton/statsmodels/subscription","commits_url":"https://api.github.com/repos/ChadFulton/statsmodels/commits{/sha}","git_commits_url":"https://api.github.com/repos/ChadFulton/statsmodels/git/commits{/sha}","comments_url":"https://api.github.com/repos/ChadFulton/statsmodels/comments{/number}","issue_comment_url":"https://api.github.com/repos/ChadFulton/statsmodels/issues/comments/{number}","contents_url":"https://api.github.com/repos/ChadFulton/statsmodels/contents/{+path}","compare_url":"https://api.github.com/repos/ChadFulton/statsmodels/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ChadFulton/statsmodels/merges","archive_url":"https://api.github.com/repos/ChadFulton/statsmodels/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ChadFulton/statsmodels/downloads","issues_url":"https://api.github.com/repos/ChadFulton/statsmodels/issues{/number}","pulls_url":"https://api.github.com/repos/ChadFulton/statsmodels/pulls{/number}","milestones_url":"https://api.github.com/repos/ChadFulton/statsmodels/milestones{/number}","notifications_url":"https://api.github.com/repos/ChadFulton/statsmodels/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ChadFulton/statsmodels/labels{/name}","releases_url":"https://api.github.com/repos/ChadFulton/statsmodels/releases{/id}","created_at":"2013-04-30T07:16:46Z","updated_at":"2014-10-06T17:08:46Z","pushed_at":"2015-01-16T18:22:53Z","git_url":"git://github.com/ChadFulton/statsmodels.git","ssh_url":"git@github.com:ChadFulton/statsmodels.git","clone_url":"https://github.com/ChadFulton/statsmodels.git","svn_url":"https://github.com/ChadFulton/statsmodels","homepage":"http://statsmodels.sourceforge.net/devel/","size":20598,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"statsmodels:master","ref":"master","sha":"6f25fdd64ee34318e67679bc570c5fb9853d1f0b","user":{"login":"statsmodels","id":717666,"avatar_url":"https://avatars.githubusercontent.com/u/717666?v=3","gravatar_id":"","url":"https://api.github.com/users/statsmodels","html_url":"https://github.com/statsmodels","followers_url":"https://api.github.com/users/statsmodels/followers","following_url":"https://api.github.com/users/statsmodels/following{/other_user}","gists_url":"https://api.github.com/users/statsmodels/gists{/gist_id}","starred_url":"https://api.github.com/users/statsmodels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/statsmodels/subscriptions","organizations_url":"https://api.github.com/users/statsmodels/orgs","repos_url":"https://api.github.com/users/statsmodels/repos","events_url":"https://api.github.com/users/statsmodels/events{/privacy}","received_events_url":"https://api.github.com/users/statsmodels/received_events","type":"Organization","site_admin":false},"repo":{"id":1885237,"name":"statsmodels","full_name":"statsmodels/statsmodels","owner":{"login":"statsmodels","id":717666,"avatar_url":"https://avatars.githubusercontent.com/u/717666?v=3","gravatar_id":"","url":"https://api.github.com/users/statsmodels","html_url":"https://github.com/statsmodels","followers_url":"https://api.github.com/users/statsmodels/followers","following_url":"https://api.github.com/users/statsmodels/following{/other_user}","gists_url":"https://api.github.com/users/statsmodels/gists{/gist_id}","starred_url":"https://api.github.com/users/statsmodels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/statsmodels/subscriptions","organizations_url":"https://api.github.com/users/statsmodels/orgs","repos_url":"https://api.github.com/users/statsmodels/repos","events_url":"https://api.github.com/users/statsmodels/events{/privacy}","received_events_url":"https://api.github.com/users/statsmodels/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/statsmodels/statsmodels","description":"Statsmodels: statistical modeling and econometrics in Python","fork":false,"url":"https://api.github.com/repos/statsmodels/statsmodels","forks_url":"https://api.github.com/repos/statsmodels/statsmodels/forks","keys_url":"https://api.github.com/repos/statsmodels/statsmodels/keys{/key_id}","collaborators_url":"https://api.github.com/repos/statsmodels/statsmodels/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/statsmodels/statsmodels/teams","hooks_url":"https://api.github.com/repos/statsmodels/statsmodels/hooks","issue_events_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/events{/number}","events_url":"https://api.github.com/repos/statsmodels/statsmodels/events","assignees_url":"https://api.github.com/repos/statsmodels/statsmodels/assignees{/user}","branches_url":"https://api.github.com/repos/statsmodels/statsmodels/branches{/branch}","tags_url":"https://api.github.com/repos/statsmodels/statsmodels/tags","blobs_url":"https://api.github.com/repos/statsmodels/statsmodels/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/statsmodels/statsmodels/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/statsmodels/statsmodels/git/refs{/sha}","trees_url":"https://api.github.com/repos/statsmodels/statsmodels/git/trees{/sha}","statuses_url":"https://api.github.com/repos/statsmodels/statsmodels/statuses/{sha}","languages_url":"https://api.github.com/repos/statsmodels/statsmodels/languages","stargazers_url":"https://api.github.com/repos/statsmodels/statsmodels/stargazers","contributors_url":"https://api.github.com/repos/statsmodels/statsmodels/contributors","subscribers_url":"https://api.github.com/repos/statsmodels/statsmodels/subscribers","subscription_url":"https://api.github.com/repos/statsmodels/statsmodels/subscription","commits_url":"https://api.github.com/repos/statsmodels/statsmodels/commits{/sha}","git_commits_url":"https://api.github.com/repos/statsmodels/statsmodels/git/commits{/sha}","comments_url":"https://api.github.com/repos/statsmodels/statsmodels/comments{/number}","issue_comment_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/comments/{number}","contents_url":"https://api.github.com/repos/statsmodels/statsmodels/contents/{+path}","compare_url":"https://api.github.com/repos/statsmodels/statsmodels/compare/{base}...{head}","merges_url":"https://api.github.com/repos/statsmodels/statsmodels/merges","archive_url":"https://api.github.com/repos/statsmodels/statsmodels/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/statsmodels/statsmodels/downloads","issues_url":"https://api.github.com/repos/statsmodels/statsmodels/issues{/number}","pulls_url":"https://api.github.com/repos/statsmodels/statsmodels/pulls{/number}","milestones_url":"https://api.github.com/repos/statsmodels/statsmodels/milestones{/number}","notifications_url":"https://api.github.com/repos/statsmodels/statsmodels/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/statsmodels/statsmodels/labels{/name}","releases_url":"https://api.github.com/repos/statsmodels/statsmodels/releases{/id}","created_at":"2011-06-12T17:04:50Z","updated_at":"2015-02-09T03:21:12Z","pushed_at":"2015-02-08T13:20:15Z","git_url":"git://github.com/statsmodels/statsmodels.git","ssh_url":"git@github.com:statsmodels/statsmodels.git","clone_url":"https://github.com/statsmodels/statsmodels.git","svn_url":"https://github.com/statsmodels/statsmodels","homepage":"http://statsmodels.sourceforge.net/devel/","size":34886,"stargazers_count":869,"watchers_count":869,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":354,"mirror_url":null,"open_issues_count":838,"forks":354,"open_issues":838,"watchers":869,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/statsmodels/statsmodels/pulls/1698"},"html":{"href":"https://github.com/statsmodels/statsmodels/pull/1698"},"issue":{"href":"https://api.github.com/repos/statsmodels/statsmodels/issues/1698"},"comments":{"href":"https://api.github.com/repos/statsmodels/statsmodels/issues/1698/comments"},"review_comments":{"href":"https://api.github.com/repos/statsmodels/statsmodels/pulls/1698/comments"},"review_comment":{"href":"https://api.github.com/repos/statsmodels/statsmodels/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/statsmodels/statsmodels/pulls/1698/commits"},"statuses":{"href":"https://api.github.com/repos/statsmodels/statsmodels/statuses/3c634a6218514332f131971c3d9d0248d18caa1e"}}}}