knots.fd: Extract the knots from a function basis or data object

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

View source: R/knots.fd.R

Description

Extract either all or only the interior knots from an object of class basisfd, fd, or fdSmooth.

Usage

1
2
3
4
5
6
## S3 method for class 'fd'
knots(Fn, interior=TRUE, ...)
## S3 method for class 'fdSmooth'
knots(Fn, interior=TRUE, ...)
## S3 method for class 'basisfd'
knots(Fn, interior=TRUE, ...)

Arguments

Fn

an object of class basisfd or containing such an object

interior

logical:

if TRUE, Fn[["params"]] are returned.

Else, nord <- norder(Fn); rng <- Fn[['rangeval']]; return c(rep(rng[1], nord), Fn[["params"]], rep(rng[2], nord))

...

ignored

Details

The interior knots of a bspline basis are stored in the params component. The remaining knots are in the rangeval component, with multiplicity norder(Fn).

Value

Numeric vector. If 'interior' is TRUE, this is the params component of the bspline basis. Otherwise, params is bracketed by rep(rangeval, norder(basisfd).

Author(s)

Spencer Graves

References

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

See Also

fd, create.bspline.basis,

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
25
26
27
28
29
30
31
32
33
34
35
36
x <- 0:24
y <- c(1.0,1.0,1.4,1.1,1.0,1.0,4.0,9.0,13.0,
       13.4,12.8,13.1,13.0,14.0,13.0,13.5,
       10.0,2.0,3.0,2.5,2.5,2.5,3.0,4.0,3.5)
##
## knots.fdSmooth
##
girlGrowthSm <- with(growth, smooth.basisPar(argvals=age, y=hgtf,
                                             lambda=0.1))
class(girlGrowthSm) # fdSmooth

girlKnots.fdSm  <- knots(girlGrowthSm)
girlKnots.fdSmA <- knots(girlGrowthSm, interior=FALSE)
stopifnot(all.equal(girlKnots.fdSm, girlKnots.fdSmA[5:33]))

##
## knots.df
##
class(girlGrowth.fd <- girlGrowthSm$fd) # fd

girlKnots.fd  <- knots(girlGrowth.fd)
girlKnots.fdA <- knots(girlGrowth.fd, interior=FALSE)

stopifnot(all.equal(girlKnots.fdSm,  girlKnots.fd))
stopifnot(all.equal(girlKnots.fdSmA, girlKnots.fdA))

##
## knots.basisfd
##
class(girlGr.basisfd <- girlGrowth.fd$basis)

girlKnots.basisfd  <- knots(girlGr.basisfd)
girlKnots.basisfdA <- knots(girlGr.basisfd, interior=FALSE)

stopifnot(all.equal(girlKnots.basisfd,  girlKnots.fd))
stopifnot(all.equal(girlKnots.basisfdA, girlKnots.fdA))

fda documentation built on May 2, 2019, 5:12 p.m.