Skip to content

Commit 3d8781f

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

21 files changed

+96
-306
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
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
Lines changed: 4 additions & 4 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 24 additions & 16 deletions
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

Lines changed: 0 additions & 54 deletions
This file was deleted.

man/StatSciChinese.Rd

Lines changed: 0 additions & 54 deletions
This file was deleted.

man/as.array3.Rd

Lines changed: 5 additions & 4 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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

0 commit comments

Comments
 (0)