如何纠正efp()错误“变量'数据'的无效类型(列表)”?

时间:2022-02-26 22:30:08

I have a large(>100,000) single column floating point time-series data. I want to find structural changes within the data with respect to time( in my case index). In-order to do that, I am using R strucchange package. But I'm getting error. I expect to generate the following kind of plot with my dataset 如何纠正efp()错误“变量'数据'的无效类型(列表)”?

我有一个大的(> 100,000)单列浮点时间序列数据。我想在数据中找到与时间相关的结构变化(在我的案例索引中)。为了做到这一点,我使用R strucchange包。但是我收到了错误。我希望用我的数据集生成以下类型的绘图

Here is the code which I'm using:

这是我正在使用的代码:

data = read.csv("tst1.csv", header = FALSE)
library(strucchange)

## fit, visualize and test OLS-based CUSUM test
## with a Cramer-von Mises functional
ocus <- efp(data ~ 1, type = "OLS-CUSUM")
sctest(ocus, functional = "meanL2")

## estimate breakpoints
bp <- breakpoints(data ~1)
summary(bp)

plot.ts(data)
lines(bp)
lines(fitted(bp, type = "mean"), col = 2)

I'm getting following error messages:

我收到以下错误消息:

Loading required package: zoo

Attaching package: ‘zoo’

The following objects are masked from ‘package:base’:

as.Date, as.Date.numeric

Loading required package: sandwich
Error in model.frame.default(formula, data = data) : 
invalid type (list) for variable 'data'
Calls: efp -> model.frame -> model.frame.default
Execution halted

My data tst1.csv looks like:

我的数据tst1.csv看起来像:

0.6
0.78
0.54
0.96
0.43
1.43
1.03
0.83
0.68
3.23
3.09
2.87
...

Any help is much more appreciated.

任何帮助都非常感激。

Thanks

谢谢

1 个解决方案

#1


1  

That is because data is a data frame. In order to put it in the formula correctly, try this:

那是因为数据是数据帧。为了正确地把它放在公式中,试试这个:

ocus <- efp(V1 ~ 1, data=data,type = "OLS-CUSUM")

#1


1  

That is because data is a data frame. In order to put it in the formula correctly, try this:

那是因为数据是数据帧。为了正确地把它放在公式中,试试这个:

ocus <- efp(V1 ~ 1, data=data,type = "OLS-CUSUM")