# create.basis:
Create a smooth B-spline basis

## Description

This function creates a smooth B-spline basis and provides tools to
find the coefficients of functional data in the basis
and to recover functional data from basis coefficients.## Usage

create.basis(x, p, sp = 1e-09, degree = 3, nderiv = 2)

## Arguments

x

vector of observation times

p

number of basis functions

degree

degree of the B splines

nderiv

order of the derivative to penalize for smoothing

## Value

A list with fields
A list with fields

## Details

The knots of the B-spline basis are taken as regular quantiles of `x`

. The function output is intended for use with functions
`coef2fd`

and `fd2coef`

.
## Examples

n <- 100 # number of curves
d <- 500 # number of observation points
grid <- (1:d)/d # observation points
p <- 50 # number of B-spline basis functions
# Simulate Brownian motion
x <- matrix(rnorm(n*d,sd=1/sqrt(d)),n,d)
x <- t(apply(x,1,cumsum))
# Create B-spline basis
mybasis <- create.basis(grid, p, 1e-4)
# Compute smooth basis coefficients
beta <- fd2coef(x, mybasis)
# Recover smooth functional data
x.smooth <- coef2fd(beta, mybasis)
# Standard PCA and Functional PCA
pca <- prcomp(x)
fpca <- prcomp(beta)