Description Usage Arguments Details Value See Also Examples
Interactively enter a set of points and then fit a curve of specified form to get a coefficients.
1 2 3 4 5 6 7 8 9 |
formula |
formula for the model to be fitted to the entered data |
n |
numeric, number of data points to be entered |
model |
character, name of the model-fitting function to be used for the entered data |
prn |
numeric, number of points used to evaluate the fitted model, important only for plotting the fitted curve |
xlim |
numeric of length 2, limits for the horizontal axis |
ylim |
numeric of length 2, limits for the vertical axis |
... |
other arguments passed to the model-fitting function |
Frequently there is a need to quickly come up with a particular form of a function. This function enables to quickly fit a curve of certain kind to a, usually small, number of data points.
The function starts with creating an empty plotting region ready for input
of n
data points. Every data input (through locator
) results
in adding a point to the plot with a subsequent number. After the data are
inputed the function uses model-fitting function specified with model
to fit the curve specified with formula
with possibly additional
arguments passed through ...
.
The formula
argument has a usual form as in almost all model-fitting
functions in . It can contain only variables y
and x
.
Furthermore, direct transformations of y
are not supported. All
transformations of x
should be enclosed in I()
function.
The function was designed to be used with lm
or glm
as
model-fitting functions. However, in principle, it should be possible to use
any other function that provides similar interface, i.e. formula
and
data
arguments, and the corresponding predict
method.
Once the model is fitted the function finds its predicted values for a
sequence of values defined by xlim
of length prn
. Then the
curve itself is added to the plot. Finally the model object is returned.
A model object created for the supplied data with the model-fitting
function specified with model
.
See lowess
and spline
for other curve
fitting functions, lm
and glm
for help with th
model-fitting functions supported. Also see predict
and
I
1 2 3 4 5 6 7 8 9 10 | ## Not run:
# fitting via 'lm'
iCurveFit(formula= y ~ x ) # linear
iCurveFit(formula= y ~ I(x^2) + x ) # parabolic
iCurveFit(formula= y ~ I(x^3) + I(x^2) + x, n=7) # polynomial of degree 3
iCurveFit(formula= y ~ I(sin(x)), n=7) # sinusoidal
iCurveFit(formula= y ~ I(log(x)), n=7) # log
iCurveFit(formula= y ~ I(1/x), n=7) # hyperbolic
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.