第100+9步 ChatGPT文献复现:ARIMA预测百日咳

基于WIN10的64位系统演示

一、写在前面

我们来继续换一篇文章来学习学习:

《BMC Public Health》杂志的2022年一篇题目为《ARIMA and ARIMA-ERNN models for prediction of pertussis incidence in mainland China from 2004 to 2021》文章的模拟数据做案例。

这文章做的是用:使用单纯ARIMA模型和ARIMA-ERNN组合模型预测中国大陆百日咳发病率。

文章是用单纯的ARIMA模型作为对照,更新了ARIMA-ERNN模型。本期,我们先来尝试ARIMA模型。

数据不是原始数据哈,是我使用GPT-4根据文章的散点图提取出来近似数据,只弄到了2004-2017年的。

二、闲聊和复现:

1 数据基本描述

没啥好说的,就是最最基本的描述统计。

要是有原始数据,直接可以让GPT-4帮分析。

(2)季节拆分

之前介绍过了哈,使用SPSS也可以实现,文章使用的是R语言:

①首先,使用GPT-4生成:

咒语:

直接输出结果:

注意哈,我的数据是模拟数据,且只到2017年12月,所以乍一看跟文章的略有偏差。

GPT给出的代码(Python)供参考:

python 复制代码
import pandas as pd
from statsmodels.tsa.seasonal import STL
import matplotlib.pyplot as plt

# Load the data from the CSV file
data = pd.read_csv('/mnt/data/数据.csv')

# Convert the 'time' column to datetime to facilitate resampling by year
data['time'] = pd.to_datetime(data['time'], format='%b-%y')

# Set the time column as index and set frequency to month start
data.set_index('time', inplace=True)
data.index.freq = 'MS'

# Prepare the data for STL decomposition by ensuring it has a frequency (monthly data)
# Apply STL decomposition with a seasonal period of 13 (adjusted as needed)
stl = STL(data['incidence'], seasonal=13)
result = stl.fit()

# Plotting the results of the STL decomposition
plt.figure(figsize=(12, 8))

# Original data plot
plt.subplot(4, 1, 1)
plt.plot(result.observed)
plt.title('Original Data')

# Seasonal component plot
plt.subplot(4, 1, 2)
plt.plot(result.seasonal)
plt.title('Seasonal Component')

# Trend component plot
plt.subplot(4, 1, 3)
plt.plot(result.trend)
plt.title('Trend Component')

# Residual plot
plt.subplot(4, 1, 4)
plt.plot(result.resid)
plt.title('Residual')

# Adjust layout and save the figure to a file
plt.tight_layout()
plt.savefig('/mnt/data/STL_Decomposition_Corrected.png')

plt.show()

②首先,使用SPSS生成:

步骤我在简单过一下,大家巩固记忆:

看结果:

(2)构建ARIMA模型

文章使用的是SAS建模,那我就用JMP展示(传送门):

看到季节性和总体上升趋势,直接无脑d和D取1,然后p、q、P、Q取值0、1、2、3即可:

结果最优模型如下:

ARIMA(3,1,3)(3,1,2)12:拟合的MAPE为27%,预测的MAPE为18%,比文章的高一些,不过基本处于一个数量级水平。

不用纠结为啥ARIMA参数不同,实验条件都不一样。

三、 后话

到目前为止,大家应该熟练掌握单纯ARIMA模型了吧。

四、 数据

不提供,自行根据下图提取吧****。****

实在没有GPT-4,那就这个:

https://apps.automeris.io/wpd/index.zh_CN.html

相关推荐
BFT白芙堂14 分钟前
睿尔曼系列机器人——以创新驱动未来,重塑智能协作新生态(上)
人工智能·机器学习·机器人·协作机器人·复合机器人·睿尔曼机器人
aneasystone本尊20 分钟前
使用 MCP 让 Claude Code 集成外部工具
人工智能
静心问道30 分钟前
SEW:无监督预训练在语音识别中的性能-效率权衡
人工智能·语音识别
xwz小王子36 分钟前
从LLM到WM:大语言模型如何进化成具身世界模型?
人工智能·语言模型·自然语言处理
我爱一条柴ya37 分钟前
【AI大模型】深入理解 Transformer 架构:自然语言处理的革命引擎
人工智能·ai·ai作画·ai编程·ai写作
静心问道38 分钟前
FLAN-T5:规模化指令微调的语言模型
人工智能·语言模型·自然语言处理
李师兄说大模型38 分钟前
KDD 2025 | 地理定位中的群体智能:一个多智能体大型视觉语言模型协同框架
人工智能·深度学习·机器学习·语言模型·自然语言处理·大模型·deepseek
静心问道39 分钟前
SqueezeBERT:计算机视觉能为自然语言处理在高效神经网络方面带来哪些启示?
人工智能·计算机视觉·自然语言处理
Sherlock Ma40 分钟前
百度开源文心一言4.5:论文解读和使用入门
人工智能·百度·自然语言处理·开源·大模型·文心一言·多模态
weisian1511 小时前
人工智能-基础篇-18-什么是RAG(检索增强生成:知识库+向量化技术+大语言模型LLM整合的技术框架)
人工智能·语言模型·自然语言处理