Learn R Programming

fda (version 1.1.4)

data2fd: Convert Discrete Data to Functional Data

Description

This function converts an array 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.

Usage

data2fd(y, argvals=seq(0, 1, len = n), basisobj,
        fdnames=defaultnames,
        argnames=c("time", "reps", "values"))

Arguments

y
an array containing sampled values of curves. If 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 t
argvals
a set of argument values. If this is a vector, the same set of argument values is used for all columns of y. If argvals is a matrix, the columns correspond to the columns of y, and contain the argument values for t
basisobj
either: A 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
A list of length 3, each member being a string vector containing labels for the levels of the corresponding dimension of the discrete data. The first dimension is for argument values, and is given the default name "time", the second is for replications,
argnames
a character vector of length 3 containing:

  • the name of the argument, e.g. "time" or "age"
  • a description of the cases, e.g. "weather stations"
  • the name of the observed function value, e.g. "temperature"

These strings are

Value

  • an object of the fd class containing:
  • coefsthe coefficient array
  • basisa basis object and
  • fdnamesa list containing names for the arguments, function values and variables

Details

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

See Also

smooth.basis, project.basis, smooth.fd, smooth.monotone, smooth.pos

Examples

Run this code
#    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(daily$tempav, daytime, daybasis)
#  plot the temperature curves
plot(tempfd)

Run the code above in your browser using DataLab