【问题标题】:Breakpoints and F statistics in strucchange packagestrucchange 包中的断点和 F 统计信息
【发布时间】:2016-09-22 03:01:47
【问题描述】:

据我所知,断点应该对应于最大化 F 统计数据的观察,但我看不出 F 统计数据与中断时间之间有任何有意义的关联。我怎么了?

y <- c(rnorm(30), 2+rnorm(20))  # 1 breakpoint
f <- Fstats(y ~ 1)               # calculate F statistics
f$breakpoint                     # breakpoint Fstats suggests
which(f$Fstats == max(f$Fstats)) # observation with max F statistics
order(f$Fstats)                  # observations ordered by F statistics

可以看出,断点的观察并不是F统计量最高的观察。

【问题讨论】:

    标签: r breakpoints


    【解决方案1】:

    您的 y 不是类 ts。所以输出变得有点好奇 ts 数据,不幸的是你没有解释它。

    set.seed(1)
    y <- c(rnorm(30), 2+rnorm(20))
    ts.y <- ts(y, start = 1, frequency = 1)  # change `y` into class `ts`
    
    ts.f <- Fstats(ts.y ~ 1)
    
    ts.f$breakpoint  # [1] 30
    ts.f$Fstats
     # Time Series:
     # Start = 7       # this means ts.f$Fstats[1] is 7th
    which(ts.f$Fstats == max(ts.f$Fstats)) # [1] 24  # ts.f$Fstats[24] is 30th
    
    plot(ts.f)
    lines(breakpoints(ts.f))
    

    【讨论】:

    • 非常感谢,我明白了!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-09
    • 2012-07-12
    • 1970-01-01
    • 2019-12-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多