fit_meanshift function

Fast implementation of meanshift model

Fast implementation of meanshift model

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()

Returns

A mod_cpt object.

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.

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)

See Also

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

Author(s)

Xueheng Shi, Ben Baumer