R strchange中的断点时间序列模型的模型比较 [英] Model comparison for breakpoint time series model in R strucchange
问题描述
我要测试时间序列是否包含结构性变化.
I want to test whether a time series contains structural changes or not.
使用此模拟示例创建了一个序列,该序列在进行30和80次观察后有两个中断.
Using this simulated example creates a series with two breaks after 30 and 80 observations.
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)
我使用 strucchange R软件包来确定数量(如果有)的断点并对其建模:
I use the strucchange R package to determine the number (if any) of break points and model these:
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)
...,然后将具有2个结构变化点的拟合模型放在原始时间序列的顶部:
... and put the fitted model with 2 structural change points on top of the raw time series:
lines(fitted(break_points, breaks = 2), col = 4)
我感兴趣的是:如何测试具有结构变化的模型是否比简单的线性模型更合适?
What I'm interested in is: how can I test whether the model with structural changes fits better than a simple linear model?
simple_lm = lm(sim_ts ~ time(sim_ts))
abline(simple_lm, col='red') #to add the linear line to the plot
模型比较是否只是:anova(simple_lm, break_model)
?
我是否首先需要对平稳性进行初步测试?还是模型比较包含了这一点?
And wouldn't I need an initial test for stationarity first? Or is this subsumed by the model comparison?
推荐答案
预测文献中评估良好拟合的正常"方法是使用损失函数(MSE).因为您没有进行预测,所以最简单的方法可能只是比较R². (如果您关心的是一个很好的选择)
The "normal" way in the forecasting literature to evaluate a good fit is the use of a loss function (MSE). Because you are not forecasting maybe the easiest way is to just compare R². (If all you care about is a good fit)
方差分析方法需要假设独立于观察者,所以我不知道是否有可能的陷阱.即使它在这里似乎可行.
The Anova Method needs the asumption of independence of observervations, so I´m not sure if there is a possible pitfall. Even though it seems to work here.
这篇关于R strchange中的断点时间序列模型的模型比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!