Skip to content

Commit a29a0ed

Browse files
authored
Update smooth.monotone.R
1 parent bbf7d50 commit a29a0ed

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

R/smooth.monotone.R

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ smooth.monotone <- function(argvals, y, WfdParobj, wtvec=rep(1,n),
2727
# curves. If this is not the case, you will need to
2828
# run this function inside one or more loops, smoothing
2929
# each curve separately.
30-
# Y ... Function value array (the values to be fit).
30+
# y ... Function value array (the values to be fit).
3131
# If the functional data are univariate, this array will
3232
# be an N by NCURVE matrix, where N is the number of
3333
# observed curve values for each curve and NCURVE is the
3434
# number of curves observed.
35-
# If the functional data are muliivariate, this array will
35+
# If the functional data are mulivariate, this array will
3636
# be an N by NCURVE by NVAR matrix, where NVAR the number
3737
# of functions observed per case. For example, for the
3838
# gait data, NVAR = 2, since we observe knee and hip
@@ -128,14 +128,18 @@ nbasis <- basisobj$nbasis # number of basis functions
128128
# set up initial coefficient array
129129

130130
coef0 <- Wfdobj$coefs
131-
if(ncol(coef0) != ncol(Y)){
132-
if(ncol(coef0) == 1){
133-
coef0 = matrix(coef0,basisobj$nbasis,ncol(Y),byrow=FALSE)
134-
}else{
135-
coef0 = matrix(0,basisobj$nbasis,ncol(Y),byrow=FALSE)
136-
}
131+
if(length(dim(coef0)) == 2 & nvar != 1){
132+
coef0 = array(0,nbasis,ncurve,nvar)
137133
}
138-
134+
if( dim(coef0) == 2 & ncol(coef0) ! = ncurve){
135+
coef0 = matrix(0,nbasis,ncurve)
136+
}
137+
if( dim(coef0) == 3 & !all.equal(dim(coef0)[2:3],c(ncurve,nvar)) ){
138+
coef0 = array(0,nbasis,ncurve,nvar)
139+
}
140+
# Note that we could be more carefull about this and try to adapt coefficients
141+
# if they have something like the right shape, but I'm not sure we can do
142+
# so in any reasonable way.
139143

140144
# check WTVEC
141145

0 commit comments

Comments
 (0)