fit_meanshift: Fast implementation of meanshift model

View source: R/mod_meanshift.R

fit_meanshiftR Documentation

Fast implementation of meanshift model

Description

Fast implementation of meanshift model

Usage

fit_meanshift(x, tau, distribution = "norm", ...)

fit_meanshift_norm(x, tau, ...)

fit_meanshift_lnorm(x, tau, ...)

fit_meanshift_norm_ar1(x, tau, ...)

Arguments

x

A time series

tau

a set of indices representing a changepoint set

distribution

A character indicating the distribution of the data. Should match R distribution function naming conventions (e.g., "norm" for the Normal distribution, etc.)

...

arguments passed to stats::lm()

Details

fit_meanshift_norm() returns the same model as fit_lmshift() with the deg_poly argument set to 0. However, it is faster on large changepoint sets.

fit_meanshift_lnorm() fit the meanshift model with the assumption of log-normally distributed data.

fit_meanshift_norm_ar1() applies autoregressive errors.

Value

A mod_cpt object.

Author(s)

Xueheng Shi, Ben Baumer

See Also

Other model-fitting: fit_lmshift(), fit_meanvar(), fit_nhpp(), model_args(), model_name(), new_fun_cpt(), whomademe()

Examples

# Manually specify a changepoint set
tau <- c(365, 826)

# Fit the model
mod <- fit_meanshift_norm_ar1(DataCPSim, tau)

# View model parameters
logLik(mod)
deg_free(mod)

# Manually specify a changepoint set
cpts <- c(1700, 1739, 1988)
ids <- time2tau(cpts, as_year(time(CET)))

# Fit the model
mod <- fit_meanshift_norm(CET, tau = ids)

# Review model parameters
glance(mod)

# Fit an autoregressive model
mod <- fit_meanshift_norm_ar1(CET, tau = ids)

# Review model parameters
glance(mod)


tidychangepoint documentation built on April 4, 2025, 4:31 a.m.