coefest: Functional Data Fit

Description Usage Arguments Details Value References Examples

Description

These are the main functions to fit a functional data object to a dataset. The model can be linear or nonlinear. The smoothing parameter and the number of basis is assumed to be known.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
coefEst(y, t, lam, k, L=2,
        create_basis=create.bspline.basis, ...)

nlCoefEst(y, t, lam, k, L=2,
          create_basis=create.bspline.basis, maxit=100, tol=1e-8,
          typels=c("brent","grid"), addDat=FALSE, rangeval=NULL, ...)

makeLinFda(obj, npoints=200)

logFda(obj)

## S3 method for class 'myfda'
as.fd(x, fdnames=NULL, npoints=200, ...)

## S3 method for class 'myfda'
fitted(object, t=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. In coefEst and nlCoefEst, the number of elements is equal to the number of rows of y. For the fitted method, it can be a fine grid, and the range must be inside the range of the basis.

lam

The regularization parameter that penalizes for the absence of smoothness.

k

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

...

Other argument that is passed to create_basis (see create.bspline.basis), or to other methods in the case of as.fd.myfda.

obj

Object of class "myfda"

npoints

Number of points to fit the linear FDA to the non-linear one

x

Object of class "myfda"

object

Object of class "myfda"

fdnames

Names of elements of the "fd" object (see fd)

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.

rangeval

This can be set if the basis is defined on a range other than range(t).

Details

In coefEst, the functional data is a linear combination of the basis, while in nlCoefEst it is the exponential of the linear combination of the basis. The latter is used when we want to force the functional data curve to be positive,

makeLinFda will transform the nonlinear fit to a linear FDA by fitting the nonlinear curve to a linear combination of the same basis. The curve is almost identical and it is transformed this way by funcreg

logFDA transforms the non-linear FDA into a linear FDA. It only redefine the link equation and take the log of the observed data.

Value

It returns an object of 'class' "myfda"

The object of class "myfda" is a list containing at least:

coefficients

k\times n matrix of coefficients.

y

The dataset matrix y.

t

The input vector t.

basis

The basis object

link

The function that links y to the linear combination of the basis.

lambda

The value of lam.

convergence

Information on the convergence of the Newton method.

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

## Linear estimation
res <- coefEst(y=GDPv56, t=t, lam=0.003, k=15)
res

cbind(data=GDPv56[,1], fitted=fitted(res)[,1])

## Nonlinear Estimation
res <- nlCoefEst(y=GDPv56, t=t, lam=0.003, k=15)
res

resLin <- makeLinFda(res)
resLin

## Take the logarithm of the non-linear functional data
logres <- logFda(res)
plot(res,1:2)

## Transform the myfda object into an fd object
resfd <- as.fd(resLin)

## Nonlinear Estimation with zeros
data(simData)
t <- seq(0,1,length.out=5)
res <- nlCoefEst(y=simData, t=t, lam=0.003, k=7)
res
res <- nlCoefEst(y=simData, t=t, lam=0.003, k=7, addDat=TRUE)
res

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

Related to coefest in funcreg...