From 82bd28204598fa0a31dab888923cde324e15c805 Mon Sep 17 00:00:00 2001 From: glevy <glevy@crans.org> Date: Wed, 8 May 2024 18:39:45 +0200 Subject: [PATCH] Pas loin de la fin ? --- README.md | 92 +-------------------- "R\303\251sultats tests 0" | 100 +---------------------- "R\303\251sultats tests 1" | 106 +----------------------- "R\303\251sultats tests 2" | 84 ------------------- "R\303\251sultats tests 3" | 95 ---------------------- "R\303\251sultats tests 4" | 93 --------------------- main.r | 160 +++++++++++++++++++++++++++---------- 7 files changed, 122 insertions(+), 608 deletions(-) delete mode 100644 "R\303\251sultats tests 2" delete mode 100644 "R\303\251sultats tests 3" delete mode 100644 "R\303\251sultats tests 4" diff --git a/README.md b/README.md index c238399..974fe57 100644 --- a/README.md +++ b/README.md @@ -1,93 +1,7 @@ # Séries temporelles linéaires +*Guillaume Lévy, Thomas Pogu* -## Getting started - -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://gitlab.crans.org/ensae/series-temporelles-lineaires.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](https://gitlab.crans.org/ensae/series-temporelles-lineaires/-/settings/integrations) - -## Collaborate with your team - -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README - -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +## Licence +Ce projet est sous la licence GPLv3. diff --git "a/R\303\251sultats tests 0" "b/R\303\251sultats tests 0" index ce56e21..e61c1e9 100644 --- "a/R\303\251sultats tests 0" +++ "b/R\303\251sultats tests 0" @@ -66,102 +66,4 @@ s.e. 0.0024 sigma^2 estimated as 0.002115: log likelihood = 596.06, aic = -1188.11 > BIC(arima(y, c(0,0,0))) -[1] -1180.348 - - - - - - - - - - - - - -==== Ancienne partie avant le log ==== - -arima(y,c(0,0,0)) - -Call: -arima(x = y, order = c(0, 0, 0)) - -Coefficients: - intercept - 0.0000 -s.e. 0.1659 - -sigma^2 estimated as 9.88: log likelihood = -920.54, aic = 1845.08 -> BIC(arima(y,c(0,0,0))) -[1] 1852.845 - -arima(y,c(0,0,1)) - -Call: -arima(x = y, order = c(0, 0, 1)) - -Coefficients: - ma1 intercept - -0.6738 -0.0002 -s.e. 0.0382 0.0451 - -sigma^2 estimated as 6.786: log likelihood = -853.41, aic = 1712.82 -> BIC(arima(y,c(0,0,1))) -[1] 1724.473 - -arima(y,c(0,0,2)) - -Call: -arima(x = y, order = c(0, 0, 2)) - -Coefficients: - ma1 ma2 intercept - -0.6734 -0.0006 -0.0002 -s.e. 0.0520 0.0498 0.0451 - -sigma^2 estimated as 6.786: log likelihood = -853.41, aic = 1714.82 -> BIC(arima(y,c(0,0,2))) -[1] 1730.356 - -arima(y,c(0,0,3)) - -Call: -arima(x = y, order = c(0, 0, 3)) - -Coefficients: - ma1 ma2 ma3 intercept - -0.6718 0.0235 -0.0332 -0.0007 -s.e. 0.0526 0.0687 0.0657 0.0441 - -sigma^2 estimated as 6.781: log likelihood = -853.28, aic = 1716.57 -> BIC(arima(y,c(0,0,3))) -[1] 1735.983 - -arima(y,c(0,0,4)) - -Call: -arima(x = y, order = c(0, 0, 4)) - -Coefficients: - ma1 ma2 ma3 ma4 intercept - -0.6828 0.0402 -0.0654 0.0349 -0.0004 -s.e. 0.0560 0.0771 0.0879 0.0631 0.0452 - -sigma^2 estimated as 6.775: log likelihood = -853.13, aic = 1718.26 -> BIC(arima(y,c(0,0,4))) -[1] 1741.557 - -arima(y,c(0,0,5)) - -Call: -arima(x = y, order = c(0, 0, 5)) - -Coefficients: - ma1 ma2 ma3 ma4 ma5 intercept - -0.6595 -0.0018 -0.0372 -0.0804 0.1830 0.0018 -s.e. 0.0524 0.0637 0.0679 0.0685 0.0569 0.0548 - -sigma^2 estimated as 6.589: log likelihood = -848.2, aic = 1710.41 -> BIC(arima(y,c(0,0,5))) -[1] 1737.589 \ No newline at end of file +[1] -1180.348 \ No newline at end of file diff --git "a/R\303\251sultats tests 1" "b/R\303\251sultats tests 1" index 7c9423f..722abf5 100644 --- "a/R\303\251sultats tests 1" +++ "b/R\303\251sultats tests 1" @@ -74,108 +74,4 @@ En fait faut pas retirer la moyenne, ça fait de la daube. Coefficients: ma1 intercept -0.6646 0.0035 -s.e. 0.0395 0.0007 - - - - - - - - - - - - - -==== Ancienne partie avant log ==== - -arima(y,c(1,0,0)) - -Call: -arima(x = y, order = c(1, 0, 0)) - -Coefficients: - ar1 intercept - -0.4723 -0.0014 -s.e. 0.0466 0.0994 - -sigma^2 estimated as 7.681: log likelihood = -875.48, aic = 1756.95 -> BIC(arima(y,c(1,0,0))) -[1] 1768.602 - - -arima(y,c(1,0,1)) - -Call: -arima(x = y, order = c(1, 0, 1)) - -Coefficients: - ar1 ma1 intercept - 0.0009 -0.6743 -0.0002 -s.e. 0.0760 0.0549 0.0451 - -sigma^2 estimated as 6.786: log likelihood = -853.41, aic = 1714.82 -> BIC(arima(y,c(1,0,1))) -[1] 1730.356 - - -arima(y,c(1,0,2)) - -Call: -arima(x = y, order = c(1, 0, 2)) - -Coefficients: - ar1 ma1 ma2 intercept - -0.9540 0.3193 -0.6807 0.0000 -s.e. 0.0174 0.0387 0.0381 0.0447 - -sigma^2 estimated as 6.631: log likelihood = -850.37, aic = 1710.75 -> BIC(arima(y,c(1,0,2))) -[1] 1730.164 - - -arima(y,c(1,0,3)) - -Call: -arima(x = y, order = c(1, 0, 3)) - -Coefficients: - ar1 ma1 ma2 ma3 intercept - -0.9519 0.3038 -0.6752 0.021 0.0002 -s.e. 0.0185 0.0547 0.0411 0.051 0.0455 - -sigma^2 estimated as 6.627: log likelihood = -850.29, aic = 1712.58 -> BIC(arima(y,c(1,0,3))) -[1] 1735.878 - - -arima(y,c(1,0,4)) - -Call: -arima(x = y, order = c(1, 0, 4)) - -Coefficients: - ar1 ma1 ma2 ma3 ma4 intercept - -0.9001 0.2558 -0.5897 0.0129 -0.0815 -0.0008 -s.e. 0.0631 0.0777 0.0729 0.0558 0.0668 0.0431 - -sigma^2 estimated as 6.652: log likelihood = -849.97, aic = 1713.94 -> BIC(arima(y,c(1,0,4))) -[1] 1741.128 - - -arima(y,c(1,0,5)) - -Call: -arima(x = y, order = c(1, 0, 5)) - -Coefficients: - ar1 ma1 ma2 ma3 ma4 ma5 intercept - -0.5232 -0.1410 -0.3425 -0.0422 -0.0942 0.1841 0.0009 -s.e. 0.3771 0.3755 0.2442 0.0575 0.0564 0.0577 0.0502 - -sigma^2 estimated as 6.56: log likelihood = -847.43, aic = 1710.86 - -BIC(arima(y,c(1,0,5))) -[1] 1741.924 \ No newline at end of file +s.e. 0.0395 0.0007 \ No newline at end of file diff --git "a/R\303\251sultats tests 2" "b/R\303\251sultats tests 2" deleted file mode 100644 index c258320..0000000 --- "a/R\303\251sultats tests 2" +++ /dev/null @@ -1,84 +0,0 @@ -arima(y,c(2,0,0)) - -Call: -arima(x = y, order = c(2, 0, 0)) - -Coefficients: - ar1 ar2 intercept - -0.5883 -0.2556 0.0013 -s.e. 0.0511 0.0526 0.0770 - -sigma^2 estimated as 7.204: log likelihood = -864.04, aic = 1736.09 -> BIC(arima(y,c(2,0,0))) -[1] 1751.62 - -arima(y,c(2,0,1)) - -Call: -arima(x = y, order = c(2, 0, 1)) - -Coefficients: - ar1 ar2 ma1 intercept - 0.0206 0.0283 -0.6941 -0.0005 -s.e. 0.0907 0.0741 0.0731 0.0445 - -sigma^2 estimated as 6.783: log likelihood = -853.34, aic = 1716.68 -> BIC(arima(y,c(2,0,1))) -[1] 1736.093 - -arima(y,c(2,0,2)) - -Call: -arima(x = y, order = c(2, 0, 2)) - -Coefficients: - ar1 ar2 ma1 ma2 intercept - -0.0606 0.0298 -0.6128 -0.0556 -0.0005 -s.e. 0.6334 0.0749 0.6314 0.4240 0.0445 - -sigma^2 estimated as 6.783: log likelihood = -853.33, aic = 1718.66 -> BIC(arima(y,c(2,0,2))) -[1] 1741.963 - -arima(y,c(2,0,3)) - -Call: -arima(x = y, order = c(2, 0, 3)) - -Coefficients: - ar1 ar2 ma1 ma2 ma3 intercept - -1.3121 -0.9682 0.6142 0.1448 -0.6129 0.0004 -s.e. 0.0315 0.0268 0.0500 0.0578 0.0562 0.0473 - -sigma^2 estimated as 6.503: log likelihood = -846.26, aic = 1706.51 -> BIC(arima(y,c(2,0,3))) -[1] 1733.697 - -arima(y,c(2,0,4)) - -Call: -arima(x = y, order = c(2, 0, 4)) - -Coefficients: - ar1 ar2 ma1 ma2 ma3 ma4 intercept - -1.3319 -0.9599 0.6943 0.1226 -0.6441 -0.1031 -0.0003 -s.e. 0.0363 0.0316 0.0639 0.0566 0.0535 0.0538 0.0438 - -sigma^2 estimated as 6.44: log likelihood = -844.49, aic = 1704.97 -> BIC(arima(y,c(2,0,4))) -[1] 1736.041 - - -arima(y,c(2,0,5)) - -Call: -arima(x = y, order = c(2, 0, 5)) - -Coefficients: - ar1 ar2 ma1 ma2 ma3 ma4 ma5 intercept - -0.4245 0.3337 -0.2382 -0.6047 0.1772 -0.0902 0.1950 0.0018 -s.e. 0.2293 0.2233 0.2262 0.1282 0.1645 0.0612 0.0638 0.0544 - -sigma^2 estimated as 6.536: log likelihood = -846.87, aic = 1711.73 -> BIC(arima(y,c(2,0,5))) -[1] 1746.681 \ No newline at end of file diff --git "a/R\303\251sultats tests 3" "b/R\303\251sultats tests 3" deleted file mode 100644 index 5137569..0000000 --- "a/R\303\251sultats tests 3" +++ /dev/null @@ -1,95 +0,0 @@ -arima(y,c(3,0,0)) - -Call: -arima(x = y, order = c(3, 0, 0)) - -Coefficients: - ar1 ar2 ar3 intercept - -0.6178 -0.3234 -0.1236 0.0012 -s.e. 0.0524 0.0601 0.0541 0.0683 - -sigma^2 estimated as 7.1: log likelihood = -861.45, aic = 1732.9 - -BIC(arima(y,c(3,0,0))) -[1] 1752.319 - - -arima(y,c(3,0,1)) - -Call: -arima(x = y, order = c(3, 0, 1)) - -Coefficients: - ar1 ar2 ar3 ma1 intercept - -0.0062 0.0106 -0.0309 -0.6671 -0.0004 -s.e. 0.1091 0.0838 0.0692 0.0965 0.0448 - -sigma^2 estimated as 6.779: log likelihood = -853.24, aic = 1718.49 - -BIC(arima(y,c(3,0,1))) -[1] 1741.786 - - -arima(y,c(3,0,2)) - -Call: -arima(x = y, order = c(3, 0, 2)) - -Coefficients: - ar1 ar2 ar3 ma1 ma2 intercept - -0.9111 0.0767 0.0799 0.2548 -0.6895 -0.0004 -s.e. 0.0997 0.1414 0.0776 0.0836 0.0718 0.0442 - -sigma^2 estimated as 6.658: log likelihood = -850.14, aic = 1714.27 - - - -BIC(arima(y,c(3,0,2))) -[1] 1741.458 - - -arima(y,c(3,0,3)) - -Call: -arima(x = y, order = c(3, 0, 3)) - -Coefficients: - ar1 ar2 ar3 ma1 ma2 ma3 intercept - -1.1785 -0.7573 0.149 0.5349 0.0277 -0.6598 -0.0004 -s.e. 0.0885 0.1204 0.082 0.0697 0.0783 0.0535 0.0437 - -sigma^2 estimated as 6.447: log likelihood = -844.67, aic = 1705.34 - -BIC(arima(y,c(3,0,3))) -[1] 1736.403 - -arima(y,c(3,0,4)) - -Call: -arima(x = y, order = c(3, 0, 4)) - -Coefficients: - ar1 ar2 ar3 ma1 ma2 ma3 ma4 intercept - -1.4545 -1.1237 -0.1197 0.8154 0.1995 -0.6283 -0.1763 -0.0002 -s.e. 0.4980 0.6653 0.4855 0.4915 0.3187 0.0883 0.2960 0.0441 - -sigma^2 estimated as 6.439: log likelihood = -844.45, aic = 1706.9 - -BIC(arima(y,c(3,0,4))) -[1] 1741.849 - -arima(y,c(3,0,5)) - -Call: -arima(x = y, order = c(3, 0, 5)) - -Coefficients: - ar1 ar2 ar3 ma1 ma2 ma3 ma4 ma5 intercept - -0.6644 -0.0717 0.6325 0.0146 -0.3762 -0.7089 0.3693 0.1299 0.0020 -s.e. 0.1913 0.2522 0.1849 0.1937 0.1311 0.0559 0.1305 0.0598 0.0521 - -sigma^2 estimated as 6.41: log likelihood = -843.66, aic = 1707.32 - -BIC(arima(y,c(3,0,5))) -[1] 1746.148 - diff --git "a/R\303\251sultats tests 4" "b/R\303\251sultats tests 4" deleted file mode 100644 index f810489..0000000 --- "a/R\303\251sultats tests 4" +++ /dev/null @@ -1,93 +0,0 @@ - -arima(y,c(4,0,0)) - -Call: -arima(x = y, order = c(4, 0, 0)) - -Coefficients: - ar1 ar2 ar3 ar4 intercept - -0.6503 -0.4084 -0.2861 -0.2791 0.0003 -s.e. 0.0507 0.0600 0.0603 0.0524 0.0518 - -sigma^2 estimated as 6.575: log likelihood = -847.81, aic = 1707.61 - - -BIC(arima(y,c(4,0,0))) -[1] 1730.914 - -arima(y,c(4,0,1)) - -Call: -arima(x = y, order = c(4, 0, 1)) - -Coefficients: - ar1 ar2 ar3 ar4 ma1 intercept - -0.5483 -0.3452 -0.2530 -0.2662 -0.1102 0.0002 -s.e. 0.2150 0.1429 0.0917 0.0616 0.2248 0.0501 - -sigma^2 estimated as 6.57: log likelihood = -847.68, aic = 1709.36 - -BIC(arima(y,c(4,0,1))) -[1] 1736.546 - -arima(y,c(4,0,2)) - -Call: -arima(x = y, order = c(4, 0, 2)) - -Coefficients: - ar1 ar2 ar3 ar4 ma1 ma2 intercept - -0.5648 -0.2700 -0.2078 -0.2461 -0.0960 -0.0930 0.0001 -s.e. 0.1923 0.1872 0.1218 0.0720 0.1971 0.1763 0.0481 - -sigma^2 estimated as 6.565: log likelihood = -847.55, aic = 1711.09 - -BIC(arima(y,c(4,0,2))) -[1] 1742.16 - -arima(y,c(4,0,3)) - -Call: -arima(x = y, order = c(4, 0, 3)) - -Coefficients: - ar1 ar2 ar3 ar4 ma1 ma2 ma3 intercept - -1.2009 -0.8536 0.0298 -0.0675 0.5620 0.0802 -0.6151 0.0001 -s.e. 0.0952 0.1665 0.1580 0.0761 0.0821 0.1004 0.0783 0.0447 - -sigma^2 estimated as 6.433: log likelihood = -844.28, aic = 1706.56 - -BIC(arima(y,c(4,0,3))) -[1] 1741.515 - -arima(y,c(4,0,4)) - -Call: -arima(x = y, order = c(4, 0, 4)) - -Coefficients: - ar1 ar2 ar3 ar4 ma1 ma2 ma3 ma4 intercept - -0.3842 0.0328 0.5362 -0.2668 -0.2559 -0.3023 -0.5701 0.5730 0.0025 -s.e. 0.1621 0.1710 0.1343 0.1000 0.1521 0.0879 0.0810 0.1116 0.0549 - -sigma^2 estimated as 6.383: log likelihood = -842.92, aic = 1705.84 - -BIC(arima(y,c(4,0,4))) -[1] 1744.676 - -arima(y,c(4,0,5)) - -Call: -arima(x = y, order = c(4, 0, 5)) - -Coefficients: - ar1 ar2 ar3 ar4 ma1 ma2 ma3 ma4 ma5 intercept - 0.2866 0.2587 0.3218 -0.9049 -1.0175 0.0135 -0.2064 1.1189 -0.5157 0.0011 -s.e. 0.0599 0.0756 0.0444 0.0337 0.0773 0.1352 0.1420 0.0912 0.0589 0.0489 - -sigma^2 estimated as 5.964: log likelihood = -833.61, aic = 1689.22 -Warning message: -In arima(y, c(4, 0, 5)) : possible convergence problem: optim gave code = 1 - -BIC(arima(y,c(4,0,5))) -[1] 1731.932 \ No newline at end of file diff --git a/main.r b/main.r index c2bcc7c..823842e 100644 --- a/main.r +++ b/main.r @@ -1,3 +1,5 @@ +# Partie 0 : prolégomènes # + # Installation de quelques paquets utiles install.packages("tseries") install.packages("fUnitRoots") @@ -28,7 +30,7 @@ print(serie_temporelle) ## Visualisation sous forme de graphe plot(serie_temporelle, xlab = "Mois", ylab = "Indice", main = "Indice de production de produits pharmaceutiques.") - +# Partie I # # Premières analyses ## Au début ça faisait de la grosse daube. @@ -52,8 +54,6 @@ plot( acf(log_serie_difference, main = "ACF de la log-différence première", 24) pacf(log_serie_difference, main = "PACF de la log-différence première", 24) -# C'est radical. Incroyable. - # Tests de (non-)stationnarité @@ -61,33 +61,53 @@ pacf(log_serie_difference, main = "PACF de la log-différence première", 24) adf_diff = adf.test(log_serie_difference, k = 7) print(adf_diff) - Augmented Dickey-Fuller Test - -data: log_serie_difference -Dickey-Fuller = -8.8632, Lag order = 7, p-value = 0.01 -alternative hypothesis: stationary - - ## Test de PP pp_diff = pp.test(log_serie_difference) print(pp_diff) - Phillips-Perron Unit Root Test - -data: log_serie_difference -Dickey-Fuller Z(alpha) = -444.6, Truncation lag parameter = 5, p-value = 0.01 -alternative hypothesis: stationary - ## Test de KPSS kpss_diff = kpss.test(log_serie_difference) print(kpss_diff) - KPSS Test for Level Stationarity +# Partie II # + +# Comparaison des différents modèles ARMA(p,q) +## Comme on a assez peu de modèles à tester, c'est aussi rapide de le faire à la main. +### On est pas des sauvages, on trie par ordre lexicographique. Inverse. Bref. + +arima(y, c(4,0,0)) +BIC(arima(y, c(4,0,0))) + +arima(y, c(3,0,0)) +BIC(arima(y, c(3,0,0))) + +arima(y, c(2,0,0)) +BIC(arima(y, c(2,0,0))) + +arima(y, c(1,0,0)) +BIC(arima(y, c(1,0,0))) + +arima(y, c(0,0,0)) +BIC(arima(y, c(0,0,0))) + + + +arima(y, c(4,0,1)) +BIC(arima(y, c(4,0,1))) + +arima(y, c(3,0,1)) +BIC(arima(y, c(3,0,1))) + +arima(y, c(2,0,1)) +BIC(arima(y, c(2,0,1))) + +arima(y, c(1,0,1)) +BIC(arima(y, c(1,0,1))) + +arima(y, c(0,0,1)) +BIC(arima(y, c(0,0,1))) -data: log_serie_difference -KPSS Level = 0.14375, Truncation lag parameter = 5, p-value = 0.1 -# <Série de tests ARIMA> on remplira plus tard hein # On a choisi notre candidat modele_arima = arima(log_serie_difference, c(0,0,1)) @@ -96,7 +116,7 @@ modele_arima = arima(log_serie_difference, c(0,0,1)) # Extraction des coefficients et des erreurs standard coefs <- coef(modele_arima) -se <- sqrt(diag(vcov(modele_arima))) # Erreurs standard +se <- sqrt(diag(vcov(modele_arima))) # Coefficient et erreur standard pour ma1 coefficient_ma1 <- coefs["ma1"] @@ -119,7 +139,7 @@ cat("P-value associée:", p_value, "\n") Statistique de test t: -16.83084 P-value associée: 1.45042e-63 -# Le test est violemment concluant, ma1 est non nul. +# Le test est fortement concluant, ma1 est non nul. # On tente un rapport de vraisemblance pour tester la non nullité jointe. # Calcul du modèle restreint avec les coefficients fixés à zéro @@ -139,8 +159,9 @@ Rapport de vraisemblance: 125.8787 > cat("P-value associée:", p_value_LR, "\n") P-value associée: 0 -# Bah c'est un peu la violence. +# La conclusion est sans appel. +# On teste aussi la non nullité de la constante. intercept_coef <- coefs["intercept"] se_intercept <- se["intercept"] @@ -152,39 +173,92 @@ cat("P-value associée:", p_value_intercept, "\n") P-value associée: 3.139217e-07 -# On passe à la blancheur -Box.test(modele_arima$residuals, type = "Ljung-Box") - - Box-Ljung test - -data: modele_arima$residuals -X-squared = 0.11608, df = 1, p-value = 0.7333 +# On passe à la blancheur, deux tests pour le prix d'un. +Box.test(modele_arima$residuals, type = "Ljung-Box") Box.test(modele_arima$residuals, type = "Box-Pierce") - Box-Pierce test -data: modele_arima$residuals -X-squared = 0.11511, df = 1, p-value = 0.7344 # Le QQplot pour voir à l'oeil la normalité qqnorm(modele_arima$residuals) qqline(modele_arima$residuals) -# Bah on dévie bien salement +# Queues lourdes, on s'apprête à rejeter. -# Et le test de normalité +# Et les tests de normalité shapiro.test(modele_arima$residuals) +jarque.bera.test(modele_arima$residuals) - Shapiro-Wilk normality test -data: modele_arima$residuals -W = 0.98192, p-value = 0.0001781 +# Prédiction des deux prochaines valeurs avec le modèle ARMA +predictions <- predict(modele_arima, n.ahead = 2) -# Un deuxième pour la route -jarque.bera.test(modele_arima$residuals) +# Sélectionnez les prédictions et les intervalles de confiance +valeurs_prédites <- predictions$pred +erreur_standard <- predictions$se + +intervalle_inf <- valeurs_prédites - qnorm(0.975) * erreur_standard +intervalle_sup <- valeurs_prédites + qnorm(0.975) * erreur_standard + + +plot( + log_serie_difference, + type = "l", + xlab = "Mois", + ylab = "Log-indices", + main = "Prédictions avec intervalles de confiance") + +lines( + c(length(log_serie_difference), dates_nouvelles), + c(dernieres_valeurs[2], valeurs_prédites), + col = "blue") + +lines( + c(dates_nouvelles[1], dates_nouvelles[1]), + c(intervalle_inf[1], intervalle_sup[1]), + col = "red") + +lines( + c(dates_nouvelles[2], dates_nouvelles[2]), + c(intervalle_inf[2], intervalle_sup[2]), + col = "red") + +polygon( + c(dates_nouvelles[1], rev(dates_nouvelles), dates_nouvelles[2]), + c(intervalle_inf[1], rev(intervalle_sup), intervalle_inf[2]), + col = rgb(0.8, 0.8, 0.8, 0.5), + border = NA) + +legend( + "topleft", + legend = c("Série connue", "Prédictions", "Intervalle de confiance"), + col = c("black", "blue", "red"), + lty = c(1, 1, NA), + pch = c(NA, NA, NA)) + + + + + + + + + +intervalles_confiance <- predictions$pred + cbind(-1, 1) * qnorm(0.975) * predictions$se + +# Créez un vecteur de dates pour les deux prochains points +dates_nouvelles <- seq(length(log_serie_difference) + 1, length(log_serie_difference) + 2) + +# Tracez la série connue et les prédictions +plot(log_serie_difference, type = "l", xlab = "Temps", ylab = "Valeurs", main = "Prédictions avec intervalles de confiance") +lines(c(length(log_serie_difference), dates_nouvelles), c(dernieres_valeurs[2], valeurs_prédites), col = "blue") + +# Ajoutez les intervalles de confiance +lines(c(dates_nouvelles[1], dates_nouvelles[1]), intervalles_confiance[1, ], col = "red") +lines(c(dates_nouvelles[2], dates_nouvelles[2]), intervalles_confiance[2, ], col = "red") +polygon(c(dates_nouvelles[1], rev(dates_nouvelles), dates_nouvelles[2]), c(intervalles_confiance[1, ], rev(intervalles_confiance[2, ])), col = rgb(0.8, 0.8, 0.8, 0.5), border = NA) - Jarque Bera Test +# Légende +legend("topright", legend = c("Série connue", "Prédictions", "Intervalle de confiance"), col = c("black", "blue", "red"), lty = c(1, 1, NA), pch = c(NA, NA, NA)) -data: modele_arima$residuals -X-squared = 30.806, df = 2, p-value = 2.045e-07 -- GitLab