Learn R Programming

fda (version 6.2.0)

lines.fd: Add Lines from Functional Data to a Plot

Description

Lines defined by functional observations are added to an existing plot.

Usage

# S3 method for fd
lines(x, Lfdobj=int2Lfd(0), nx=201, ...)
# S3 method for fdSmooth
lines(x, Lfdobj=int2Lfd(0), nx=201, ...)

Arguments

x

a univariate functional data object to be evaluated at nx points over xlim and added as a line to an existing plot.

Lfdobj

either a nonnegative integer or a linear differential operator object. If present, the derivative or the value of applying the operator is evaluated rather than the functions themselves.

nx

Number of points within xlim at which to evaluate x for plotting.

...

additional arguments such as axis titles and so forth that can be used in plotting programs called by lines.fd or lines.fdSmooth.

Side Effects

Lines added to an existing plot.

References

Ramsay, James O., Hooker, Giles, and Graves, Spencer (2009), Functional data analysis with R and Matlab, Springer, New York.

Ramsay, James O., and Silverman, Bernard W. (2005), Functional Data Analysis, 2nd ed., Springer, New York.

Ramsay, James O., and Silverman, Bernard W. (2002), Applied Functional Data Analysis, Springer, New York.

See Also

plot.fd, plotfit.fd

Examples

Run this code
oldpar <- par(no.readonly=TRUE)
##
## plot a fit with 3 levels of smoothing
##
x <- seq(-1,1,0.02)
y <- x + 3*exp(-6*x^2) + sin(1:101)/2
# sin not rnorm to make it easier to compare
# results across platforms 

result4.0  <- smooth.basisPar(argvals=x, y=y, lambda=1)
result4.m4 <- smooth.basisPar(argvals=x, y=y, lambda=1e-4)

plot(x, y)
lines(result4.0$fd)
lines(result4.m4$fd,      col='blue')
lines.fdSmooth(result4.0, col='red') 

plot(x, y, xlim=c(0.5, 1))
lines.fdSmooth(result4.0)
lines.fdSmooth(result4.m4, col='blue')
# no visible difference from the default?  
par(oldpar)

Run the code above in your browser using DataLab