# mat2fd: Create an 'fd' object from a matrix In GPFDA: Gaussian Process for Functional Data Analysis

 mat2fd R Documentation

## Create an 'fd' object from a matrix

### Description

Easy setting up for creating an 'fd' object

### Usage

```mat2fd(mat, fdList = NULL)
```

### Arguments

 `mat` Input data, should be a matrix with ncol time points and nrow replications or samples. `fdList` A list with following items: timeSequence of time points (default to be 100 points from 0 to 1). nbasisNumber of basis functions used in smoothing, default to be less or equal to 23. norderOrder of the functional curves default to be 6. bSplineLogical, if TRUE (default), b-Spline basis is used; otherwise, Fourier basis is used. PenDefault to be c(0,0), meaning that the penalty is on the second order derivative of the curve, since the weight for zero-th and first order derivatives of the curve are set to zero. lambdaSmoothing parameter for the penalty. Default to be 1e-4.

### Details

All items listed above have default values. If any item is required to change, add that item into the list; otherwise, leave it as NULL. For example, if one only wants to change the number of basis functions, do:

`mat2fd(SomeMatrix,list(nbasis=21))`

An 'fd' object

### References

Ramsay, J., and Silverman, B. W. (2006),

### Examples

```require(fda)
require(fda.usc)
nrep <- 20   # number of replications
n <- 100     # number of time points
input <- seq(-1, pi, length.out=n) # time points
ry <- rnorm(nrep, sd=10)
y <- matrix(NA, ncol=n, nrow=nrep)
for(i in 1:nrep)  y[i,] <- sin(2*input)*ry[i]

plot.fdata(fdata(y,input))

yfd <- mat2fd(y, list(lambda=0.01))
plot(yfd)

yfd <- mat2fd(y, list(lambda=0.00001))
plot(yfd)

```

GPFDA documentation built on May 7, 2022, 5:06 p.m.