开发者

How to set the tolerance identifying changes in Variance?

开发者 https://www.devze.com 2023-03-31 11:54 出处:网络
I\'m using a very good R package named \"changepoint\" to detect changes in the variance in my series.

I'm using a very good R package named "changepoint" to detect changes in the variance in my series.

At the moment i'm using cpt.var function, it is very powerful to d开发者_JS百科etect changes BUT I would like to have a more tolerance method.

cpt.var(mod$residuals)

where mod is a linear regression:

mod <- lm(priceA ~ priceB)


If you look at the help file for ?cpt.var you can change the penalty argument from the default SIC to Manual. When using the Manual, you can specify a type I error value through the value argument.

Here is an example based on the help file:

# Example of multiple changes in variance at 50,100,150 in simulated data
set.seed(1)
x = c(rnorm(50,0,1), rnorm(50,0,10), rnorm(50,0,5), rnorm(50,0,1))

##Key arguments Manual and value
##Returns 4 changes points
cpt.var(x, penalty="Manual", value="log(2*log(n))", method="BinSeg", 
        dist="CSS", Q=5, class=FALSE) 

##Returns 5 changes points - a false positive
cpt.var(x, penalty="Manual", value="0.5*log(2*log(n))", method="BinSeg", 
        dist="CSS", Q=5, class=FALSE) 
0

精彩评论

暂无评论...
验证码 换一张
取 消