Fitting a smooth curve through paired (x,y) data
Description
Fitting a smooth curve through paired (x,y) data.
Usage
1 2 3 
Arguments
X 
An Nx2 
weights 
If 
typeOfWeights 
A 
method 

bandwidth 
A 
satSignal 
Signals equal to or above this threshold will not be used in the fitting. 
... 
Not used. 
Value
A named list
structure of class XYCurve
.
Missing values
The estimation of the function will only be made based on complete
nonsaturated observations, i.e. observations that contains no NA
values nor saturated values as defined by satSignal
.
Weighted normalization
Each data point, that is, each row in X
, which is a
vector of length 2, can be assigned a weight in [0,1] specifying how much
it should affect the fitting of the normalization function.
Weights are given by argument weights
, which should be a numeric
vector
of length N.
Note that the lowess and the spline method only support zeroone {0,1} weights. For such methods, all weights that are less than a half are set to zero.
Details on loess
For loess
, the arguments family="symmetric"
,
degree=1
, span=3/4
,
control=loess.control(trace.hat="approximate"
,
iterations=5
, surface="direct")
are used.
Author(s)
Henrik Bengtsson
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  # Simulate data from the model y < a + bx + x^c + eps(bx)
x < rexp(1000)
a < c(2,15)
b < c(2,1)
c < c(1,2)
bx < outer(b,x)
xc < t(sapply(c, FUN=function(c) x^c))
eps < apply(bx, MARGIN=2, FUN=function(x) rnorm(length(x), mean=0, sd=0.1*x))
Y < a + bx + xc + eps
Y < t(Y)
lim < c(0,70)
plot(Y, xlim=lim, ylim=lim)
# Fit principal curve through a subset of (y_1, y_2)
subset < sample(nrow(Y), size=0.3*nrow(Y))
fit < fitXYCurve(Y[subset,], bandwidth=0.2)
lines(fit, col="red", lwd=2)
# Backtransform (y_1, y_2) keeping y_1 unchanged
YN < backtransformXYCurve(Y, fit=fit)
points(YN, col="blue")
abline(a=0, b=1, col="red", lwd=2)
