getLandK: Cross-Validation

Description Usage Arguments Details Value References Examples

Description

Several functions that computes the leave-one-out cross-validation of functional data. They include cases of linear and nonlinear fit.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
nlGetLam(y, t, lamInt, k, L=2,
         create_basis=create.bspline.basis, maxit=100, tol=1e-8,
         maxitalgo=100, tolalgo=1e-7, type=c("Brent","GS"),
         typels=c("brent","grid"), addDat=FALSE, ...)

nlGetLandKopt(y, t, lamInt, kvec, L=2,
              create_basis=create.bspline.basis, maxit=100, tol=1e-7,
              maxitalgo=100, tolalgo=1e-6, type=c("Brent", "GS"),
              typels=c("brent","grid"), addDat=FALSE, ...)

nlGetLandK(y, t, lamvec, kvec, L=2,
           create_basis=create.bspline.basis, maxit=100, tol=1e-8,
           typels=c("brent","grid"), addDat=FALSE, ...)

getLam(y, t, lamInt, k, L=2,
       create_basis=create.bspline.basis, 
       maxitalgo=100, tolalgo=1e-7, type=c("Brent","GS"), ...)

getLandK(y, t, lamvec, kvec, L=2,
         create_basis=create.bspline.basis, ...)

getLandKopt(y, t, lamInt, kvec, L=2,
            create_basis=create.bspline.basis, 
            maxitalgo=100, tolalgo=1e-6, type=c("Brent", "GS"), ...)

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.

lamInt

A vector that contains the lower and upper bounds for Lambda that is passed to the Brent or Golden Section method.

kvec

A vector of integers that indicates the number of basis.

k

A scalar 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

maxitalgo

Maximum number of iteration for the brent and Golden-Section methods

tolalgo

Tolerance level for the stopping rule of the Brent or Golden-Section method.

type

Which algorithm should we use to get the lambda.

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

Function that starts with 'nl' are the nonlinear functional data (see coefEst).

getLam and nlGetLam, finds the Lambda that minimizes the cross-validation for a given k using either the Brent method or the Golden-Section method.

nlGetLandK and getLandK find the optimal Lambda and k using a grid search. The grid is provided by the user through lamvec and kvec.

getLandKopt and nlGetLandKopt find the optimal Lambda and k using a grid search for k only. Lambda is obtained using the Brent or Golden-Section method.

Value

getLam and nlGetLam returns a list with the following items:

lam

The optimal Lambda

info

A convergence code for the optimization method (0 for normal convergence).

iter

The number of iterations for the Brent or Golden-Section method.

cv

The minimum cross-validation

getLandK, codenlGetLandK, getLandKopt, and codenlGetLandKopt, returns an object of class "myfda" (see coefEst). In addition to the usual element, the list inludes information about the search.

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
data(GDPv56) 
t <- seq(0,1,len=nrow(GDPv56))

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

# Using a grid
nlam <- 5
lamvec <- 10^seq(-5,1,length.out=nlam)
kvec <- 5:7
res1 <- getLandK(GDPv56, t, lamvec, kvec)
res1

# Using Brent
res2 <- getLandKopt(GDPv56, t, lamvec, kvec, tolalgo=1e-5)
res2

## Nonlinear estimation
###########################

# Using a grid
res3 <- nlGetLandK(GDPv56, t, lamvec, kvec)
res3

# Using Brent
res4 <- nlGetLandKopt(GDPv56, t, lamvec, kvec, tolalgo=1e-5)
res3

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

Related to getLandK in funcreg...