Skip to content

Commit f4286ba

Browse files
author
Giles Hooker
committed
updates to landmarkreg and smooth.basis.sparse
1 parent 46a3713 commit f4286ba

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

R/landmarkreg.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ landmarkreg <- function(unregfd, ximarks, x0marks, x0lim=NULL,
103103

104104
if (is.null(WfdPar)) {
105105
Wnbasis <- length(x0marks) + 2
106-
Ybasis <- create.bspline.basis(rangeval, Wnbasis)
106+
Wbasis <- create.bspline.basis(rangeval, Wnbasis)
107107
Wfd <- fd(matrix(0,Wnbasis,1), Wbasis)
108108
WfdPar <- fdPar(Wfd, 2, 1e-10)
109109
} else {

R/smooth.basis.sparse.R

+17-6
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,25 @@ smooth.basis.sparse <- function(argvals, y, fdParobj, fdnames=NULL, covariates=N
7272
}
7373
}
7474
}
75-
coefs = matrix(0, nrow = basisobj$nbasis, ncol = dim(data)[2])
76-
for(i in 1:dim(data)[2]){
77-
curve = data[,i]
78-
curve.smooth = smooth.basis(time[!is.na(curve)],curve[!is.na(curve)],
75+
if(length(dim(y)) == 2){
76+
coefs = matrix(0, nrow = basisobj$nbasis, ncol = dim(y)[2])
77+
for(i in 1:dim(y)[2]){
78+
curve = y[,i]
79+
curve.smooth = smooth.basis(time[!is.na(curve)],curve[!is.na(curve)],
7980
basisobj, covariates, method)
80-
coefs[,i] = curve.smooth$fd$coefs
81+
coefs[,i] = curve.smooth$fd$coefs
82+
}
83+
} else if(length(dim(y) == 3){
84+
coefs = array(0, c(basisobj$nbasis,dim(y)[2:3]))
85+
for(i in 1:dim(y)[2]){
86+
for(j in 1:dim(y)[3]){
87+
curve = y[,i,j]
88+
curve.smooth = smooth.basis(time[!is.na(curve)],curve[!is.na(curve)],
89+
basisobj, covariates, method)
90+
coefs[,i,j] = curve.smooth$fd$coefs
91+
}
92+
}
8193
}
8294
datafd = fd(coefs,basisobj, fdnames)
83-
8495
return(datafd)
8596
}

0 commit comments

Comments
 (0)