linearFit {ifultools} | 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 TRUE , the aspect ratio
of the data (defined by range(y) / range(x) ) is used to adjust
the angle.tolerance . Specifically, the new angle tolerance becomes
angle.tolerance / aspect.ratio . Using the
aspect ratio to dilate angle.tolerance allows the user
to specify the degree of variablity they wish to impose
on the data vis-a-vis a standard plot of the data, i.e. what
you would see if you issued plot(xdata, ydata) .
The idea is that when looking at such plots, one might
decide (for example) that a 5 degree variablity on the plot
would be acceptable. But if that range of y is vastly
different from that of x , then the true change in angle
from one section to the other will be much different than 5 degrees.
Thus, aspect can be used to compensate for aspect ratios far away from unity.
Default: TRUE . |
fit |
a function representing the linear regression scheme to use in fitting
the resulting statistics (on a log-log scale). Supported functions are: lm ,
lmsreg , and ltsreg . See the on-line help documentation for each of these for
more information. Default: lmsreg . |
method |
a character string used to define the criterion
for selecting one of the segments returned by the linearSegmentation function.
Choices are
Default: "widest" . |
n.fit |
an integer denoting the window size, not to exceed the number of samples in the time series. Default: 5. |
the regression model.
## 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)