Skip to content

Commit

Permalink
Merge pull request #9 from rkillick/v2.2.2
Browse files Browse the repository at this point in the history
V2.2.2
  • Loading branch information
rkillick authored Oct 4, 2016
2 parents 488f289 + e3959de commit 8c9c280
Show file tree
Hide file tree
Showing 28 changed files with 796 additions and 144 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ language: r
sudo: required
warnings_are_errors: true
r_check_revdep: false
r:
- 3.1
- oldrel
- release
- devel
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: changepoint
Type: Package
Title: Methods for Changepoint Detection
Version: 2.2.1
Date: 2016-02-26
Version: 2.2.2
Date: 2016-10-04
Authors@R: c(person("Rebecca", "Killick",
role=c("aut","cre"),email="[email protected]"),
person("Kaylea", "Haynes", role="aut"),
Expand All @@ -12,8 +12,8 @@ Maintainer: Rebecca Killick <[email protected]>
BugReports: <[email protected]>
URL: https://github.com/rkillick/changepoint/
Description: Implements various mainstream and specialised changepoint methods for finding single and multiple changepoints within data. Many popular non-parametric and frequentist methods are included. The cpt.mean(), cpt.var(), cpt.meanvar() functions should be your first point of call.
Depends: R(>= 3.0), methods, stats, zoo(>= 0.9-1)
Depends: R(>= 3.1), methods, stats, zoo(>= 0.9-1)
Suggests: testthat
License: GPL
LazyLoad: yes
Packaged: 2016-02-26 12:36:29 UTC; killick
Packaged: 2016-10-04 12:36:29 UTC; killick
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import(zoo)
import(stats)

export("cpt.mean", "cpt.meanvar", "cpt.var")
export("BINSEG", "decision", "penalty_decision","PELT","class_input")
exportClasses(cpt,cpt.reg,cpt.range)
exportMethods(plot,summary,show,nseg,logLik,likelihood,data.set,data.set.ts,cpts,cpts.full, cpts.ts,cpttype,distribution,test.stat,
method,ncpts,ncpts.max,param.est,param, coef,pen.type,pen.value,pen.value.full, minseglen, seg.len,"cpts<-","cpttype<-","data.set<-","distribution<-","test.stat<-","ncpts.max<-","param.est<-","pen.type<-",
Expand Down
16 changes: 16 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
Version 2.2.2
=============
* Updated R dependency, thanks to Mateusz Konieczny to identifying the problem (and solution).
* Updated all functions with minseglen arguments to error when minseglen is set too large for a change to be included in the data, e.g. n=14, minseglen=10. Thanks to Simon Taylor for spotting this bug.
* minseglen added to nonparametric Binary Segmentation functions.
* Initialization of candidate log-likelihood values in C is set to -Inf instead of 0.
* Fixed bug whereby if a non-MBIC penalty was use with SegNeigh it errored saying "MBIC not implemented for SegNeigh" this was supposed to be displaying for MBIC penalty only. Thanks to Craig Wenger for spotting this.
* Fixed bug whereby the AMOC method with Gamma, Exponential or Poisson test statistic was returning the position of the change in a vector of potential changes rather than the actual changepoint location. This did not affect methods other than AMOC.
* Changed cpt.meanvar so that if test.stat="Poisson" or test.stat="Exponential" you can have a minseglen=1 (previously minimum was 2). Thanks to Craig Wenger for the suggestion.
* Minor changes to PELT and BinSeg functions in preparation for user defined cost functions (coming soon).
* We now export the BINSEG, PELT, decision, penalty_decision and class_input functions. This is to allow other packages to make use of these functions (previously these were replicated in other packages). They are NOT designed for general use, they are for developer use only.
* added acf generic which returns the acf for each segment.
* changed logLik to return -2*log-likelihood of the models, previously this was a scaled version.
* changed the prototype of the cpt class to include a default of "Not Set" for cpttype.
* change y axis on plot(.,diagnostic=TRUE) to be labelled "Penalty Value", previously it was incorrectly labelled "Difference in Test Statistic".

Version 2.2.1
=============
* Fixed a minor bug where additional arguments to the plot function when diagnostic=TRUE were not passed through to the plot.
Expand Down
4 changes: 2 additions & 2 deletions R/PELT_one_func_minseglen.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PELT = function(sumstat,pen=0, cost_func = "norm.mean", shape = 1, minseglen = 1){
# function that uses the PELT method to calculate changes in mean where the segments in the data are assumed to be Normal
n = length(sumstat)/3 - 1
n = length(sumstat[,1]) - 1
if(n<2){stop('Data must have atleast 2 observations to fit a changepoint model.')}

storage.mode(sumstat) = 'double'
Expand All @@ -27,6 +27,6 @@ PELT = function(sumstat,pen=0, cost_func = "norm.mean", shape = 1, minseglen = 1
if(answer[[6]]>0){
stop("C code error:",answer[[6]],call.=F)
}
return(list(answer[[10]],sort(answer[[5]][answer[[5]]>0]), answer[[9]], answer[[11]]))
return(list(lastchangecpts=answer[[10]],cpts=sort(answer[[5]][answer[[5]]>0]), lastchangelike=answer[[9]], ncpts=answer[[11]]))

}
5 changes: 4 additions & 1 deletion R/cpt.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ cpt.var=function(data,penalty="MBIC",pen.value=0,know.mean=FALSE, mu=NA,method="
cpt.meanvar=function(data,penalty="MBIC",pen.value=0,method="AMOC",Q=5,test.stat="Normal",class=TRUE,param.estimates=TRUE,shape=1,minseglen=2){
checkData(data)
if(method=="SegNeigh" & minseglen>2){stop("minseglen not yet implemented for SegNeigh method, use PELT instead.")}
if(minseglen<2){minseglen=2;warning('Minimum segment length for a change in mean and variance is 2, automatically changed to be 2.')}
if(minseglen<2){
if(!(minseglen==1 & (test.stat=="Poisson"|test.stat=="Exponential"))){
minseglen=2;warning('Minimum segment length for a change in mean and variance is 2, automatically changed to be 2.')}
}
if(penalty == "CROPS"){
if(is.numeric(pen.value)){
if(length(pen.value) == 2){
Expand Down
Loading

0 comments on commit 8c9c280

Please sign in to comment.