File: breakfactor.Rd

package info (click to toggle)
strucchange 1.5-0-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,148 kB
  • sloc: makefile: 1
file content (47 lines) | stat: -rw-r--r-- 1,248 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
\name{breakfactor}
\alias{breakfactor}
\title{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{
  \item{obj}{An object of class \code{"breakpoints"} or
    \code{"breakpointsfull"} respectively.}
  \item{breaks}{an integer specifying the number of breaks
    to extract (only if \code{obj} is of class \code{"breakpointsfull"}),
    by default the minimum BIC partition is used.}
  \item{labels}{a vector of labels for the returned factor,
    by default the segments are numbered starting from
    \code{"segment1"}.}
  \item{\dots}{further arguments passed to \code{factor}.}
}

\value{
  A factor encoding the segmentation.
}

\seealso{\code{\link{breakpoints}}}

\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)
}

\keyword{regression}