Skip to content

Commit 7c586c5

Browse files
committed
minor updates to fda code
1 parent eca0189 commit 7c586c5

23 files changed

+605
-881
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
.Ruserdata
55
.Rbuildignore
66

7+
inst/doc

DESCRIPTION

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
Package: fda
2-
Version: 5.5.1
3-
Date: 2021-11-16
2+
Version: 5.5.2
3+
Date: 2022-03-04
44
Title: Functional Data Analysis
55
Author: J. O. Ramsay <ramsay@psych.mcgill.ca> [aut,cre],
66
Spencer Graves <spencer.graves@effectivedefense.org> [ctb],
77
Giles Hooker <gjh27@cornell.edu> [ctb]
88
Maintainer: J. O. Ramsay <ramsay@psych.mcgill.ca>
9-
Depends: R (>= 3.5), splines, Matrix, fds, deSolve
10-
Suggests: lattice
9+
Depends: R (>= 3.5), splines, fds, deSolve
10+
Suggests:
11+
rmarkdown,
12+
knitr,
13+
lattice
1114
Description: These functions were developed to support functional data
1215
analysis as described in Ramsay, J. O. and Silverman, B. W.
1316
(2005) Functional Data Analysis. New York: Springer and in
@@ -21,3 +24,4 @@ License: GPL (>= 2)
2124
URL: http://www.functionaldata.org
2225
LazyData: true
2326
NeedsCompilation: no
27+
VignetteBuilder: knitr

NAMESPACE

+4-5
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ export(AmpPhaseDecomp,
9797
monhess,
9898
monomial,
9999
monomialpen,
100-
norder, norder.bspline,
100+
norder,
101+
norder.bspline,
101102
objAndNames,
102103
odesolv,
103104
pca.fd,
@@ -127,10 +128,10 @@ export(AmpPhaseDecomp,
127128
predict.fdSmooth,
128129
project.basis,
129130
quadset,
130-
reconsCurves,
131+
reconsCurves,
131132
register.fd,
132133
register.newfd,
133-
scoresPACE,
134+
scoresPACE,
134135
sd.fd,
135136
std.fd,
136137
stdev.fd,
@@ -142,7 +143,6 @@ export(AmpPhaseDecomp,
142143
smooth.fdPar,
143144
smooth.monotone,
144145
smooth.morph,
145-
smooth.morph2,
146146
smooth.pos,
147147
smooth.basis.sparse,
148148
smooth.sparse.mean,
@@ -170,7 +170,6 @@ export(AmpPhaseDecomp,
170170
import("graphics")
171171
import("stats")
172172
import("splines")
173-
import("Matrix")
174173
import("fds")
175174
import("deSolve")
176175

R/.DS_Store

0 Bytes
Binary file not shown.

R/basisfd.R

+9-6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ basisfd <- function(type, rangeval, nbasis, params, dropind=vector("list",0),
2020
# "power" "pow"
2121
# RANGEVAL...an array of length 2 containing the lower and upper
2222
# boundaries for (the rangeval of argument values
23+
# If basis is of FEM type, rangeval is not used
2324
# NBASIS ... the number of basis functions
2425
# PARAMS ... If the basis is "fourier", this is a single number indicating
2526
# the period. That is, the basis functions are periodic on
@@ -212,13 +213,15 @@ basisfd <- function(type, rangeval, nbasis, params, dropind=vector("list",0),
212213
stop("'type' unrecognizable.")
213214
}
214215

215-
# check rangeval
216+
# check rangeval if the object is not of type FEM
216217

217-
rangeval = as.vector(rangeval)
218-
if (!is.numeric(rangeval)) stop("Argument rangeval is not numeric.")
219-
if (length(rangeval) != 2) stop("Argument rangeval is not of length 2.")
220-
if (!(rangeval[2] > rangeval[1]))
221-
stop("Argument rangeval is not strictly increasing.")
218+
if (!type == "FEM") {
219+
rangeval = as.vector(rangeval)
220+
if (!is.numeric(rangeval)) stop("Argument rangeval is not numeric.")
221+
if (length(rangeval) != 2) stop("Argument rangeval is not of length 2.")
222+
if (!(rangeval[2] > rangeval[1]))
223+
stop("Argument rangeval is not strictly increasing.")
224+
}
222225

223226
# check nbasis
224227

R/bsplineS.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ bsplineS <- function (x, breaks, norder=4, nderiv=0, returnMatrix=FALSE)
4747
nbasis <- nbreaks + norder - 2
4848
if (nbasis >= norder) {
4949
if (nbasis > 1) {
50-
basismat <- Matrix(splines::spline.des(knots, x, norder, derivs)$design)
50+
basismat <- splines::spline.des(knots, x, norder, derivs)$design
5151
} else {
5252
basismat <- as.matrix(splines::spline.des(knots, x, norder, derivs)$design)
5353
}

R/create.bspline.basis.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ create.bspline.basis <- function (rangeval=NULL, nbasis=NULL,
9595
# Returns
9696
# BASISFD ...a functional data basis object
9797

98-
# Last modified 11 February 2015 by Jim Ramsay
98+
# Last modified 19 November 2021 by Jim Ramsay
9999

100100
# -------------------------------------------------------------------------
101101
# Default basis for missing arguments: A B-spline basis over [0,1] of

R/fdParcheck.R

+1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ fdParcheck = function(fdParobj, ncurve=NULL) {
1616
}
1717
}
1818
return(fdParobj)
19+
1920
}

R/landmarkreg.R

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
landmarkreg <- function(fdobj, ximarks, x0marks=xmeanmarks,
22
WfdPar=NULL, monwrd=FALSE, ylambda=1e-10)
3-
{
3+
{
44
# Arguments:
55
# FDOBJ ... functional data object for curves to be registered
66
# XIMARKS ... N by NL array of times of interior landmarks for
@@ -125,8 +125,7 @@ landmarkreg <- function(fdobj, ximarks, x0marks=xmeanmarks,
125125
# smooth relation between this curve"s values and target"s values
126126
if (monwrd) {
127127
# use monotone smoother
128-
# Wfd <- smooth.morph(xval, yval, WfdPar)$Wfdobj
129-
Wfds <- smooth.morph(xval, yval, WfdPar)
128+
Wfds <- smooth.morph(xval, yval, wrange, WfdPar)
130129
Wfd <- Wfds$Wfdobj
131130
h <- monfn(x, Wfd)
132131
b <- (rangeval[2]-rangeval[1])/(h[n]-h[1])
@@ -160,7 +159,7 @@ landmarkreg <- function(fdobj, ximarks, x0marks=xmeanmarks,
160159
wcoef <- Wfd$coefs
161160
Wfdinv <- fd(-wcoef,wbasis)
162161
WfdParinv <- fdPar(Wfdinv, wLfd, wlambda)
163-
Wfdinv <- smooth.morph(h, x, WfdParinv)$Wfdobj
162+
Wfdinv <- smooth.morph(h, x, wrange, WfdParinv)$Wfdobj
164163
hinv <- monfn(x, Wfdinv)
165164
b <- (rangeval[2]-rangeval[1])/(hinv[n]-hinv[1])
166165
a <- rangeval[1] - b*hinv[1]

0 commit comments

Comments
 (0)