Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

monfn

Evaluates a monotone function


Description

Evaluates a monotone function

Usage

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

Arguments

argvals

A numerical vector at which function and derivative are evaluated.

Wfdobj

A functional data object.

basislist

A list containing values of basis functions.

returnMatrix

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

Details

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.

Value

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

See Also

Examples

## basically this example resembles part of landmarkreg.R that uses monfn.R to
## estimate the warping function.

## Specify the curve subject to be registered
n=21
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, WfdPar=WfdPar)$Wfdobj

## 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

Functional Data Analysis

v5.1.9
GPL (>= 2)
Authors
J. O. Ramsay <ramsay@psych.mcgill.ca> [aut,cre], Spencer Graves <spencer.graves@effectivedefense.org> [ctb], Giles Hooker <gjh27@cornell.edu> [ctb]
Initial release
2020-12-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.