{"action":"created","comment":{"url":"https://api.github.com/repos/statsmodels/statsmodels/pulls/comments/49997788","id":49997788,"diff_hunk":"@@ -1055,6 +1055,115 @@ def arma_order_select_ic(y, max_ar=4, max_ma=2, ic='bic', trend='c',\n     return Bunch(**res)\n \n \n+def kpss(x, null_hypo=\"level\", lags=None):\n+    \"\"\"\n+    Kwiatkowski-Phillips-Schmidt-Shin test for stationarity.\n+\n+    Computes the Kwiatkowski-Phillips-Schmidt-Shin (KPSS) test for the null\n+    hypothesis that x is level or trend stationary.\n+\n+    Parameters\n+    ----------\n+    x : array_like, 1d\n+        Data series\n+    null_hypo : str{\"level\", \"trend\"}\n+        Indicates the null hypothesis for the KPSS test\n+        * \"level\" : The data is level stationary (default)\n+        * \"trend\" : The data is trend stationary\n+    lags : int\n+        Indicates the number of lags to be used. If None (default),\n+        lags is set to int(12 * (n / 100) ** (1 / 4)), as outlined in\n+        Schwert (1989).\n+\n+    Returns\n+    -------\n+    kpss_stat : float\n+        The KPSS test statistic\n+    p_value : float\n+        The p-value of the test\n+    lags : int\n+        The truncation lag parameter\n+    flag: int\n+        * -1 : the p-value is smaller than the indicated p-value.\n+        * 0 : the p-value is the indicated p-value.\n+        * 1 : the p-value is greater than the indicated p-value.\n+    crit : dict\n+        The critical values at 10%, 5%, 2.5% and 1%. Based on\n+        Kwiatkowski et al. (1992).\n+\n+    Notes\n+    -----\n+    To estimate sigma^2 the Newey-West estimator is used. If lags is None,\n+    the truncation lag parameter is set to int(12 * (n / 100) ** (1 / 4)),\n+    as outlined in Schwert (1989). The p-values are interpolated from\n+    Table 1 of Kwiatkowski et al. (1992).\n+\n+    Missing values are not handled.\n+\n+    References\n+    ----------\n+    D. Kwiatkowski, P. C. B. Phillips, P. Schmidt, and Y. Shin (1992): Testing\n+    the Null Hypothesis of Stationarity against the Alternative of a Unit Root.\n+    `Journal of Econometrics` 54, 159–178.\n+    \"\"\"\n+    nobs = len(x)\n+    x = np.asarray(x)\n+    hypo = null_hypo.lower()\n+\n+    # if n != m * n\n+    if nobs != x.size:\n+        raise ValueError(\"x of shape {} not understood\".format(x.shape))\n+\n+    if hypo == \"trend\":\n+        # p. 162 Kwiatkowski et al. (1992): y_t = beta * t + r_t + e_t,\n+        # where beta is the trend, r_t a random walk and e_t a stationary\n+        # error term.\n+        resids = OLS(x, add_constant(range(1, nobs + 1))).fit().resid\n+        crit = [0.119, 0.146, 0.176, 0.216]\n+    elif hypo == \"level\":\n+        # special case of the model above, where beta = 0 (so the null\n+        # hypothesis is that the data is stationary around r_0).\n+        resids = OLS(x, np.ones(nobs)).fit().resid\n+        crit = [0.347, 0.463, 0.574, 0.739]\n+    else:\n+        raise ValueError(\"hypothesis '{}' not understood\".format(hypo))\n+\n+    if lags is None:\n+        # from Kwiatkowski et al. referencing Schwert (1989)\n+        lags = int(np.ceil(12. * np.power(nobs / 100., 1 / 4.)))\n+\n+    pvals = [0.10, 0.05, 0.025, 0.01]\n+\n+    eta = sum(resids.cumsum() ** 2) / (nobs ** 2)  # eq. 11, p. 165\n+    s_hat = _sigma_est_kpss(resids, nobs, lags)\n+\n+    kpss_stat = eta / s_hat\n+    p_value = np.interp(kpss_stat, crit, pvals)\n+\n+    if p_value == pvals[-1]:\n+        flag = -1\n+    elif p_value == pvals[0]:\n+        flag = 1\n+    else:\n+        flag = 0\n+\n+    return kpss_stat, p_value, lags, flag, {'10%' : crit[0], '5%' : crit[1],\n+                                            '2.5%' : crit[2], '1%' : crit[3]}","path":"statsmodels/tsa/stattools.py","position":null,"original_position":106,"commit_id":"1d3ad006d8931d5611bd45a3667182d5f4c7521e","original_commit_id":"afbbf5e3ce98cd3988901df794f689c151aa0bd7","user":{"login":"N-Wouda","id":16272507,"avatar_url":"https://avatars.githubusercontent.com/u/16272507?v=3","gravatar_id":"","url":"https://api.github.com/users/N-Wouda","html_url":"https://github.com/N-Wouda","followers_url":"https://api.github.com/users/N-Wouda/followers","following_url":"https://api.github.com/users/N-Wouda/following{/other_user}","gists_url":"https://api.github.com/users/N-Wouda/gists{/gist_id}","starred_url":"https://api.github.com/users/N-Wouda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/N-Wouda/subscriptions","organizations_url":"https://api.github.com/users/N-Wouda/orgs","repos_url":"https://api.github.com/users/N-Wouda/repos","events_url":"https://api.github.com/users/N-Wouda/events{/privacy}","received_events_url":"https://api.github.com/users/N-Wouda/received_events","type":"User","site_admin":false},"body":"I will follow `adfuller` and add the optional argument to return a results store.","created_at":"2016-01-18T13:24:59Z","updated_at":"2016-01-18T13:24:59Z","html_url":"https://github.com/statsmodels/statsmodels/pull/2749#discussion_r49997788","pull_request_url":"https://api.github.com/repos/statsmodels/statsmodels/pulls/2749","_links":{"self":{"href":"https://api.github.com/repos/statsmodels/statsmodels/pulls/comments/49997788"},"html":{"href":"https://github.com/statsmodels/statsmodels/pull/2749#discussion_r49997788"},"pull_request":{"href":"https://api.github.com/repos/statsmodels/statsmodels/pulls/2749"}}},"pull_request":{"url":"https://api.github.com/repos/statsmodels/statsmodels/pulls/2749","id":55116462,"html_url":"https://github.com/statsmodels/statsmodels/pull/2749","diff_url":"https://github.com/statsmodels/statsmodels/pull/2749.diff","patch_url":"https://github.com/statsmodels/statsmodels/pull/2749.patch","issue_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/2749","number":2749,"state":"open","locked":false,"title":"Added kpss test","user":{"login":"N-Wouda","id":16272507,"avatar_url":"https://avatars.githubusercontent.com/u/16272507?v=3","gravatar_id":"","url":"https://api.github.com/users/N-Wouda","html_url":"https://github.com/N-Wouda","followers_url":"https://api.github.com/users/N-Wouda/followers","following_url":"https://api.github.com/users/N-Wouda/following{/other_user}","gists_url":"https://api.github.com/users/N-Wouda/gists{/gist_id}","starred_url":"https://api.github.com/users/N-Wouda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/N-Wouda/subscriptions","organizations_url":"https://api.github.com/users/N-Wouda/orgs","repos_url":"https://api.github.com/users/N-Wouda/repos","events_url":"https://api.github.com/users/N-Wouda/events{/privacy}","received_events_url":"https://api.github.com/users/N-Wouda/received_events","type":"User","site_admin":false},"body":"Added an implementation of the Kwiatkowski–Phillips–Schmidt–Shin (KPSS) test to `tsa.stattools`.","created_at":"2016-01-05T17:09:16Z","updated_at":"2016-01-18T13:24:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e235fa00b5dc5dd0b378e1c7f7f3c950e1b07cdd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/statsmodels/statsmodels/pulls/2749/commits","review_comments_url":"https://api.github.com/repos/statsmodels/statsmodels/pulls/2749/comments","review_comment_url":"https://api.github.com/repos/statsmodels/statsmodels/pulls/comments{/number}","comments_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/2749/comments","statuses_url":"https://api.github.com/repos/statsmodels/statsmodels/statuses/1d3ad006d8931d5611bd45a3667182d5f4c7521e","head":{"label":"N-Wouda:N-Wouda-kpss","ref":"N-Wouda-kpss","sha":"1d3ad006d8931d5611bd45a3667182d5f4c7521e","user":{"login":"N-Wouda","id":16272507,"avatar_url":"https://avatars.githubusercontent.com/u/16272507?v=3","gravatar_id":"","url":"https://api.github.com/users/N-Wouda","html_url":"https://github.com/N-Wouda","followers_url":"https://api.github.com/users/N-Wouda/followers","following_url":"https://api.github.com/users/N-Wouda/following{/other_user}","gists_url":"https://api.github.com/users/N-Wouda/gists{/gist_id}","starred_url":"https://api.github.com/users/N-Wouda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/N-Wouda/subscriptions","organizations_url":"https://api.github.com/users/N-Wouda/orgs","repos_url":"https://api.github.com/users/N-Wouda/repos","events_url":"https://api.github.com/users/N-Wouda/events{/privacy}","received_events_url":"https://api.github.com/users/N-Wouda/received_events","type":"User","site_admin":false},"repo":{"id":49068816,"name":"statsmodels","full_name":"N-Wouda/statsmodels","owner":{"login":"N-Wouda","id":16272507,"avatar_url":"https://avatars.githubusercontent.com/u/16272507?v=3","gravatar_id":"","url":"https://api.github.com/users/N-Wouda","html_url":"https://github.com/N-Wouda","followers_url":"https://api.github.com/users/N-Wouda/followers","following_url":"https://api.github.com/users/N-Wouda/following{/other_user}","gists_url":"https://api.github.com/users/N-Wouda/gists{/gist_id}","starred_url":"https://api.github.com/users/N-Wouda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/N-Wouda/subscriptions","organizations_url":"https://api.github.com/users/N-Wouda/orgs","repos_url":"https://api.github.com/users/N-Wouda/repos","events_url":"https://api.github.com/users/N-Wouda/events{/privacy}","received_events_url":"https://api.github.com/users/N-Wouda/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/N-Wouda/statsmodels","description":"Statsmodels: statistical modeling and econometrics in Python","fork":true,"url":"https://api.github.com/repos/N-Wouda/statsmodels","forks_url":"https://api.github.com/repos/N-Wouda/statsmodels/forks","keys_url":"https://api.github.com/repos/N-Wouda/statsmodels/keys{/key_id}","collaborators_url":"https://api.github.com/repos/N-Wouda/statsmodels/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/N-Wouda/statsmodels/teams","hooks_url":"https://api.github.com/repos/N-Wouda/statsmodels/hooks","issue_events_url":"https://api.github.com/repos/N-Wouda/statsmodels/issues/events{/number}","events_url":"https://api.github.com/repos/N-Wouda/statsmodels/events","assignees_url":"https://api.github.com/repos/N-Wouda/statsmodels/assignees{/user}","branches_url":"https://api.github.com/repos/N-Wouda/statsmodels/branches{/branch}","tags_url":"https://api.github.com/repos/N-Wouda/statsmodels/tags","blobs_url":"https://api.github.com/repos/N-Wouda/statsmodels/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/N-Wouda/statsmodels/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/N-Wouda/statsmodels/git/refs{/sha}","trees_url":"https://api.github.com/repos/N-Wouda/statsmodels/git/trees{/sha}","statuses_url":"https://api.github.com/repos/N-Wouda/statsmodels/statuses/{sha}","languages_url":"https://api.github.com/repos/N-Wouda/statsmodels/languages","stargazers_url":"https://api.github.com/repos/N-Wouda/statsmodels/stargazers","contributors_url":"https://api.github.com/repos/N-Wouda/statsmodels/contributors","subscribers_url":"https://api.github.com/repos/N-Wouda/statsmodels/subscribers","subscription_url":"https://api.github.com/repos/N-Wouda/statsmodels/subscription","commits_url":"https://api.github.com/repos/N-Wouda/statsmodels/commits{/sha}","git_commits_url":"https://api.github.com/repos/N-Wouda/statsmodels/git/commits{/sha}","comments_url":"https://api.github.com/repos/N-Wouda/statsmodels/comments{/number}","issue_comment_url":"https://api.github.com/repos/N-Wouda/statsmodels/issues/comments{/number}","contents_url":"https://api.github.com/repos/N-Wouda/statsmodels/contents/{+path}","compare_url":"https://api.github.com/repos/N-Wouda/statsmodels/compare/{base}...{head}","merges_url":"https://api.github.com/repos/N-Wouda/statsmodels/merges","archive_url":"https://api.github.com/repos/N-Wouda/statsmodels/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/N-Wouda/statsmodels/downloads","issues_url":"https://api.github.com/repos/N-Wouda/statsmodels/issues{/number}","pulls_url":"https://api.github.com/repos/N-Wouda/statsmodels/pulls{/number}","milestones_url":"https://api.github.com/repos/N-Wouda/statsmodels/milestones{/number}","notifications_url":"https://api.github.com/repos/N-Wouda/statsmodels/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/N-Wouda/statsmodels/labels{/name}","releases_url":"https://api.github.com/repos/N-Wouda/statsmodels/releases{/id}","created_at":"2016-01-05T13:50:58Z","updated_at":"2016-01-05T13:51:03Z","pushed_at":"2016-01-17T23:12:15Z","git_url":"git://github.com/N-Wouda/statsmodels.git","ssh_url":"git@github.com:N-Wouda/statsmodels.git","clone_url":"https://github.com/N-Wouda/statsmodels.git","svn_url":"https://github.com/N-Wouda/statsmodels","homepage":"http://statsmodels.sourceforge.net/devel/","size":21899,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"statsmodels:master","ref":"master","sha":"54d6c2b6821b79d3c28c04f66bd981b1ae4f5f29","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":"2016-01-18T12:07:57Z","pushed_at":"2016-01-18T06:58:20Z","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":35408,"stargazers_count":1264,"watchers_count":1264,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":590,"mirror_url":null,"open_issues_count":1171,"forks":590,"open_issues":1171,"watchers":1264,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/statsmodels/statsmodels/pulls/2749"},"html":{"href":"https://github.com/statsmodels/statsmodels/pull/2749"},"issue":{"href":"https://api.github.com/repos/statsmodels/statsmodels/issues/2749"},"comments":{"href":"https://api.github.com/repos/statsmodels/statsmodels/issues/2749/comments"},"review_comments":{"href":"https://api.github.com/repos/statsmodels/statsmodels/pulls/2749/comments"},"review_comment":{"href":"https://api.github.com/repos/statsmodels/statsmodels/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/statsmodels/statsmodels/pulls/2749/commits"},"statuses":{"href":"https://api.github.com/repos/statsmodels/statsmodels/statuses/1d3ad006d8931d5611bd45a3667182d5f4c7521e"}}}}