Learn R Programming

fda (version 2.4.0)

smooth.pos: Smooth Data with a Positive Function

Description

A set of data is smoothed with a functional data object that only takes positive values. For example, this function can be used to estimate a smooth variance function from a set of squared residuals. A function $W(t)$ is estimated such that that the smoothing function is $exp[W(t)]$.

Usage

smooth.pos(argvals, y, WfdParobj, wtvec=rep(1,n),
           conv=.0001, iterlim=50, dbglev=1, returnMatrix=FALSE)

Arguments

argvals
Argument value array of length N, where N is the number of observed curve values for each curve. It is assumed that that these argument values are common to all observed curves. If this is not the case, you will need to run this function
y
Function value array (the values to be fit). If the functional data are univariate, this array will be an N by NCURVE matrix, where N is the number of observed curve values for each curve and NCURVE is the number of curves observed. If th
WfdParobj
A functional parameter or fdPar object. This object contains the specifications for the functional data object to be estimated by smoothing the data. See comment lines in function fdPar for details. The functional data object WFD in WFDP
wtvec
a vector of weights to be used in the smoothing.
conv
a convergence criterion.
iterlim
the maximum number of iterations allowed in the minimization of error sum of squares.
dbglev
either 0, 1, or 2. This controls the amount information printed out on each iteration, with 0 implying no output, 1 intermediate output level, and 2 full output. If either level 1 or 2 is specified, it can be helpful to turn off the outpu
returnMatrix
logical: If TRUE, a two-dimensional is returned using a special class from the Matrix package.

Value

  • an object of class posfd, being a list with 4 components:
  • Wfdobja functional data object defining function $W(x)$ that that optimizes the fit to the data of the positive function that it defines.
  • Flista named list containing three results for the final converged solution: (1) f: the optimal function value being minimized, (2) grad: the gradient vector at the optimal solution, and (3) norm: the norm of the gradient vector at the optimal solution.
  • argvals, ythe corresponding input arguments
  • returnMatrixlogical: If TRUE, a two-dimensional is returned using a special class from the Matrix package.

See Also

smooth.monotone, smooth.morph

Examples

Run this code
smallbasis  <- create.fourier.basis(c(0, 365), 65)
harmaccelLfd365 <- vec2Lfd(c(0,(2*pi/365)^2,0), c(0, 365))

index <- (1:35)[CanadianWeather$place == "Vancouver"]
VanPrec  <- CanadianWeather$dailyAv[,index, "Precipitation.mm"]

lambda    <- 1e4
dayfdPar <- fdPar(smallbasis, harmaccelLfd365, lambda)
smooth.pos(day.5, VanPrec, dayfdPar)

Run the code above in your browser using DataLab