在用于模型比较的众多标准/统计数据中,AIC 和 BIC 是最受欢迎的。以下是 wiki 页面 (https://en.wikipedia.org/wiki/Akaike_information_criterion) 的摘录:
Akaike 信息准则 (AIC) 是预测的估计量
误差,从而给定统计模型的相对质量
数据集。给定数据模型的集合,AIC
估计每个模型相对于其他模型的质量
楷模。因此,AIC 提供了一种模型选择方法。
在 R 中,通用函数 AIC() 可用于计算 AIC。 (请参阅 wiki 页面中关于计算具有不同功能的 AIC 的软件不可靠性的注释,您的代码并非如此,因为这两个模型都是通过 lm 安装的)。 AIC 越小,模型越好。 〜2.0或类似的差异通常用作确定实际意义的阈值。您的简单模型的 AIC 值远大于中断模型(663.6993 与 380.8516 的差异 >>2.0);有压倒性的证据表明,中断模型更受欢迎。这并不奇怪,因为许多结构变化检测包通过优化 AIC 或 BIC 来精确寻找最可能的中断数量和位置。
set.seed(42)
sim_data = data.frame(outcome = c(rnorm(30, 10, 1), rnorm(50, 20, 2), rnorm(20, 45, 1)))
sim_ts = ts(data = sim_data, start = c(2010, 1), frequency = 12)
plot(sim_ts)
library("strucchange")
break_points = breakpoints(sim_ts ~ 1) #2 breakpoints at 30 and 80
break_factor = breakfactor(break_points, breaks = 2)
break_model = lm(sim_ts ~ break_factor - 1)
simple_lm = lm(sim_ts ~ time(sim_ts))
AIC(simple_lm) #663.6993
AIC(break_model) #380.8516
或者,经常使用基于贝叶斯的标准。为了自我推销,我演示了使用后验模型可能性来比较使用我开发的 R 包Rbeast 的替代模型:
set.seed(42)
sim_data = data.frame(outcome = c(rnorm(30, 10, 1), rnorm(50, 20, 2), rnorm(20, 45, 1)))
library(Rbeast)
break_model = beast( sim_data$outcome, season='none')
simple_model = beast( sim_data$outcome, season='none', tcp.minmax=c(0,0) )
plot(break_model)
plot(simple_model)
# Due to the Bayesian nature, the exact log-lik numbers will vary to some extent across runs.
break_model$marg_lik # posterior log-lik: -2.467201
simple_model$marg_lik # posterior log-lik: -137.2492
代码的一些解释:sim_data$outcome是正则时间序列。 Rbeast 同时进行时间序列分解(如果存在周期性/季节性分量)和断点/变化点检测。您的样本数据没有季节性成分,因此设置了 season='none'。断点模型识别两个断点,以及断点随时间的估计概率(峰值概率对应于两个断点)。
为了拟合没有断点的模型,我们通过将断点的最小数量和最大数量都设置为零来强制执行强先验:tcp.minmax=c(0,0)。这样,一个全局线性模型就被拟合了。
每个模型规范的后边际对数似然在输出 break_model$marg_lik 和 break_model$marg_lik 中给出。显然,marg lik 越大,模型越好。与 AIC 或 BIC 类似,1~2.0 的差异通常表明模型之间具有实际意义。