Skip to content

Commit 3d8781f

Browse files
James RamsayJames Ramsay
James Ramsay
authored and
James Ramsay
committed
update
1 parent 87c52d7 commit 3d8781f

21 files changed

+96
-306
lines changed

.Rbuildignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ revdep
55
^.*\.Rproj$
66
^\.Rproj\.user$
77
fda_release_to_CRAN.R
8+
^CRAN-SUBMISSION$

DESCRIPTION

100644100755
+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Package: fda
2-
Version: 6.1.3
3-
Date: 2023-04-24
2+
Version: 6.1.4
3+
Date: 2023-05-23
44
Title: Functional Data Analysis
55
Authors@R: c(person("James", "Ramsay",
66
role=c("aut","cre"),
7-
email="james.ramsay@mcgill.ca"),
7+
email="ramsay@psych.mcgill.ca"),
88
person("Giles", "Hooker",
99
role="ctb",
1010
email="gjh27@cornell.edu"),
@@ -29,5 +29,5 @@ Description: These functions were developed to support functional data
2929
License: GPL (>= 2)
3030
URL: http://www.functionaldata.org
3131
LazyData: true
32-
NeedsCompilation: no
32+
NeedsCompilation: yes
3333
VignetteBuilder: knitr

NAMESPACE

+2
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ S3method(density, fd)
195195
S3method(deriv, fd)
196196
S3method(lines, fd)
197197
S3method(mean, fd)
198+
S3method(matrix, matplot)
199+
S3method(numeric, matplot)
198200
S3method(norder, fd)
199201
S3method(plot, fd)
200202
S3method(predict, fd)

R/smooth.morph.R

