xyw.coords: Extract fitting structures with weights

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Extract arguments, eliminate duplicates in x, averaging corresponding y's, summing corresponding weights, and maintaining the dominant sign of convexity constraints.

Usage

1
  xyw.coords(x, y = NULL, w = NULL, v = NULL, ...)

Arguments

x

A data.frame, matrix, or numeric vector. See details.

y

Optional numeric vector. See details.

w

Optional vector of weights

v

Convexity constraints. See details.

...

Optional arguments, currently ignored.

Details

'x' and 'y' are first passed to xy.coords for initial parsing. Then duplicate 'x' values are identified, and corresponding values of y, w and v are processed to average y's, sum w's, and use sign(sum(v's)). If(missing(w)) w = 1. If(missing(v)) v = 0.

Value

A list with the following components:

x

unique of input x values, sorted

y

input y, arranged to match x, with values corresponding to duplicate x values replaced by their mean.

w

input w, arranged to match x, with values corresponding to duplicate x values replaced by their sum.

v

input v, arranged to match x, with values corresponding to duplicate x values replaced by the sign of their sum.

xin

input x values

yin

input y values

Author(s)

Sundar Dorai-Raj

References

Dierckx, P. (1991) Curve and Surface Fitting with Splines, Oxford Science Publications.

See Also

xy.coords curfit, concon

Examples

1
2
3
4
5
6
7
8
9
x <- c(3, 1, 3+1e-7, 6, 3+5e-7, 5)
y <- c(3, 1, 2, 6, 4, 5) 
tst <- xyw.coords(x, y)
ans <- list(x = c(1, 3+2e-7, 5:6), y = c(1, 3, 5:6), w = c(1, 3, 1, 1),
            v = rep(0, 4), xin=x, yin=y) 
all.equal(tst, ans)
# TRUE
#all.equal(tst$x, c(1, 3, 5:6))
#[1] "Mean relative  difference: 6.666666e-08"

DierckxSpline documentation built on May 2, 2019, 6:30 p.m.