rkillick / EnvCpt

A place for the development version of the changepoint package on CRAN. The master thread is that from CRAN.
5 stars 14 forks source link

Penalise changepoints more #10

Closed multimeric closed 3 years ago

multimeric commented 3 years ago

Hi, thanks for writing this package.

I'm finding that EnvCpt finds a few more changepoints than I believe are actually present, so I'd like to penalise them a bit more. From looking at the documentation and source code it seems that envcpt passes all its ... args into cpt.reg (I'm looking at a regression changepoint model). However, even if I do envcpt(my_vector, pen.value=999999), don't notice any change in the resulting changepoints. Is there another way I'm supposed to do this?

Also, I think it would be helpful if pen.value were included in the manual for envcpt, since the function that it refers to (cpt.meanvar) is not exported.

Thanks.

multimeric commented 3 years ago

I now realise from looking at the manual file, that this is referring to the changepoint::cpt.meanvar. This cross-package reference doesn't show up in the PDF manual which is why I was confused. From looking at the changepoint manual it seems that I would first have to set penalty="manual", and then pen.value would work.

rkillick commented 3 years ago

Nope, your original inclination was correct. We haven't passed the pen.value argument to the cpt.reg function and have hard coded as MBIC penalty. I'll add this to the "enhancement" list but with the current backlog of work due to the pandemic I doubt I'll get to it before the end of the summer. I'd certainly welcome a pull request if you have time/inclination.

multimeric commented 3 years ago

I think it does seem to work, though:

data = c(1:100, 100:1, 1:100) + rnorm(300, sd = 5)
fit = EnvCpt::envcpt(data, models="trendcpt", penalty="Manual", pen.value=10)
plot(fit, colors = rep.int('red', 12))

image

versus

fit = EnvCpt::envcpt(data, models="trendcpt", penalty="Manual", pen.value=100)
plot(fit, colors = rep.int('red', 12))

image

rkillick commented 3 years ago

Ah yes, my past self must have changed this! This pandemic has ruined my memory of distinguishing what I intended to do and what I actually did! Thanks for trying it and seeing that it worked, saved me a job.