Skip to content

Commit 5d44f38

Browse files
author
Giles Hooker
committed
Giles fixing fRegress and intercepts
1 parent ea822f1 commit 5d44f38

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

R/fRegress.double.R

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,10 @@ fRegress.double <- function(y, xfdlist, betalist, wt=NULL,
135135

136136
betacoef <- Cmatinv %*% Dmat
137137

138-
# compute degrees of freedom measure
139-
140-
df <- sum(diag(Zmat %*% Cmatinv %*% t(Zmat)))
138+
# df <- sum(diag(Zmat %*% Cmatinv %*% t(Zmat)))
139+
140+
hatvals = diag(Zmat %*% Cmatinv %*% t(Zmat))
141+
df <- sum(hatvals)
141142

142143
# set up fdPar object for BETAESTFDPAR
143144

@@ -186,6 +187,11 @@ fRegress.double <- function(y, xfdlist, betalist, wt=NULL,
186187
}
187188
yhatfdobj <- yhatmat
188189

190+
# Calculate OCV and GCV scores
191+
192+
OCV = sum( (ymat-yhatmat)^2/(1-hatvals)^2 )
193+
GCV = sum( (ymat-yhatmat)^2 )/( (sum(1-hatvals))^2 )
194+
189195
# -----------------------------------------------------------------------
190196
# Compute pointwise standard errors of regression coefficients
191197
# if both y2cMap and SigmaE are supplied.
@@ -246,6 +252,8 @@ fRegress.double <- function(y, xfdlist, betalist, wt=NULL,
246252
Cmatinv = Cmatinv,
247253
wt = wt,
248254
df = df,
255+
GCV = GCV,
256+
OCV = OCV,
249257
y2cMap = y2cMap,
250258
SigmaE = SigmaE,
251259
betastderrlist = betastderrlist,

R/fRegress.formula.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ fRegress.formula <- function(y, data=NULL, betalist=NULL,
311311
if(is.numeric(xfdlist[[i]])) {
312312
# if xfdlist[[i]] is numeric, basis is set up using that of dependent variable y
313313
if(is.numeric(y)) {
314-
bbasis <- create.constant.basis(trng)
314+
bbasis <- create.constant.basis(c(0,1))
315315
bfd <- fd(basisobj=bbasis)
316316
betalist[[i]] <- fdPar(bfd)
317317
} else {

0 commit comments

Comments
 (0)