fel {hysteresis} | R Documentation |
Fitting Ellipses
Description
Fit a sinusoidal hysteretic (elliptical) process between an input and an output.
Usage
fel(x, y=NULL, method = "harmonic2", period = NULL, subjects = NULL,
times="unknown",subset = NULL,na.action= getOption("na.action"),
control=nls.control(), boot=FALSE,...)
Arguments
x |
input |
y |
output |
method |
the method to be used for fitting; one of either the default |
period |
an optional number that defines the length of the |
subjects |
an optional factor or list of factors, each of the same length as x. Use to identify several different ellipses to fit at once, in which case |
times |
either a numeric vector of length |
subset |
an optional vector specifying a subset of observations to be used in the fitting process. |
control |
optional and only used if |
na.action |
a function which indicates what should happen when the data contain NAs. The default is set by the |
boot |
logical, if |
... |
other othrt optional arguments passed to |
Details
Where the response y is a sinusoidal process with an element of randomness that lags the controlling input x, which is also a stochastic sinusoidal process, an ellipse can be used to fit the relationship between x and y.
The values of parameters such as area, lag, retention, coercion, split angle and hysteresis.y are estimated from this ellipse. See loop.parameters
.
The harmonic2 method is a two step harmonic least squares model using generalized transcendental equations presented by Lapshin (1995). Yang and Parkhurst provide the efficient estimates
for parameters and as such "harmonic2" is used as the default. Direct specific least squares (method="direct"
) based on the work of Radim Halir and Jan Flusser is also available although work on delta method standard errors is still in progress. The geometric method is based on the work of Gander, Golub and Strebel and uses the results of an initial direct method to produce an ellipse that minimizes the sum of the squared geometric distances. Finally method="lm"
and
ellipse specific non-linear least squares (method="nls"
) are included as well.
If x and y contain more than 1 ellipse that needs to be fit, the argument subjects
can be used to identify a period of data to fit separate ellipses.
Bootstrapped estimates for parameter values are provided with summary.ellipsefit
. These bootstrapped estimates are generally less biased than those provided by fel
in isolation.
Value
fel
returns an object of class ellipsefit
or ellipsefitlist
.
call |
the function call. |
fit |
information dependent on the fitting method used. |
method |
the |
x |
the input x used. |
y |
the output y used. |
pred.x |
the fitted values for x. |
pred.y |
the fitted values for y. |
period.time |
a vector that contains times converted to radians for observations, either estimated after the ellipse has been fitted or given beforehand by |
fit.statistics |
rudimentary measures, based on the "harmonic2" method, include the Multivariate Final Prediction Error (MFPE) and the AIC for both the output alone and the two variables in combination. Although degree of freedom adjustments are made for other methods, measures of fit require further study. |
values |
a named vector of parameter estimates. See |
Estimates |
a named vector of parameter estimates. See |
Std.Errors |
Delta standard errors produced by the delta method. |
residuals |
algebraic residuals from the model. The function |
if boot==TRUE
fel
returns an object of class ellipsesummary
by making a call to summary.ellipsefit
. See summary.ellipsefit
.
For bootstrapping
Boot.Estimates |
bootstrapped estimates. |
Boot.Std.Errors |
bootstrap standard errors. |
If multiple ellipses are fit simultaneously there will be three arguments to the response, models which will contain the separate model fits for each ellipse, Estimates which will have all of the parameter estimates in matrix form, and Std.Errors which will have all of the delta method standard errors in matrix form. See fel.repeated
.
Author(s)
Spencer Maynes, Fan Yang, and Anne Parkhurst.
References
Yang, F and A. Parkhurst, "Efficient Estimation of Elliptical Hysteresis with Application to the Characterization of Heat Stress" DOI:10.1007/s13253-015-0213-6
See Also
plot.ellipsefit
for plotting and summary.ellipsefit
for summarizing and bootstrapping an ellipsefit
object. Also residuals.ellipsefit
.
Examples
### Simulate and fit a Single ellipse.
Sellipse <- mel(method=2,sd.x=0.2,sd.y=0.04)
Sellipse.fit <- fel(Sellipse$x,Sellipse$y)
Sellipse.fit #Gives estimates, delta standard errors and 95% CI
Sellipse.fit$Estimates
### Bootstrap estimates and standard errors (Seed is necessary if want to reproduce results)
booted.Sellipse <- fel(Sellipse$x,Sellipse$y,boot=TRUE, seed=123)
booted.Sellipse #Gives boot estimates, boot bias, boot SE and boot quartiles
plot(booted.Sellipse,main="Simulated Bootstrap Ellipse Loop",xlab="X Input",
ylab="Y Output",values="ellipse.all")