{"id":20768797,"url":"https://github.com/1995parham-learning/autoregression","last_synced_at":"2025-06-11T23:07:32.304Z","repository":{"id":254989088,"uuid":"618420369","full_name":"1995parham-learning/AutoRegression","owner":"1995parham-learning","description":"Autoregression is a time series model that uses observations from previous time steps as input to a regression equation to predict the value at the next time step.","archived":false,"fork":false,"pushed_at":"2024-08-27T09:54:43.000Z","size":412,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-11T19:38:22.691Z","etag":null,"topics":["autoregression","pacf","stationary","time-series"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/1995parham-learning.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-24T12:35:35.000Z","updated_at":"2024-08-27T09:54:46.000Z","dependencies_parsed_at":"2024-08-27T11:11:37.453Z","dependency_job_id":"b1d46f98-017a-415c-b030-96886c1de1f4","html_url":"https://github.com/1995parham-learning/AutoRegression","commit_stats":null,"previous_names":["1995parham-learning/autoregression"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/1995parham-learning/AutoRegression","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1995parham-learning%2FAutoRegression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1995parham-learning%2FAutoRegression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1995parham-learning%2FAutoRegression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1995parham-learning%2FAutoRegression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1995parham-learning","download_url":"https://codeload.github.com/1995parham-learning/AutoRegression/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1995parham-learning%2FAutoRegression/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259360951,"owners_count":22845825,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autoregression","pacf","stationary","time-series"],"created_at":"2024-11-17T11:40:59.098Z","updated_at":"2025-06-11T23:07:32.257Z","avatar_url":"https://github.com/1995parham-learning.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e AutoRegression \u003c/h1\u003e\n\nAutoregression is a **time series model** that uses observations from previous time steps \nas input to a regression equation to predict the value at the next time step. It is a very \nsimple idea that can result in accurate forecasts on a range of time series problems.\n\n$$y_t = c + \\phi_1 y_{t-1} + \\phi_2 y_{t-2} + ... + \\phi_p y_{t-p} + \\epsilon $$\n\n$\\epsilon$ is the error term of the equation\n\nA **constraint** to using auto regression is that the time series data needs to be stationary.\n\n## Stationarity (weak)\nStationarity means that:\n1. $\\mu$ is constant\n2. $\\sigma$ is constant\n3. There is no seasonality\n\n![examples of time series data that violated the above constraints](img/Statinarity.jpg)\n\n### Checking For Stationarity\n1. Visually\n2. Global vs Local Tests\n3. Augmented Dickey Fuller (ADF) \n\nA very common idea to transform a non-stationary data to a stationary one is differnecing. If $y_t$ is not stationary $y_t - t_{t-1}$ may be stationary.\n\n## Auto Correlation Function (ACF)\nLet's explain this by an example:\n$S_t$ Average price of Salmon this month\nThe most intuitive determiner of the price of Salmon this month is the price of Salmon last month and then the month before that and on and on.\n![ACF](img/ACF.jpg)\nThe direct effect may be a big food festival for example which happens every two months and affacts the price of Salmon\nACF($s_{t-2}$, $s_t$) = CORR($s_{t-2}$, $s_t$) = Pearson correlation \n| x | y |\n| -------- | -------- |\n| January | March |\n| February | April |\n| March | May |\nACF contains the effect of both direct route ($S_{t-2}$ -\u003e $S_{t}$) and indirect route ($S_{t-2}$ -\u003e $S_{t-1}$ -\u003e $S_{t}$)\n\n## Partial Auto Correlation Function (PACF)\nIn PACF we only care about the direct effect $S_{t-2}$ -\u003e $S_{t}$. The ACF($s_{t-2}$, $s_t$) might be high only becase of the inderect effect, the direct effect may have little to no correlation and will barely help us with predicting the Salmon price. PACF gives us only the direct effect.\n$$PACF(k=2): S_t = \\phi_{21} s_{t-1} + \\phi_{22} s_{t-2} + \\epsilon_t$$\n$\\phi_{22}$ gives us the direct effect of $s_{t-2}$ on $s_t$\n\nSee [this file](PACF.ipynb) for code example\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1995parham-learning%2Fautoregression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1995parham-learning%2Fautoregression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1995parham-learning%2Fautoregression/lists"}