# smooth.pos: Smooth Data with a Positive Function In fda: Functional Data Analysis

 smooth.pos R Documentation

## 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)
``````

### 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 inside one or more loops, smoothing each curve separately. `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 the functional data are multivariate, this array will be an N by NCURVE by NVAR matrix, where NVAR the number of functions observed per case. For example, for the gait data, NVAR = 2, since we observe knee and hip angles. `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 WFDPAROBJ is used to initialize the optimization process. Its coefficient array contains the starting values for the iterative minimization of mean squared error. The coefficient array contains the starting values for the iterative minimization of mean squared error, and this coefficient array must be either a K by NCURVE matrix or a K by NUCRVE by NVAR array, where K is the number of basis functions. `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 output buffering feature of S-PLUS.

### Value

an object of class `posfd`, being a list with 4 components:

 `Wfdobj` a functional data object defining function \$W(x)\$ that that optimizes the fit to the data of the positive function that it defines. `Flist` a 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` the corresponding input arguments `y` the corresponding input arguments

### 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.

`smooth.surp`, `smooth.monotone`, `smooth.morph`

### Examples

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