mcp_example: Get example models and data

View source: R/misc.R

mcp_exampleR Documentation

Get example models and data

Description

Get example models and data

Usage

mcp_example(name, sample = FALSE)

Arguments

name

Name of the example. One of:

  • "demo": Two change points between intercepts and joined/disjoined slopes.

  • "ar": One change point in autoregressive residuals.

  • "binomial": Binomial with two change points. Much like "demo" on a logit scale.

  • "intercepts": An intercept-only change point.

  • rel_prior: Relative parameterization and informative priors.

  • "quadratic": A change point to a quadratic segment.

  • "trigonometric": Trigonometric/seasonal data and model.

  • "varying": Varying / hierarchical change points.

  • "variance": A change in variance, including a variance slope.

sample

TRUE (run fit = mcp(model, data, ...)) or FALSE.

Value

List with

  • model: A list of formulas

  • data: The simulated data

  • simulated: The parameters used for simulating the data.

  • fit: an mcpfit if sample = TRUE,

  • call: the code to run the above.

Author(s)

Jonas Kristoffer Lindeløv jonas@lindeloev.dk

Examples


ex = mcp_example("demo")
plot(ex$data)  # Plot data
print(ex$simulated)  # See true parameters used to simulate
print(ex$call)  # See how the data was simulated

# Fit the model. Either...
fit = mcp(ex$model, ex$data)
plot(fit)

ex_with_fit = mcp_example("demo", sample = TRUE)
plot(ex_with_fit$fit)


mcp documentation built on March 18, 2022, 6:41 p.m.