linearFit | R Documentation |
Segments the time series in approximately linear regions
as defined by the linearSegmentation
function
and subsequently regressed the specified segment using
a selected regression scheme.
linearFit(x, y, fit=lmsreg, method="widest", n.fit=5, angle.tolerance=5, aspect=TRUE)
x |
the independent variable of the time series. |
y |
the dependent variable of the time series. |
angle.tolerance |
the maximum angle in degrees that the running average of the slopes in the current set of points can change relative to the slope of the data calculated in the most current (rightmost) window before a change-point is recorded. Default: 5. |
aspect |
a logical value. If |
fit |
a function representing the linear regression scheme to use in fitting
the resulting statistics (on a log-log scale). Supported functions are: |
method |
a character string used to define the criterion
for selecting one of the segments returned by the
Default: |
n.fit |
an integer denoting the window size, not to exceed the number of samples in the time series. Default: 5. |
the regression model.
logScale
.
## obtain some data with approximately ## piecewise-linear trends x <- seq(0,2*pi,length=100) y <- sin(x) ## perform linear segmentation with aspect ratio ## dilation using a 5 degree tolerance and 5 ## point windows. regress the widest of these ## segments with the lm() function. linearFit(x, y, n.fit=5, angle.tolerance=5, aspect=TRUE, method="widest", fit=lm)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.