+24-16
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,18 @@ smooth.morph <- function(x, y, ylim, WfdPar,
4040
# WFD Functional data object for W. It's coefficient vector
4141
# contains the optimized coefficients.
4242

43-
# last modified 3 June 2022 by Jim Ramsay
43+
# last modified 17 May 2023 by Jim Ramsay
4444

45-
nobs <- length(x) # number of observations
45+
# number of observations and weights on x-values
46+
47+
nobs <- length(x)
4648
wt <- matrix(1,nobs,1)
4749
wt[nobs] <- 10
4850

51+
# -----------------------------------------------------
52+
# Check arguments
53+
# -----------------------------------------------------
54+
4955
# check consistency of x and y and convert to column matrices
5056

5157
if (length(y) != nobs) {
@@ -81,10 +87,13 @@ smooth.morph <- function(x, y, ylim, WfdPar,
8187
}
8288

8389
# -----------------------------------------------------
84-
# extract information from WfdPar
90+
# Initialize optimization
8591
# -----------------------------------------------------
8692

93+
# extract information from WfdPar
94+
8795
Wfdobj <- WfdPar$fd
96+
cvec <- Wfdobj$coef # initial coefficients
8897
Wbasis <- Wfdobj$basis # basis for Wfdobj
8998
Wnbasis <- Wbasis$nbasis # no. basis functions
9099
Wrange <- Wbasis$rangeval
@@ -96,20 +105,22 @@ smooth.morph <- function(x, y, ylim, WfdPar,
96105
stop("One or more weights are negative.")
97106
}
98107

99-
cvec <- Wfdobj$coef # initial coefficients
100-
Zmat <- fda::zerobasis(length(cvec))
101-
bvec <- t(Zmat) %*% cvec
102-
cvec <- Zmat %*% bvec
103-
104-
# check range of x
108+
# check that values in x are within limits in xlim
105109

106110
if (abs(x[1] - xlim[1]) > 1e-7 || abs(x[nobs] - xlim[2]) > 1e-7) {
107-
stop("Values in x are out of bounds by more than 1e-7")
111+
print("Argument vector x is out of range:")
112+
stop("Values are out of bounds by more than 1e-7")
108113
} else {
109114
x[1 ] <- xlim[1]
110115
x[nobs] <- xlim[2]
111116
}
112117

118+
# transform coefficients to zero column sum
119+
120+
Zmat <- fda::zerobasis(length(cvec))
121+
bvec <- t(Zmat) %*% cvec
122+
cvec <- Zmat %*% bvec
123+
113124
# initialize matrix Kmat defining penalty term
114125

115126
if (Wlambda > 0) {
@@ -160,10 +171,6 @@ smooth.morph <- function(x, y, ylim, WfdPar,
160171
iterhist <- matrix(0,iterlim+1,length(status))
161172
iterhist[1,] <- status
162173

163-
# -----------------------------------------------------
164-
# ------------- Begin main iterations ---------------
165-
# -----------------------------------------------------
166-
167174
STEPMAX <- 10
168175
itermax <- 20
169176
TOLX <- 1e-10
@@ -220,7 +227,7 @@ smooth.morph <- function(x, y, ylim, WfdPar,
220227
}
221228

222229
# -----------------------------------------------------
223-
# construct output objects
230+
# construct output objects and return in a list
224231
# -----------------------------------------------------
225232

226233
Wfdobj <- fd(cvec, Wbasis)
@@ -233,7 +240,8 @@ smooth.morph <- function(x, y, ylim, WfdPar,
233240
hwidth <- hmax - hmin
234241
hfine <- (ylim[1] - hmin) + hfine*(ywidth/hwidth)
235242

236-
return(list(Wfdobj=Wfdobj, f=f, grad=grad, hmat=hmat, norm=norm, hfine=hfine,
243+
return(list(Wfdobj=Wfdobj, f=f, grad=grad, hmat=hmat,
244+
norm=norm, hfine=hfine,
237245
iternum=iternum, iterhist=iterhist))
238246

239247
}

data/StatSciChinese.rda

-403 KB
Binary file not shown.

fda_release_to_CRAN.R

-54
This file was deleted.

man/StatSciChinese.Rd

-54
This file was deleted.

man/as.array3.Rd

+5-4
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@ as.array3(x)
6767
##
6868
## 4-d array
6969
##
70-
71-
if(!CRAN()) {
72-
as.array3(array(1:24, 1:4))
73-
}
70+
# These lines throw an error because the dimensionality woud be 4
71+
# and as.array3 only allows dimensions 3 or less.
72+
# if(!CRAN()) {
73+
# as.array3(array(1:24, 1:4))
74+
# }
7475
}
7576
\keyword{utilities}
7677

man/as.fd.Rd

+3-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ lines(x., eval.fd(x., fn.), col='green', lty='dotted', lwd=3)
113113

114114
if(!CRAN()) {
115115
# Will NOT translate a periodic spline
116-
fp <- splinefun(x, y, method='periodic')
117-
as.fd(fp)
118-
#Error in as.fd.function(fp) :
116+
# fp <- splinefun(x, y, method='periodic')
117+
# as.fd(fp)
118+
# Error in as.fd.function(fp) :
119119
# x (fp) uses periodic B-splines, and as.fd is programmed
120120
# to translate only B-splines with coincident boundary knots.
121121
}

man/eval.surp.Rd

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ eval.surp(evalarg, Wfdobj, nderiv = 0)
1919
the set \code{c(0,1,2)}.}
2020
}
2121
\details{A surprisal \code{M}-vector is information measured in \code{M}-bits.
22-
Since a multinomial probability vector must sum to one, it follows that the
23-
surprisal vector \code{S} must satisfy the constraint
22+
Since a multinomial probability vector must sum to one, it follows
23+
that the surprisal vector \code{S} must satisfy the constraint
2424
\code{log_M(sum(M^(-S)) = 0.} That is, surprisal vectors lie within a
2525
curved \code{M-1}-dimensional manifold.
2626

man/fd.Rd

+4-3
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ all.equal(fd.bspl1.1, fd.bspl1.1a)
106106
\dontshow{ ) }
107107
# TRUE
108108

109-
if(!CRAN()) {
110-
fd.bspl1.1b <- fd(0)
111-
}
109+
# the following three lines shown an error in a non-cran check:
110+
# if(!CRAN()) {
111+
# fd.bspl1.1b <- fd(0)
112+
# }
112113

113114
##
114115
## Cubic spline: 4 basis functions

man/fda-package.Rd

+17-60
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,22 @@
1-
\name{fda-package}
2-
\alias{fda-package}
3-
\alias{fda}
41
\docType{package}
5-
\title{Functional Data Analysis in R}
2+
\name{fda}
3+
\alias{fda}
4+
\title{Functions for statistical analyses of functions}
5+
66
\description{
7-
Functions and data sets companion to Ramsay, J. O.; Hooker, Giles; and
8-
Graves, Spencer (2010) Functional Data Analysis with R and Matlab,
9-
plus Ramsay, J. O., and Silverman, B. W. (2006) Functional Data
10-
Analysis, 2nd ed. and (2002) Applied Functional Data Analysis
11-
(Springer). This includes finite bases approximations (such as
12-
splines and Fourier series) to functions fit to data smoothing on the
13-
integral of the squared deviations from an arbitrary differential operator.
14-
}
15-
\details{
16-
\tabular{ll}{
17-
Package: \tab fda\cr
18-
Type: \tab Package\cr
19-
Version: \tab 2.2.6\cr
20-
Date: \tab 2011-02-03\cr
21-
License: \tab GPL-2\cr
22-
LazyLoad: \tab yes\cr
23-
}
24-
}
25-
\author{
26-
J. O. Ramsay, <ramsay@psych.mcgill.ca>, Hadley Wickham
27-
<h.wickham@gmail.com>, Spencer Graves <spencer.graves@prodsyse.com>,
28-
Giles Hooker <gjh27@cornell.edu>
7+
The data analyses that we use for data matrices or dataFrames, such as means, covariances, linear regressions, principal and canonical component analyses, can also be applied to samples of functions or curves. This package provides functional versions of these analyses along with plotting and other assessment tools.
8+
9+
The functions themselves are often a consequence of smoothing discrete data values over domains like time, space, and other continuous variables. Data smoothing tools are also provided.
10+
11+
But there are transformations of functions that have no meaning for data matrices for which rows may be re-ordered. Derivatives and integrals are often used to set up dynamic models, and can also play a constructive role in the data smoothing process. Methods for these and other functional operations are also available in this package.
12+
13+
There are now many texts and papers on functional data analysis. The two resources provided by the buildeers of the fda package are:
14+
15+
James Ramsay and Bernard Silverman (2005) Functional Data Analysis. New York, Springer.
2916

30-
Maintainer: J. O. Ramsay <ramsay@psych.mcgill.ca>
31-
}
32-
\references{
33-
Ramsay, J. O.; Hooker, Giles; and Graves, Spencer (2010)
34-
\emph{Functional Data Analysis with R and Matlab}, Springer, New
35-
York.
17+
James Ramsay, Giles Hooker and Spencer Graves (2009) Functional Data Analysis with R and Matlab. New York: Springer.
3618

37-
Ramsay, James O., and Silverman, Bernard W. (2006), \emph{Functional
38-
Data Analysis, 2nd ed.}, Springer, New York.
19+
Another relevant package is the package Data2LD that offers ann introduction and methods for constructing linear and nonlinear differential equation models, along with the text:
3920

40-
Ramsay, James O., and Silverman, Bernard W. (2002), \emph{Applied
41-
Functional Data Analysis}, Springer, New York.
42-
}
43-
\examples{
44-
##
45-
## As noted in the Preface to Ramsay, Hooker and Graves (p. v),
46-
## the fda package includes scripts to reproduce all but one of the
47-
## figures in the book.
48-
##
49-
## These figures can be found and run as follows:
50-
##
51-
if(!CRAN()){
52-
scriptsDir <- system.file('scripts', package='fda')
53-
Rscripts <- dir(scriptsDir, full.names=TRUE, pattern='R$')
54-
fdarm <- grep('fdarm', Rscripts, value=TRUE)
55-
chapters <- length(fdarm)
56-
# NOTE: If R fails in any of these scripts,
57-
# this for loop will not end normally,
58-
# and the abnormal termination will be displayed:
59-
for(ch in 1:chapters){
60-
cat('Running', fdarm[ch], '\n')
61-
invisible(source(fdarm[ch]))
62-
}
63-
}
64-
}
65-
\keyword{smooth}
21+
James Ramsay and Giles Hooker, Dynamic Data Analysis, New York: Springer.
22+
}

man/norder.Rd

+4-3
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ norder(x, ...)
7070
# 21 breaks, 19 interior knots.
7171
stopifnot(norder(create.bspline.basis()) == 4)
7272

73-
if (!CRAN()) {
74-
norder(create.fourier.basis(c(0,12) ))
73+
# these five lines throw an error of for a nocran check
74+
# if (!CRAN()) {
75+
# norder(create.fourier.basis(c(0,12) ))
7576
# Error in norder.bspline(x) :
7677
# object x is of type = fourier; 'norder' is only defined for type = 'bspline'
77-
}
78+
# }
7879

7980
}
8081
\keyword{smooth}

0 commit comments

Comments
 (0)