Uses the changepoint package to detect change points in the mean of a numeric vector and assigns group IDs accordingly.
Arguments
- x
Numeric vector.
Value
An integer vector of the same length as x, where each element indicates the group assignment based on detected change points.
Details
Uses cpt.mean from the changepoint package with the PELT method and MBIC penalty to detect change points in the mean.
Examples
# Example with a simulated change in mean
set.seed(123)
x <- c(rnorm(50, 0), rnorm(50, 3))
group_id <- Groupvalues(x)
table(group_id)
#> group_id
#> 1 2
#> 50 50