data2fd | Language Reference for FDA Library
|
y
of function values
plus an array
argvals
of argument values into a
functional data object. This a function that tries to
do as much for the user as possible. A basis function
expansion is used to represent the curve, but no roughness
penalty is used. The data are fit using the least squares
fitting criterion.
data2fd(y, argvals=seq(0, 1, len = n), basisobj, fdnames=defaultnames, argnames=c("time", "reps", "values"))
y
is a vector, only one replicate and variable are assumed.
If
y
is a matrix, rows must correspond to argument
values and columns to replications or cases, and it will be assumed
that there is only one variable per observation. If
y
is a three-dimensional array, the first dimension (rows)
corresponds to argument values, the second (columns) to replications,
and the third (layers) to variables within replications. Missing values
are permitted, and the number of values may vary from one
replication to another. If this is the case, the number of
rows must equal the maximum number of argument values,
and columns of
y
having fewer values must be padded out with
NA's.
y
. If
argvals
is a
matrix, the columns correspond to the columns of
y
, and contain the
argument values for that replicate or case.
basisfd
object created by function create.basis.fd(),
or the value NULL, in which case a
basisfd
object is set up by
the function, using the values of the next three arguments.
fdnames
.fd
class containing:
This function tends to be used in rather simple applications where
there is no need to control the roughness of the resulting curve
with any great finesse. The roughness is essentially controlled
by how many basis functions are used. In more sophisticated
applications, it would be better to use the function
smooth.basis.
# set up the fourier basis nbasis <- 65 dayrange <- c(0,365) daybasis <- create.fourier.basis(dayrange, nbasis) # Make temperature fd object # Temperature data are in 12 by 365 matrix tempav # See analyses of weather data. # Set up sampling points at mid days daytime <- (1:365)-0.5 # Convert the data to a functional data object tempfd <- data2fd(tempav, daytime, daybasis) # plot the temperature curves plot(tempfd)