|
1 |
| -\name{monfn} |
2 |
| -\alias{monfn} |
3 |
| -\title{Evaluates a monotone function} |
4 |
| -\description{Evaluates a monotone function} |
5 |
| -\usage{ |
6 |
| - monfn(argvals, Wfdobj, basislist=vector("list", JMAX), returnMatrix=FALSE) |
7 |
| -} |
8 |
| -\arguments{ |
9 |
| - \item{argvals}{A numerical vector at which function and derivative are |
10 |
| - evaluated.} |
11 |
| - \item{Wfdobj}{A functional data object.} |
12 |
| - \item{basislist}{A list containing values of basis functions.} |
13 |
| - \item{returnMatrix}{ |
14 |
| - logical: If TRUE, a two-dimensional is returned using a |
15 |
| - special class from the Matrix package. |
16 |
| - } |
17 |
| -} |
18 |
| -\value{ |
19 |
| - A numerical vector or matrix containing the values the warping function h. |
20 |
| -} |
21 |
| -\details{ |
22 |
| - This function evaluates a strictly monotone function of the form |
23 |
| - \deqn{h(x) = [D^{-1} exp(Wfdobj)](x),} |
24 |
| - where \eqn{D^{-1}} means taking the indefinite integral. The interval over |
25 |
| - which the integration takes places is defined in the basis object in Wfdobj. |
26 |
| -} |
27 |
| -\seealso{ |
28 |
| - \code{\link{landmarkreg}} |
29 |
| -} |
30 |
| -\examples{ |
31 |
| - |
32 |
| -## basically this example resembles part of landmarkreg.R that uses monfn.R to |
33 |
| -## estimate the warping function. |
34 |
| - |
35 |
| -## Specify the curve subject to be registered |
36 |
| -n=21 |
37 |
| -tbreaks = seq(0, 2*pi, len=n) |
38 |
| -xval <- sin(tbreaks) |
39 |
| -rangeval <- range(tbreaks) |
40 |
| - |
41 |
| -## Establish a B-spline basis for the curve |
42 |
| -wbasis <- create.bspline.basis(rangeval=rangeval, breaks=tbreaks) |
43 |
| -Wfd0 <- fd(matrix(0,wbasis$nbasis,1),wbasis) |
44 |
| -WfdPar <- fdPar(Wfd0, 1, 1e-4) |
45 |
| -fdObj <- smooth.basis(tbreaks, xval, WfdPar)$fd |
46 |
| - |
47 |
| -## Set the mean landmark times. Note that the objective of the warping |
48 |
| -## function is to transform the curve such that the landmarks of the curve |
49 |
| -## occur at the designated mean landmark times. |
50 |
| - |
51 |
| -## Specify the mean landmark times: tbreak[8]=2.2 and tbreaks[13]=3.76 |
52 |
| -meanmarks <- c(rangeval[1], tbreaks[8], tbreaks[13], rangeval[2]) |
53 |
| -## Specify landmark locations of the curve: tbreaks[6] and tbreaks[16] |
54 |
| -cmarks <- c(rangeval[1], tbreaks[6], tbreaks[16], rangeval[2]) |
55 |
| - |
56 |
| -## Establish a B-basis object for the warping function |
57 |
| -Wfd = smooth.morph(x=meanmarks, y=cmarks, WfdPar=WfdPar)$Wfdobj |
58 |
| - |
59 |
| -## Estimate the warping function |
60 |
| -h = monfn(tbreaks, Wfd) |
61 |
| - |
62 |
| -## scale using a linear equation h such that h(0)=0 and h(END)=END |
63 |
| -b <- (rangeval[2]-rangeval[1])/ (h[n]-h[1]) |
64 |
| -a <- rangeval[1] - b*h[1] |
65 |
| -h <- a + b*h |
66 |
| -plot(tbreaks, h, xlab="Time", ylab="Transformed time", type="b") |
67 |
| -} |
68 |
| - |
| 1 | +\name{monfn} |
| 2 | +\alias{monfn} |
| 3 | +\title{Evaluate the a monotone function} |
| 4 | +\description{Evaluate a monotone function defined as the indefinite integral of |
| 5 | +$exp(W(t))$ where $W$ is a function defined by a basis expansion. Function $W$ |
| 6 | +is the logarithm of the derivative of the monotone function.} |
| 7 | +\usage{ |
| 8 | + monfn(argvals, Wfdobj, basislist=vector("list", JMAX), returnMatrix=FALSE) |
| 9 | +} |
| 10 | +\arguments{ |
| 11 | + \item{argvals}{A numerical vector at which function and derivative are |
| 12 | + evaluated.} |
| 13 | + \item{Wfdobj}{A functional data object.} |
| 14 | + \item{basislist}{A list containing values of basis functions.} |
| 15 | + \item{returnMatrix}{ |
| 16 | + logical: If TRUE, a two-dimensional is returned using a |
| 17 | + special class from the Matrix package. |
| 18 | + } |
| 19 | +} |
| 20 | +\value{ |
| 21 | + A numerical vector or matrix containing the values the warping function h. |
| 22 | +} |
| 23 | +\details{ |
| 24 | + This function evaluates a strictly monotone function of the form |
| 25 | + \deqn{h(x) = [D^{-1} exp(Wfdobj)](x),} |
| 26 | + where \eqn{D^{-1}} means taking the indefinite integral. The interval over |
| 27 | + which the integration takes places is defined in the basis object in Wfdobj. |
| 28 | +} |
| 29 | +\references{ |
| 30 | + Ramsay, James O., Hooker, G. and Graves, S. (2009), \emph{Functional |
| 31 | + Data Analysis with R and Matlab}, Springer, New York. |
| 32 | + |
| 33 | + Ramsay, James O., and Silverman, |
| 34 | + Bernard W. (2005), \emph{Functional |
| 35 | + Data Analysis, 2nd ed.}, Springer, New York. |
| 36 | + |
| 37 | + Ramsay, James O., and Silverman, |
| 38 | + Bernard W. (2002), \emph{Applied |
| 39 | + Functional Data Analysis}, Springer, New York. |
| 40 | +} |
| 41 | +\author{ |
| 42 | + J. O. Ramsay |
| 43 | +} |
| 44 | +\seealso{ |
| 45 | + \code{\link{mongrad}}, |
| 46 | + \code{\link{landmarkreg}}, |
| 47 | + \code{\link{smooth.morph}}, |
| 48 | + \code{\link{smooth.morph2}} |
| 49 | +} |
| 50 | +\examples{ |
| 51 | + |
| 52 | +## basically this example resembles part of landmarkreg.R that uses monfn.R to |
| 53 | +## estimate the warping function. |
| 54 | + |
| 55 | +## Specify the curve subject to be registered |
| 56 | +n=21 |
| 57 | +tbreaks = seq(0, 2*pi, len=n) |
| 58 | +xval <- sin(tbreaks) |
| 59 | +rangeval <- range(tbreaks) |
| 60 | + |
| 61 | +## Establish a B-spline basis for the curve |
| 62 | +wbasis <- create.bspline.basis(rangeval=rangeval, breaks=tbreaks) |
| 63 | +Wfd0 <- fd(matrix(0,wbasis$nbasis,1),wbasis) |
| 64 | +WfdPar <- fdPar(Wfd0, 1, 1e-4) |
| 65 | +fdObj <- smooth.basis(tbreaks, xval, WfdPar)$fd |
| 66 | + |
| 67 | +## Set the mean landmark times. Note that the objective of the warping |
| 68 | +## function is to transform the curve such that the landmarks of the curve |
| 69 | +## occur at the designated mean landmark times. |
| 70 | + |
| 71 | +## Specify the mean landmark times: tbreak[8]=2.2 and tbreaks[13]=3.76 |
| 72 | +meanmarks <- c(rangeval[1], tbreaks[8], tbreaks[13], rangeval[2]) |
| 73 | +## Specify landmark locations of the curve: tbreaks[6] and tbreaks[16] |
| 74 | +cmarks <- c(rangeval[1], tbreaks[6], tbreaks[16], rangeval[2]) |
| 75 | + |
| 76 | +## Establish a B-basis object for the warping function |
| 77 | +Wfd = smooth.morph(x=meanmarks, y=cmarks, WfdPar=WfdPar)$Wfdobj |
| 78 | + |
| 79 | +## Estimate the warping function |
| 80 | +h = monfn(tbreaks, Wfd) |
| 81 | + |
| 82 | +## scale using a linear equation h such that h(0)=0 and h(END)=END |
| 83 | +b <- (rangeval[2]-rangeval[1])/ (h[n]-h[1]) |
| 84 | +a <- rangeval[1] - b*h[1] |
| 85 | +h <- a + b*h |
| 86 | +plot(tbreaks, h, xlab="Time", ylab="Transformed time", type="b") |
| 87 | +} |
| 88 | + |
0 commit comments