{"action":"created","comment":{"url":"https://api.github.com/repos/cloudera/spark-timeseries/pulls/comments/35945377","id":35945377,"diff_hunk":"@@ -0,0 +1,566 @@\n+/**\n+ * Copyright (c) 2015, Cloudera, Inc. All Rights Reserved.\n+ *\n+ * Cloudera, Inc. licenses this file to you under the Apache License,\n+ * Version 2.0 (the \"License\"). You may not use this file except in\n+ * compliance with the License. You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * This software is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n+ * CONDITIONS OF ANY KIND, either express or implied. See the License for\n+ * the specific language governing permissions and limitations under the\n+ * License.\n+ */\n+\n+package com.cloudera.sparkts\n+\n+import breeze.linalg._\n+\n+import org.apache.commons.math3.analysis.{MultivariateVectorFunction, MultivariateFunction}\n+import org.apache.commons.math3.optim.nonlinear.scalar.gradient.NonLinearConjugateGradientOptimizer\n+import org.apache.commons.math3.optim._\n+import org.apache.commons.math3.optim.nonlinear.scalar.{ObjectiveFunctionGradient, GoalType, ObjectiveFunction}\n+import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.BOBYQAOptimizer\n+import org.apache.commons.math3.random.RandomGenerator\n+import org.apache.commons.math3.stat.regression.OLSMultipleLinearRegression\n+\n+\n+object ARIMA {\n+  /**\n+   * Given a time series, fit a non-seasonal ARIMA model of order (p, d, q), where p represents\n+   * the autoregression terms, d represents the order of differencing, and q moving average error\n+   * terms. If includeIntercept is true, the model is fitted with a mean. The user can specify\n+   * the method used to fit the parameters. The current implementation only supports \"css\",\n+   * meaning conditional sum of squares. In order to select the appropriate order of the model,\n+   * users are advised to visualize inspect ACF and PACF plots. Finally, current implementation\n+   * does not verify if the parameters fitted are stationary/invertible. Given this, it is suggested\n+   * that users inspect the resulting model. However, if parameters are not sane, it is likely\n+   * that the order of the model fit is inappropriate.\n+   * We follow the specfication outlined in\n+   * https://www.otexts.org/fpp/8/5\n+   */\n+  def fitModel(\n+      order:(Int, Int, Int),","path":"src/main/scala/com/cloudera/sparkts/ARIMA.scala","position":44,"original_position":44,"commit_id":"a8bf67fc513c6aff8ad7ebfbad6a0e31c620cfea","original_commit_id":"a8bf67fc513c6aff8ad7ebfbad6a0e31c620cfea","user":{"login":"sryza","id":654855,"avatar_url":"https://avatars.githubusercontent.com/u/654855?v=3","gravatar_id":"","url":"https://api.github.com/users/sryza","html_url":"https://github.com/sryza","followers_url":"https://api.github.com/users/sryza/followers","following_url":"https://api.github.com/users/sryza/following{/other_user}","gists_url":"https://api.github.com/users/sryza/gists{/gist_id}","starred_url":"https://api.github.com/users/sryza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sryza/subscriptions","organizations_url":"https://api.github.com/users/sryza/orgs","repos_url":"https://api.github.com/users/sryza/repos","events_url":"https://api.github.com/users/sryza/events{/privacy}","received_events_url":"https://api.github.com/users/sryza/received_events","type":"User","site_admin":false},"body":"I'd separate this into 3 params","created_at":"2015-07-31T04:07:21Z","updated_at":"2015-07-31T04:07:21Z","html_url":"https://github.com/cloudera/spark-timeseries/pull/40#discussion_r35945377","pull_request_url":"https://api.github.com/repos/cloudera/spark-timeseries/pulls/40","_links":{"self":{"href":"https://api.github.com/repos/cloudera/spark-timeseries/pulls/comments/35945377"},"html":{"href":"https://github.com/cloudera/spark-timeseries/pull/40#discussion_r35945377"},"pull_request":{"href":"https://api.github.com/repos/cloudera/spark-timeseries/pulls/40"}}},"pull_request":{"url":"https://api.github.com/repos/cloudera/spark-timeseries/pulls/40","id":40718239,"html_url":"https://github.com/cloudera/spark-timeseries/pull/40","diff_url":"https://github.com/cloudera/spark-timeseries/pull/40.diff","patch_url":"https://github.com/cloudera/spark-timeseries/pull/40.patch","issue_url":"https://api.github.com/repos/cloudera/spark-timeseries/issues/40","number":40,"state":"open","locked":false,"title":"[WIP] ARIMA","user":{"login":"josepablocam","id":5097108,"avatar_url":"https://avatars.githubusercontent.com/u/5097108?v=3","gravatar_id":"","url":"https://api.github.com/users/josepablocam","html_url":"https://github.com/josepablocam","followers_url":"https://api.github.com/users/josepablocam/followers","following_url":"https://api.github.com/users/josepablocam/following{/other_user}","gists_url":"https://api.github.com/users/josepablocam/gists{/gist_id}","starred_url":"https://api.github.com/users/josepablocam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josepablocam/subscriptions","organizations_url":"https://api.github.com/users/josepablocam/orgs","repos_url":"https://api.github.com/users/josepablocam/repos","events_url":"https://api.github.com/users/josepablocam/events{/privacy}","received_events_url":"https://api.github.com/users/josepablocam/received_events","type":"User","site_admin":false},"body":"Here's what I have so far. Any and all feedback welcomed. ","created_at":"2015-07-23T21:04:48Z","updated_at":"2015-07-31T04:07:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2c44335c28c78b5fd01c06bc30d657cec20ddeef","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cloudera/spark-timeseries/pulls/40/commits","review_comments_url":"https://api.github.com/repos/cloudera/spark-timeseries/pulls/40/comments","review_comment_url":"https://api.github.com/repos/cloudera/spark-timeseries/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cloudera/spark-timeseries/issues/40/comments","statuses_url":"https://api.github.com/repos/cloudera/spark-timeseries/statuses/a8bf67fc513c6aff8ad7ebfbad6a0e31c620cfea","head":{"label":"josepablocam:arima","ref":"arima","sha":"a8bf67fc513c6aff8ad7ebfbad6a0e31c620cfea","user":{"login":"josepablocam","id":5097108,"avatar_url":"https://avatars.githubusercontent.com/u/5097108?v=3","gravatar_id":"","url":"https://api.github.com/users/josepablocam","html_url":"https://github.com/josepablocam","followers_url":"https://api.github.com/users/josepablocam/followers","following_url":"https://api.github.com/users/josepablocam/following{/other_user}","gists_url":"https://api.github.com/users/josepablocam/gists{/gist_id}","starred_url":"https://api.github.com/users/josepablocam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josepablocam/subscriptions","organizations_url":"https://api.github.com/users/josepablocam/orgs","repos_url":"https://api.github.com/users/josepablocam/repos","events_url":"https://api.github.com/users/josepablocam/events{/privacy}","received_events_url":"https://api.github.com/users/josepablocam/received_events","type":"User","site_admin":false},"repo":{"id":36529584,"name":"spark-timeseries","full_name":"josepablocam/spark-timeseries","owner":{"login":"josepablocam","id":5097108,"avatar_url":"https://avatars.githubusercontent.com/u/5097108?v=3","gravatar_id":"","url":"https://api.github.com/users/josepablocam","html_url":"https://github.com/josepablocam","followers_url":"https://api.github.com/users/josepablocam/followers","following_url":"https://api.github.com/users/josepablocam/following{/other_user}","gists_url":"https://api.github.com/users/josepablocam/gists{/gist_id}","starred_url":"https://api.github.com/users/josepablocam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josepablocam/subscriptions","organizations_url":"https://api.github.com/users/josepablocam/orgs","repos_url":"https://api.github.com/users/josepablocam/repos","events_url":"https://api.github.com/users/josepablocam/events{/privacy}","received_events_url":"https://api.github.com/users/josepablocam/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/josepablocam/spark-timeseries","description":"A library for financial and time series calculations on Apache Spark","fork":true,"url":"https://api.github.com/repos/josepablocam/spark-timeseries","forks_url":"https://api.github.com/repos/josepablocam/spark-timeseries/forks","keys_url":"https://api.github.com/repos/josepablocam/spark-timeseries/keys{/key_id}","collaborators_url":"https://api.github.com/repos/josepablocam/spark-timeseries/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/josepablocam/spark-timeseries/teams","hooks_url":"https://api.github.com/repos/josepablocam/spark-timeseries/hooks","issue_events_url":"https://api.github.com/repos/josepablocam/spark-timeseries/issues/events{/number}","events_url":"https://api.github.com/repos/josepablocam/spark-timeseries/events","assignees_url":"https://api.github.com/repos/josepablocam/spark-timeseries/assignees{/user}","branches_url":"https://api.github.com/repos/josepablocam/spark-timeseries/branches{/branch}","tags_url":"https://api.github.com/repos/josepablocam/spark-timeseries/tags","blobs_url":"https://api.github.com/repos/josepablocam/spark-timeseries/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/josepablocam/spark-timeseries/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/josepablocam/spark-timeseries/git/refs{/sha}","trees_url":"https://api.github.com/repos/josepablocam/spark-timeseries/git/trees{/sha}","statuses_url":"https://api.github.com/repos/josepablocam/spark-timeseries/statuses/{sha}","languages_url":"https://api.github.com/repos/josepablocam/spark-timeseries/languages","stargazers_url":"https://api.github.com/repos/josepablocam/spark-timeseries/stargazers","contributors_url":"https://api.github.com/repos/josepablocam/spark-timeseries/contributors","subscribers_url":"https://api.github.com/repos/josepablocam/spark-timeseries/subscribers","subscription_url":"https://api.github.com/repos/josepablocam/spark-timeseries/subscription","commits_url":"https://api.github.com/repos/josepablocam/spark-timeseries/commits{/sha}","git_commits_url":"https://api.github.com/repos/josepablocam/spark-timeseries/git/commits{/sha}","comments_url":"https://api.github.com/repos/josepablocam/spark-timeseries/comments{/number}","issue_comment_url":"https://api.github.com/repos/josepablocam/spark-timeseries/issues/comments{/number}","contents_url":"https://api.github.com/repos/josepablocam/spark-timeseries/contents/{+path}","compare_url":"https://api.github.com/repos/josepablocam/spark-timeseries/compare/{base}...{head}","merges_url":"https://api.github.com/repos/josepablocam/spark-timeseries/merges","archive_url":"https://api.github.com/repos/josepablocam/spark-timeseries/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/josepablocam/spark-timeseries/downloads","issues_url":"https://api.github.com/repos/josepablocam/spark-timeseries/issues{/number}","pulls_url":"https://api.github.com/repos/josepablocam/spark-timeseries/pulls{/number}","milestones_url":"https://api.github.com/repos/josepablocam/spark-timeseries/milestones{/number}","notifications_url":"https://api.github.com/repos/josepablocam/spark-timeseries/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/josepablocam/spark-timeseries/labels{/name}","releases_url":"https://api.github.com/repos/josepablocam/spark-timeseries/releases{/id}","created_at":"2015-05-29T21:18:18Z","updated_at":"2015-05-29T21:18:18Z","pushed_at":"2015-07-27T22:32:23Z","git_url":"git://github.com/josepablocam/spark-timeseries.git","ssh_url":"git@github.com:josepablocam/spark-timeseries.git","clone_url":"https://github.com/josepablocam/spark-timeseries.git","svn_url":"https://github.com/josepablocam/spark-timeseries","homepage":null,"size":761,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cloudera:master","ref":"master","sha":"1a15e0f2c9970b3a5c1c3ed002bce870c2bd8fad","user":{"login":"cloudera","id":87383,"avatar_url":"https://avatars.githubusercontent.com/u/87383?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudera","html_url":"https://github.com/cloudera","followers_url":"https://api.github.com/users/cloudera/followers","following_url":"https://api.github.com/users/cloudera/following{/other_user}","gists_url":"https://api.github.com/users/cloudera/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudera/subscriptions","organizations_url":"https://api.github.com/users/cloudera/orgs","repos_url":"https://api.github.com/users/cloudera/repos","events_url":"https://api.github.com/users/cloudera/events{/privacy}","received_events_url":"https://api.github.com/users/cloudera/received_events","type":"Organization","site_admin":false},"repo":{"id":32005904,"name":"spark-timeseries","full_name":"cloudera/spark-timeseries","owner":{"login":"cloudera","id":87383,"avatar_url":"https://avatars.githubusercontent.com/u/87383?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudera","html_url":"https://github.com/cloudera","followers_url":"https://api.github.com/users/cloudera/followers","following_url":"https://api.github.com/users/cloudera/following{/other_user}","gists_url":"https://api.github.com/users/cloudera/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudera/subscriptions","organizations_url":"https://api.github.com/users/cloudera/orgs","repos_url":"https://api.github.com/users/cloudera/repos","events_url":"https://api.github.com/users/cloudera/events{/privacy}","received_events_url":"https://api.github.com/users/cloudera/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudera/spark-timeseries","description":"A library for financial and time series calculations on Apache Spark","fork":false,"url":"https://api.github.com/repos/cloudera/spark-timeseries","forks_url":"https://api.github.com/repos/cloudera/spark-timeseries/forks","keys_url":"https://api.github.com/repos/cloudera/spark-timeseries/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudera/spark-timeseries/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudera/spark-timeseries/teams","hooks_url":"https://api.github.com/repos/cloudera/spark-timeseries/hooks","issue_events_url":"https://api.github.com/repos/cloudera/spark-timeseries/issues/events{/number}","events_url":"https://api.github.com/repos/cloudera/spark-timeseries/events","assignees_url":"https://api.github.com/repos/cloudera/spark-timeseries/assignees{/user}","branches_url":"https://api.github.com/repos/cloudera/spark-timeseries/branches{/branch}","tags_url":"https://api.github.com/repos/cloudera/spark-timeseries/tags","blobs_url":"https://api.github.com/repos/cloudera/spark-timeseries/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudera/spark-timeseries/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudera/spark-timeseries/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudera/spark-timeseries/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudera/spark-timeseries/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudera/spark-timeseries/languages","stargazers_url":"https://api.github.com/repos/cloudera/spark-timeseries/stargazers","contributors_url":"https://api.github.com/repos/cloudera/spark-timeseries/contributors","subscribers_url":"https://api.github.com/repos/cloudera/spark-timeseries/subscribers","subscription_url":"https://api.github.com/repos/cloudera/spark-timeseries/subscription","commits_url":"https://api.github.com/repos/cloudera/spark-timeseries/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudera/spark-timeseries/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudera/spark-timeseries/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudera/spark-timeseries/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudera/spark-timeseries/contents/{+path}","compare_url":"https://api.github.com/repos/cloudera/spark-timeseries/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudera/spark-timeseries/merges","archive_url":"https://api.github.com/repos/cloudera/spark-timeseries/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudera/spark-timeseries/downloads","issues_url":"https://api.github.com/repos/cloudera/spark-timeseries/issues{/number}","pulls_url":"https://api.github.com/repos/cloudera/spark-timeseries/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudera/spark-timeseries/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudera/spark-timeseries/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudera/spark-timeseries/labels{/name}","releases_url":"https://api.github.com/repos/cloudera/spark-timeseries/releases{/id}","created_at":"2015-03-11T08:14:49Z","updated_at":"2015-07-29T07:24:26Z","pushed_at":"2015-07-27T22:32:24Z","git_url":"git://github.com/cloudera/spark-timeseries.git","ssh_url":"git@github.com:cloudera/spark-timeseries.git","clone_url":"https://github.com/cloudera/spark-timeseries.git","svn_url":"https://github.com/cloudera/spark-timeseries","homepage":null,"size":946,"stargazers_count":157,"watchers_count":157,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":49,"mirror_url":null,"open_issues_count":25,"forks":49,"open_issues":25,"watchers":157,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cloudera/spark-timeseries/pulls/40"},"html":{"href":"https://github.com/cloudera/spark-timeseries/pull/40"},"issue":{"href":"https://api.github.com/repos/cloudera/spark-timeseries/issues/40"},"comments":{"href":"https://api.github.com/repos/cloudera/spark-timeseries/issues/40/comments"},"review_comments":{"href":"https://api.github.com/repos/cloudera/spark-timeseries/pulls/40/comments"},"review_comment":{"href":"https://api.github.com/repos/cloudera/spark-timeseries/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cloudera/spark-timeseries/pulls/40/commits"},"statuses":{"href":"https://api.github.com/repos/cloudera/spark-timeseries/statuses/a8bf67fc513c6aff8ad7ebfbad6a0e31c620cfea"}}}}