fdacv: Cross-Validation

Description Usage Arguments Details Value References Examples

Description

The functions compute the leave-one-out cross-validation of functional data. It applies also to already estimated models.

Usage

1
2
3
4
5
6
7
 
nlFdaCV(y, t, lamvec, kvec, L=2,
        create_basis=create.bspline.basis, maxit=100, tol=1e-8,
         obj=NULL, typels=c("brent","grid"), addDat=FALSE, ...)

fdaCV(y, t, lamvec, kvec, L=2,
      create_basis=create.bspline.basis, obj=NULL, ...)

Arguments

y

A T \times n matrix of data points, when T is the number of periods and n the number of individuals.

t

A numeric vector of time units. The number of elements is equal to the number of rows of y. It must have a range inside rangeval.

lamvec

A vector of regularization parameters that penalizes for the absence of smoothness.

kvec

A vector of integers that indicates the number of basis.

L

Either a nonnegative integer defining an order of a derivative or a linear differential operator (see eval.penalty).

create_basis

The function used to create the basis object (see create.bspline.basis).

maxit

The maximum number of iteration for the Newton method

tol

The tolerance parameter for the stopping rule of the Newton method

obj

Object of class "myfda" if we want the cross-validation of an already fitted model

typels

The nlCoefEst is based on Newton with line search. The argument refers to the method used for the line search

addDat

If TRUE, fake observations are added before and after assuming stationarity. for the estimation, the time span is expanded accordingly.

...

Other argument that is passed to create_basis (see create.bspline.basis).

Details

It returns a matrix of cross-validations. The rows are for the lambda, and the columns for the number of basis.

Value

fdaCV returns a matrix of cross-validations. The rows are for the lambda, and the columns for the number of basis.

nlFdaCV returns a list with the following items:

cv

The cross-validation matrix (see details)

convergence

A matrix returning TRUE if there was no convergence problem while computing the cross-validation.

kvec

The vector of integers that indicates the number of basis.

lamvec

The vector of regularization parameters.

info

An array of convergence codes for all estimations in the process of computing the cross-validations

References

Ramsay, James O., & Silverman, Bernard W. (2005), Functional Data Analysis, Springer, New York.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
data(GDPv56) 
t <- seq(0,1,len=nrow(GDPv56))

## Linear estimation
####################

# From an object
res <- coefEst(y=GDPv56, t=t, lam=0.003, k=15)
fdaCV(obj=res)

# CV with the estimation
cv <- fdaCV(y=GDPv56,t,10^seq(-5,1,len=4), k=5:7)
cv


## Nonlinear Estimation
#######################

res <- nlCoefEst(y=GDPv56, t=t, lam=0.003, k=10)
nlFdaCV(obj=res)

# CV with the estimation
cv <- nlFdaCV(y=GDPv56,t,10^seq(-5,1,len=4), k=5:7)

## Nonlinear Estimation with zeros
##################################

data(simData)
t <- seq(0,1,length.out=5)
cv <- nlFdaCV(y=simData, t=t, lam=c(1e-5, 1e-2), k=c(6:8), addDat=TRUE)
print(cv, conv=TRUE)

funcreg documentation built on May 2, 2019, 5:45 p.m.

Related to fdacv in funcreg...