Skip to content

Commit

Permalink
Fixed resid cpt.reg error
Browse files Browse the repository at this point in the history
Updated plot(cpt.range) diagnostic description.
  • Loading branch information
rkillick committed Oct 17, 2024
1 parent 2824e0b commit 6fa5ec0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/cpt.class.R
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ setClass("cpt",slots=list(data.set="ts", cpttype="character", method="character"
return(data.set(object)-fitted(object))
})
setMethod("residuals","cpt.reg",function(object){
return(data.set(object)-fitted(object))
return(data.set(object)[,1]-fitted(object))
})
setMethod("residuals","cpt.range",function(object,ncpts=NA){
return(data.set(object)-fitted(object,ncpts))
Expand Down
2 changes: 1 addition & 1 deletion man/plot-methods.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
As for the \code{cpt} objects except for two optional arguments, \code{ncpts} and \code{diagnostic}. The \code{ncpts} option allows you to specify a plot of the segmentation with \code{ncpts} changepoints in, i.e. the optimal may be specified as 10 changes but you want to plot the segmentation with 5 changes (provided a segmentation with 5 changes is listed in \code{cpts.full(x)}. The \code{diagnostic} option when set to \code{TRUE} plots the number of changepoints in each segmentation against the penalty values that give that number of changepoints. This can aide the decision on the number of changepoints as when a true changepoint is added the cost decreases considerably so it creates a stable region where several penalty values give the same number of changepoints, but when a changepoint due to noise is added the change in cost is small and so a small change in penalty value can vary the number of changes a lot. This is akin to a scree plot in principal component analysis. The idea is that someone may choose to create a plot using \code{diagnostic=TRUE}, identify the appropriate number of changes and then replot using \code{ncpts} to visualize that segmentation.
}
\item{\code{signature(x = "cpt.reg")}}{
Plots the combined regressors against the response and identifies the changepoints using vertical lines. Optional arguments to control the lines: \code{cpt.col} equivilent to \code{col} to change the colour of the changepoint line; \code{cpt.width} equivilent to \code{lwd} to change the width of the changepoint line; \code{cpt.style} equivilent to \code{lty} to change the style of the line.
Plots the combined regressors (model fit) against the response and identifies the changepoints using vertical lines. Optional arguments to control the lines: \code{cpt.col} equivilent to \code{col} to change the colour of the changepoint line; \code{cpt.width} equivilent to \code{lwd} to change the width of the changepoint line; \code{cpt.style} equivilent to \code{lty} to change the style of the line.
}

}}
Expand Down

0 comments on commit 6fa5ec0

Please sign in to comment.