Learn R Programming

cpop (version 1.0.8)

cost: Calculate the cost of a model fitted by cpop

Description

Calculate the penalised cost of a model fitted by cpop using the residual sum of squares and the penalty values.

Value

Numerical value of the penalised cost associated with the segmentations determined by using cpop

Arguments

object

An instance of an S4 class produced by cpop.

References

cpop-jss-article-2024cpop

Examples

Run this code
library(cpop)

# simulate data with change in gradient
set.seed(1)
x <- (1:50/5)^2
y <- simchangeslope(x,changepoints=c(10,50),change.slope=c(0.25,-0.25),sd=1)

# determine changepoints
res <- cpop(y,x,beta=2*log(length(y)))

# calculate the penalised cost 
cost(res)

Run the code above in your browser using DataLab