Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

breakfactor

Factor Coding of Segmentations


Description

Generates a factor encoding the segmentation given by a set of breakpoints.

Usage

breakfactor(obj, breaks = NULL, labels = NULL, ...)

Arguments

obj

An object of class "breakpoints" or "breakpointsfull" respectively.

breaks

an integer specifying the number of breaks to extract (only if obj is of class "breakpointsfull"), by default the minimum BIC partition is used.

labels

a vector of labels for the returned factor, by default the segments are numbered starting from "segment1".

...

further arguments passed to factor.

Value

A factor encoding the segmentation.

See Also

Examples

## Nile data with one breakpoint: the annual flows drop in 1898
## because the first Ashwan dam was built
data("Nile")
plot(Nile)

## compute breakpoints
bp.nile <- breakpoints(Nile ~ 1)

## fit and visualize segmented and unsegmented model
fm0 <- lm(Nile ~ 1)
fm1 <- lm(Nile ~ breakfactor(bp.nile, breaks = 1))

lines(fitted(fm0), col = 3)
lines(fitted(fm1), col = 4)
lines(bp.nile, breaks = 1)

strucchange

Testing, Monitoring, and Dating Structural Changes

v1.5-2
GPL-2 | GPL-3
Authors
Achim Zeileis [aut, cre] (<https://orcid.org/0000-0003-0918-3766>), Friedrich Leisch [aut], Kurt Hornik [aut], Christian Kleiber [aut], Bruce Hansen [ctb], Edgar C. Merkle [ctb]
Initial release
2019-10-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.