← 返回GBD分析主页

年龄周期队列模型 (APC)

分离年龄效应、时期效应和队列效应,揭示疾病风险的时间变化规律

方法说明

APC 模型将疾病率变化分解为三个维度:

  • 年龄效应 (Age Effect):不同年龄组的疾病风险差异
  • 时期效应 (Period Effect):特定时期对所有年龄组的共同影响(如政策、医疗技术)
  • 队列效应 (Cohort Effect):不同出生年代人群的独特风险模式

适用场景:肿瘤流行病学、慢性病趋势分析、出生队列研究

代码实现

1. APC 模型实现(glm 方法)

R 代码:基础 APC 模型
library(dplyr)
library(data.table) # 读取数据
# 需要:age, period (year), cohort (derived), cases, population
df <- fread("examples/apc_input.csv") # 计算发病/患病率
df[, rate := cases / population * 100000] # 创建队列(cohort = period - age)
# 假设 age 以年为单位,需要转换为数值
df[, age_num := as.numeric(gsub(" years", "", age))]
df[, cohort := period - age_num] # 标准化变量(避免共线性)
df[, age_c := scale(age_num)]
df[, period_c := scale(period)]
df[, cohort_c := scale(cohort)] # APC 模型(使用对数链接)
# 方式1:glm with offset
model_apc <- glm(cases ~ age_c + period_c + cohort_c + offset(log(population)), family = poisson, data = df) summary(model_apc) # 提取系数
coef_age <- coef(model_apc)["age_c"]
coef_period <- coef(model_apc)["period_c"]
coef_cohort <- coef(model_apc)["cohort_c"] cat("Age effect:", coef_age, "\n")
cat("Period effect:", coef_period, "\n")
cat("Cohort effect:", coef_cohort, "\n")

2. 年龄-时期-队列图

R 代码:绘制 APC 图
library(ggplot2) # 1. 年龄效应图
age_effect <- df[, .(rate = mean(rate)), by = .(age)]
p_age <- ggplot(age_effect, aes(x = age, y = rate)) + geom_line(group = 1) + geom_point + labs(x = "Age Group", y = "Disease Rate") + theme(axis.text.x = element_text(angle = 45, hjust = 1)) # 2. 时期效应图
period_effect <- df[, .(rate = mean(rate)), by = .(period)]
p_period <- ggplot(period_effect, aes(x = period, y = rate)) + geom_line(group = 1) + geom_point + labs(x = "Year (Period)", y = "Disease Rate") # 3. 队列效应图
cohort_effect <- df[, .(rate = mean(rate)), by = .(cohort)]
p_cohort <- ggplot(cohort_effect, aes(x = cohort, y = rate)) + geom_line(group = 1) + geom_point + labs(x = "Birth Cohort", y = "Disease Rate") # 合并图形
library(ggpubr)
p_combined <- ggarrange(p_age, p_period, p_cohort, ncol = 3, labels = c("Age", "Period", "Cohort"))
p_combined # 保存
ggsave("examples/apc_effects.png", p_combined, width = 15, height = 5)

3. 使用 BAPC 包(贝叶斯 APC)

R 代码:贝叶斯 APC 模型
# 安装并加载 BAPC 包
# install.packages("bapred")
library(bapred) # 准备数据格式
# 需要:age group, time period, number of cases, population
df_bapc <- df[, .(agegroup = age, period = period, cases = cases, n = population)] # 运行 BAPC
bAPC_result <- bapc(df_bapc) # 提取结果
bAPC_trends <- bAPC_result$trend # 绘制
plot(bAPC_result) # 提取各效应
age_eff <- bAPC_result$alpha # 年龄效应
period_eff <- bAPC_result$beta # 时期效应
cohort_eff <- bAPC_result$gamma # 队列效应 # 保存结果
write.csv(age_eff, "examples/bapc_age_effect.csv")
write.csv(period_eff, "examples/bapc_period_effect.csv")
write.csv(cohort_eff, "examples/bapc_cohort_effect.csv")

常见问题

Q1: 年龄和队列完全共线性怎么办?

→ 使用约束(如 age + period + cohort = 0)或贝叶斯方法解决。

Q2: 队列如何计算?

→ 队列 = 时期 - 年龄(如 2021年50岁的人出生于1971年)

相关模块