monfn: Evaluate the a monotone function

View source: R/monfn.R

monfnR Documentation

Evaluate the a monotone function


Evaluate a monotone function defined as the indefinite integral of $exp(W(t))$ where $W$ is a function defined by a basis expansion. Function $W$ is the logarithm of the derivative of the monotone function.


  monfn(argvals, Wfdobj, basislist=vector("list", JMAX), returnMatrix=FALSE)



A numerical vector at which function and derivative are evaluated.


A functional data object.


A list containing values of basis functions.


logical: If TRUE, a two-dimensional is returned using a special class from the Matrix package.


This function evaluates a strictly monotone function of the form

h(x) = [D^{-1} exp(Wfdobj)](x),

where D^{-1} means taking the indefinite integral. The interval over which the integration takes places is defined in the basis object in Wfdobj.


A numerical vector or matrix containing the values the warping function h.


J. O. Ramsay


Ramsay, James O., Hooker, G. and Graves, S. (2009), Functional Data Analysis with R and Matlab, Springer, New York.

Ramsay, James O., and Silverman, Bernard W. (2005), Functional Data Analysis, 2nd ed., Springer, New York.

Ramsay, James O., and Silverman, Bernard W. (2002), Applied Functional Data Analysis, Springer, New York.

See Also

mongrad, landmarkreg, smooth.morph


oldpar <- par(no.readonly=TRUE)
## basically this example resembles part of landmarkreg.R that uses monfn.R to
## estimate the warping function.

## Specify the curve subject to be registered
tbreaks = seq(0, 2*pi, len=n)
xval <- sin(tbreaks)
rangeval <- range(tbreaks)

## Establish a B-spline basis for the curve
wbasis <- create.bspline.basis(rangeval=rangeval, breaks=tbreaks)
Wfd0   <- fd(matrix(0,wbasis$nbasis,1),wbasis)
WfdPar <- fdPar(Wfd0, 1, 1e-4)
fdObj  <- smooth.basis(tbreaks, xval, WfdPar)$fd

## Set the mean landmark times. Note that the objective of the warping
## function is to transform the curve such that the landmarks of the curve
## occur at the designated mean landmark times.

## Specify the mean landmark times: tbreak[8]=2.2 and tbreaks[13]=3.76
meanmarks <- c(rangeval[1], tbreaks[8], tbreaks[13], rangeval[2])
## Specify landmark locations of the curve: tbreaks[6] and tbreaks[16]
cmarks <- c(rangeval[1], tbreaks[6], tbreaks[16], rangeval[2])

## Establish a B-basis object for the warping function
Wfd <- smooth.morph(x=meanmarks, y=cmarks, ylim=rangeval, 

## Estimate the warping function
h = monfn(tbreaks, Wfd)

## scale using a linear equation h such that h(0)=0 and h(END)=END
b <- (rangeval[2]-rangeval[1])/ (h[n]-h[1])
a <- rangeval[1] - b*h[1]
h <- a + b*h
plot(tbreaks, h, xlab="Time", ylab="Transformed time", type="b")

fda documentation built on May 29, 2024, 11:26 a.m.