Skip to content

Commit 647791b

Browse files
committed
Updates of 1 november 2020
1 parent fcdbf51 commit 647791b

File tree

4 files changed

+21
-44
lines changed

4 files changed

+21
-44
lines changed

R/fRegress.formula.R

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ fRegress.formula <- function(y, data=NULL, betalist=NULL,
1212
method=c('fRegress', 'model'),
1313
sep='.', ...) {
1414

15-
# Last modified 30 October 2020 by Jim Ramsay
16-
17-
print("inside fRegress.formula")
15+
# Last modified 1 November 2020 by Jim Ramsay
1816

1917
##
2018
## 1. get y = left hand side of the formula
@@ -376,11 +374,8 @@ fRegress.formula <- function(y, data=NULL, betalist=NULL,
376374
return(fRegressList)
377375
} else {
378376
if(inherits(y, 'fd')) {
379-
print("dispatching fRegress")
380-
# fRegress(y, xfdlist, betalist, wt)
381377
do.call('fRegress.fd', fRegressList)
382378
} else {
383-
print("dispatching fRegress.numeric")
384379
do.call('fRegress.double', fRegressList)
385380
}
386381
}

R/fRegress.numeric.R

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,10 @@ fRegress.numeric <- function(y, xfdlist, betalist, wt=NULL,
5151
# as predict(List). In this call List can be any object of the
5252
# "".
5353

54-
# Last modified 25 August 2020 by Jim Ramsay
54+
# Last modified 1 November 2020 by Jim Ramsay
5555

5656
# check Y and compute sample size N
5757

58-
print("inside fRegress.numeric")
59-
6058
if (!inherits(y, "numeric")) stop("Y is not a numeric vector.")
6159

6260
# ----------------------------------------------------------------
@@ -74,16 +72,12 @@ fRegress.numeric <- function(y, xfdlist, betalist, wt=NULL,
7472
N <- dim(ymat)[1]
7573
p <- length(xfdlist)
7674

77-
print("preliminaries")
78-
7975
Zmat <- NULL
8076
Rmat <- NULL
8177
pjvec <- rep(0,p)
8278
ncoef <- 0
8379
for (j in 1:p) {
84-
print(j)
8580
xfdj <- xfdlist[[j]]
86-
print(class(xfdj))
8781
xcoef <- xfdj$coefs
8882
xbasis <- xfdj$basis
8983
betafdParj <- betalist[[j]]
@@ -92,7 +86,6 @@ fRegress.numeric <- function(y, xfdlist, betalist, wt=NULL,
9286
pjvec[j] <- bnbasis
9387
Jpsithetaj <- inprod(xbasis,bbasis)
9488
Zmat <- cbind(Zmat,crossprod(xcoef,Jpsithetaj))
95-
print("betafdParj$estimate")
9689
if (betafdParj$estimate) {
9790
lambdaj <- betafdParj$lambda
9891
if (lambdaj > 0) {
@@ -116,8 +109,6 @@ fRegress.numeric <- function(y, xfdlist, betalist, wt=NULL,
116109
# set up the linear equations for the solution
117110
# -----------------------------------------------------------
118111

119-
print("Cmat and Dmat")
120-
121112
# solve for coefficients defining BETA
122113

123114
if (any(wt != 1)) {
@@ -131,21 +122,16 @@ fRegress.numeric <- function(y, xfdlist, betalist, wt=NULL,
131122
Dmat <- t(Zmat) %*% ymat
132123
}
133124

134-
# print("solving")
135-
136125
eigchk(Cmat)
137126

138127
Cmatinv <- solve(Cmat)
139128

140129
betacoef <- Cmatinv %*% Dmat
141130

142-
143-
# compute and print degrees of freedom measure
131+
# compute degrees of freedom measure
144132

145133
df <- sum(diag(Zmat %*% Cmatinv %*% t(Zmat)))
146134

147-
print("betaestlist")
148-
149135
# set up fdPar object for BETAESTFDPAR
150136

151137
betaestlist <- betalist
@@ -167,8 +153,6 @@ fRegress.numeric <- function(y, xfdlist, betalist, wt=NULL,
167153

168154
# set up fd object for predicted values
169155

170-
print("yhatmat")
171-
172156
yhatmat <- matrix(0,N,1)
173157
for (j in 1:p) {
174158
xfdj <- xfdlist[[j]]
@@ -200,8 +184,6 @@ fRegress.numeric <- function(y, xfdlist, betalist, wt=NULL,
200184
# if both y2cMap and SigmaE are supplied.
201185
# -----------------------------------------------------------------------
202186

203-
print("standard errors")
204-
205187
if (!(is.null(y2cMap) || is.null(SigmaE))) {
206188

207189
# check dimensions of y2cMap and SigmaE

man/fRegress.Rd

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -503,17 +503,17 @@ TempRgn.f <- fRegress(Temp.fd ~ region, CanadianWeather)
503503
## Get the default setup and possibly modify it
504504
##
505505

506-
TempRgn.mdl <- fRegress(tempfd ~ region, CanadianWeather, method='m')
506+
TempRgn.mdl <- fRegress(Temp.fd ~ region, CanadianWeather, method='m')
507507

508508
# make desired modifications here
509509
# then run
510510

511511
TempRgn.m <- do.call('fRegress', TempRgn.mdl)
512512

513513
# no change, so match the first run
514-
# \dontshow{stopifnot(}
515-
# all.equal(TempRgn.m, TempRgn.f)
516-
# \dontshow{)}
514+
\dontshow{stopifnot(}
515+
all.equal(TempRgn.m, TempRgn.f)
516+
\dontshow{)}
517517

518518
##
519519
## More detailed set up
@@ -536,16 +536,16 @@ region.fdlist <- list(const=rep(1, 35),
536536
region.Pacific=region.fd.Pacific)
537537
str(TempRgn.mdl$betalist)
538538

539-
beta1 <- with(tempfd, fd(basisobj=basis, fdnames=fdnames))
539+
beta1 <- with(Temp.fd, fd(basisobj=basis, fdnames=fdnames))
540540
beta0 <- fdPar(beta1)
541541
betalist <- list(const=beta0, region.Atlantic=beta0,
542542
region.Continental=beta0, region.Pacific=beta0)
543543

544-
TempRgn <- fRegress(tempfd, region.fdlist, betalist)
544+
TempRgn <- fRegress(Temp.fd, region.fdlist, betalist)
545545

546-
# \dontshow{stopifnot(}
547-
# all.equal(TempRgn, TempRgn.f)
548-
# \dontshow{)}
546+
\dontshow{stopifnot(}
547+
all.equal(TempRgn, TempRgn.f)
548+
\dontshow{)}
549549

550550
###
551551
###
@@ -585,9 +585,9 @@ betalist <- list(const=fdPar(beta0), hipfd=fdPar(beta1))
585585

586586
fRegressout <- fRegress(kneefd, xfdlist, betalist)
587587

588-
# #\dontshow{stopifnot(}
589-
# all.equal(fRegressout, knee.hip.f)
590-
# #\dontshow{)}
588+
\dontshow{stopifnot(}
589+
all.equal(fRegressout, knee.hip.f)
590+
\dontshow{)}
591591

592592
#See also the following demos:
593593

man/predict.fRegress.Rd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ weight <- c(ctl, trt)
9393

9494
fRegress.D9 <- fRegress(weight ~ group)
9595

96-
#pred.fR.D9 <- predict(fRegress.D9)
96+
pred.fR.D9 <- predict(fRegress.D9)
9797
# Now compare with 'lm'
98-
#lm.D9 <- lm(weight ~ group)
99-
#pred.lm.D9 <- predict(lm.D9)
98+
lm.D9 <- lm(weight ~ group)
99+
pred.lm.D9 <- predict(lm.D9)
100100

101-
#\dontshow{stopifnot(}
102-
#all.equal(as.vector(pred.fR.D9), as.vector(pred.lm.D9))
103-
#\dontshow{)}
101+
\dontshow{stopifnot(}
102+
all.equal(as.vector(pred.fR.D9), as.vector(pred.lm.D9))
103+
\dontshow{)}
104104

105105
##
106106
## vector response with functional explanatory variable

0 commit comments

Comments
 (0)