as.model | R Documentation |
Convert, retrieve, or verify a model object
as.model(object, ...)
## Default S3 method:
as.model(object, ...)
## S3 method for class 'tidycpt'
as.model(object, ...)
is_model(x, ...)
object |
A tidycpt object, typically returned by |
... |
currently ignored |
x |
An object, typically returned by |
tidycpt objects have a model
component.
The functions documented here are convenience utility functions
for working with the model
components.
as.model()
is especially useful in pipelines to avoid having to use
the $
or [
notation for subsetting.
When applied to a tidycpt object, as.model()
simply returns the
model
component of that object.
However, when applied to a segmenter
object, as.model()
attempts to
converts that object into a mod_cpt model object.
is_model()
checks to see if a model object implements all of the
S3 methods necessary to be considered a model.
as.model()
returns a mod_cpt model object
is_model()
a logical
vector of length 1
Other tidycpt-generics:
as.segmenter()
,
changepoints()
,
diagnose()
,
fitness()
,
model_name()
# Segment a time series using PELT
x <- segment(CET, method = "pelt")
# Retrieve the model component
x |>
as.model()
# Explicitly convert the segmenter to a model
x |>
as.segmenter() |>
as.model()
# Is that model valid?
x |>
as.model() |>
is_model()
# Fit a model directly, without using [segment()]
x <- fit_nhpp(CET, tau = 330)
is_model(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.