楼主: lauk201712
1292 11

[问答] python 与 matlab 结果不一致 [推广有奖]

  • 0关注
  • 0粉丝

硕士生

21%

还不是VIP/贵宾

-

威望
0
论坛币
125 个
通用积分
1.6056
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
1965 点
帖子
52
精华
0
在线时间
107 小时
注册时间
2018-1-24
最后登录
2024-4-5

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
同样一组数据,进行adftest时p值一个是.001,另一个是.06。怎么相差这么大啊,平稳与不平稳啊,咋回事啊请教下各位???
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:MATLAB python matla atlab Lab

沙发
shadowaver 在职认证  发表于 2023-5-31 10:30:25 |只看作者 |坛友微信交流群
数据有经过标准化处理嘛

使用道具

藤椅
Andillas 发表于 2023-5-31 22:09:16 |只看作者 |坛友微信交流群
和算法有关系吧,做这个是不是stata的用的多

使用道具

板凳
lauk201712 发表于 2023-6-5 12:47:21 |只看作者 |坛友微信交流群
shadowaver 发表于 2023-5-31 10:30
数据有经过标准化处理嘛
标准化过后的,p值跟MATLAB相差太大了,100倍啊,可能吗?!

使用道具

报纸
shadowaver 在职认证  发表于 2023-6-5 15:16:56 |只看作者 |坛友微信交流群
lauk201712 发表于 2023-6-5 12:47
标准化过后的,p值跟MATLAB相差太大了,100倍啊,可能吗?!
如果差距这么大,那两个软件的检验指标应该不一样

使用道具

地板
shadowaver 在职认证  发表于 2023-6-5 15:19:26 |只看作者 |坛友微信交流群
adftest ,两边都做的是自相关性检验嘛,除了标准化以外,差分和滞后阶数也会影响到p值

使用道具

7
lauk201712 发表于 2023-6-5 19:48:56 |只看作者 |坛友微信交流群
shadowaver 发表于 2023-6-5 15:19
adftest ,两边都做的是自相关性检验嘛,除了标准化以外,差分和滞后阶数也会影响到p值
同一组数据,滞后阶都设置过的,就是残差的单位根检验相差这么大的,回归方法都一样的

使用道具

8
hifinecon 发表于 2023-6-5 23:16:10 |只看作者 |坛友微信交流群
Differences in p-value results from an Augmented Dickey-Fuller (ADF) test between Python and MATLAB could arise from several factors:
1.        Implementation Differences: Python's statsmodels and MATLAB's adftest might use slightly different algorithms or criteria for the ADF test.
2.        Test Assumptions: The ADF test in both Python and MATLAB make assumptions about the data and the test, including assumptions about the presence of a unit root, the presence of a drift term or a deterministic time trend, and so forth. If the assumptions are not met, it can lead to different results.
3.        Different Levels of Significance: Python and MATLAB may use different levels of significance, which could lead to different p-value interpretations.
4.        Sample Size: The number of observations used for the test can significantly impact the p-value. Ensure that both Python and MATLAB are working with the same dataset size.
5.        Lag Length Selection: The choice of maximum lags in the ADF regression could be different in Python and MATLAB, causing differences in the outcome.
6.        Data Preprocessing: Ensure that your data preprocessing steps are the same across both platforms.
If you're getting significantly different p-values, I'd recommend reviewing the test parameters and the implementation details in both Python and MATLAB, ensuring that you're comparing like-for-like in terms of data, assumptions, and the statistical test itself. If the differences persist, it might be helpful to seek advice from a statistician or someone familiar with the specific nuances of these testing methods in Python and MATLAB.

使用道具

9
hifinecon 发表于 2023-6-5 23:22:01 |只看作者 |坛友微信交流群
一个可能的原因是你在两次测试中使用的统计软件、模型设定、数据处理方法等不同,导致结果有显著差异。下面是几个可能的解决方案:
1.        确认你的软件版本和实现方法是否一致:不同的统计软件可能使用稍微不同的算法来进行ADF测试,可能会导致结果的不同。
2.        检查你的模型设定:ADF检验的设定可能包括有无趋势项、有无截距项等,不同的设定可能导致检验结果的不同。如果你在一个软件中设置了有趋势项,在另一个软件中没有设置,那么结果就可能会不同。
3.        检查你的滞后阶数选择:在进行ADF检验时,我们需要选择一个滞后阶数。不同的滞后阶数可能会导致不同的检验结果。你需要确认在两次测试中使用的滞后阶数是否一致。
4.        确认你的数据预处理方法是否一致:如果你在进行ADF检验前对数据进行了预处理(比如对数变换、差分等),你需要确认在两次测试中使用的预处理方法是否一致。
如果你确认了以上所有设定都是一致的,但是结果仍然不同,那么可能需要进一步查看软件的具体实现细节,或者寻求更专业的帮助。同时,你也需要记住,ADF检验只是检验时间序列平稳性的一种方法,存在一定的局限性。在进行统计分析时,我们应当综合考虑各种信息,而不是完全依赖单一的检验结果。

使用道具

10
lauk201712 发表于 2023-6-6 11:06:41 |只看作者 |坛友微信交流群
hifinecon 发表于 2023-6-5 23:22
一个可能的原因是你在两次测试中使用的统计软件、模型设定、数据处理方法等不同,导致结果有显著差异。下面 ...
肯定都一致的,之前在网上就看到有人说R跟MATLAB单位根有不同结果,至于算法方面,那只有看开发人员的源码了。PS·有人吐槽过scipy的积分算法也有问题

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-28 02:16