fitSpline {imageData} | R Documentation |
Produce the fits from a natural cubic smoothing spline applied to a response in a data.frame
Description
Uses smooth.spline
to fit a spline to all the values of
response
stored in data
.
The amount of smoothing can be controlled by df
.
If df = NULL
, the amount of
smoothing is controlled by the default arguments and those you supply
for smooth.spline
. The method of Huang (2001) for correcting the
fitted spline for estimation bias at the end-points will be applied if
correctBoundaries
is TRUE
.
The derivatives of the fitted spline can also be obtained, and the
Relative Growth Rate (RGR) computed using them, provided
correctBoundaries
is FALSE
. Otherwise, growth rates can be
obtained by difference using splitContGRdiff
.
By default, smooth.spline
will issue an error if there are not
at least four distinct x-values. On the other hand, fitSplines
issues a warning and sets all smoothed values and derivatives to
NA
. The handling of missing values in the observations is
controlled via na.x.action
and na.y.action
.
Usage
fitSpline(data, response, x, df=NULL, smoothing.scale = "identity",
correctBoundaries = FALSE,
deriv=NULL, suffices.deriv=NULL, RGR=NULL, AGR=NULL,
na.x.action="exclude", na.y.action = "exclude", ...)
Arguments
data |
A data.frame containing the column to be smoothed.
|
response |
A character giving the name of the column in
data that is to be smoothed.
|
x |
A character giving the name of the column in
data that contains the values of the predictor variable.
|
df |
A numeric specifying the desired equivalent number of degrees
of freedom of the smooth (trace of the smoother matrix). Lower values
result in more smoothing. If df = NULL , the amount of smoothing
is controlled by the default arguments for and those that you supply to
smooth.spline .
|
smoothing.scale |
A character giving the scale on which smoothing
is to be performed. The two possibilites are "identity" , for directly
smoothing the observed response , and "logarithmic" , for scaling the
log -transformed response .
|
correctBoundaries |
A logical indicating whether the fitted spline
values are to have the method of Huang (2001) applied
to them to correct for estimation bias at the end-points. Note that
deriv must be NULL for correctBoundaries to be
set to TRUE .
|
deriv |
A numeric specifying one or more orders of derivatives
that are required.
|
suffices.deriv |
A character giving the characters to be
appended to the names of the derivatives.
|
RGR |
A character giving the character to be appended
to the smoothed response to create the RGR name,
but only when smoothing.scale is identity .
When smoothing.scale is identity :
(i) if RGR is not NULL
deriv must include 1 so that the first derivative is
available for calculating the RGR; (ii) if RGR is NULL ,
the RGR is not calculated from the AGR.
When smoothing.scale is logarithmic ,
the RGR is the backtransformed first derivative and so, to obtain it, merely
include 1 in deriv and any suffix for it in
suffices.deriv .
|
AGR |
A character giving the character to be appended
to the smoothed response to create the AGR name,
but only when smoothing.scale is logarithmic .
When smoothing.scale is logarithmic : (i)
if AGR is not NULL ,
deriv must include 1 so that the first derivative is
available for calculating the AGR; (ii) If AGR is NULL ,
the AGR is not calculated from the RGR. When smoothing.scale is identity ,
the AGR is the first derivative and so, to obtain it, merely
include 1 in deriv and any suffix for it in
suffices.deriv .
|
na.x.action |
A character string that specifies the action to
be taken when values of x are NA . The possible
values are fail , exclude or omit .
For exclude and omit , predictions and derivatives
will only be obtained for nonmissing values of x .
The difference between these two codes is that for exclude
the returned data.frame will have as many rows as
data , the missing values have been incorporated.
|
na.y.action |
A character string that specifies the action to
be taken when values of y , or the response , are
NA . The possible values are fail , exclude ,
omit , allx , trimx , ltrimx or
rtrimx . For all options, except fail , missing
values in y will be removed before smoothing.
For exclude and omit , predictions
and derivatives will be obtained only for nonmissing values of
x that do not have missing y values. Again, the
difference between these two is that, only for exclude
will the missing values be incorporated into the
returned data.frame . For allx , predictions and
derivatives will be obtained for all nonmissing x .
For trimx , they will be obtained for all nonmissing
x between the first and last nonmissing y values
that have been ordered for x ; for ltrimx and
utrimx either the lower or upper missing y
values, respectively, are trimmed.
|
... |
allows for arguments to be passed to smooth.spline .
|
Value
A data.frame
containing x
and the fitted smooth. The names
of the columns will be the value of x
and the value of response
with .smooth
appended. The number of rows in the data.frame
will be equal to the number of pairs that have neither a missing x
or
response
and it will have the same order of codex as data
.
If deriv
is not NULL
, columns
containing the values of the derivative(s) will be added to the
data.frame
; the name each of these columns will be the value of
response
with .smooth.dvf
appended, where
f
is the order of the derivative, or the value of response
with .smooth.
and the corresponding element of
suffices.deriv
appended. If RGR
is not NULL
, the RGR
is calculated as the ratio of value of the first derivative of the fitted
spline and the fitted value for the spline.
Author(s)
Chris Brien
References
Huang, C. (2001). Boundary corrected cubic smoothing splines. Journal of Statistical Computation and Simulation, 70, 107-121.
See Also
splitSplines
, smooth.spline
,
predict.smooth.spline
, splitContGRdiff
Examples
data(exampleData)
fit <- fitSpline(longi.dat, response="Area", , x="xDays", df = 4,
deriv=c(1,2), suffices.deriv=c("AGRdv","Acc"))
[Package
imageData version 0.1-62
Index]