@@ -27,12 +27,12 @@ smooth.monotone <- function(argvals, y, WfdParobj, wtvec=rep(1,n),
27
27
# curves. If this is not the case, you will need to
28
28
# run this function inside one or more loops, smoothing
29
29
# each curve separately.
30
- # Y ... Function value array (the values to be fit).
30
+ # y ... Function value array (the values to be fit).
31
31
# If the functional data are univariate, this array will
32
32
# be an N by NCURVE matrix, where N is the number of
33
33
# observed curve values for each curve and NCURVE is the
34
34
# number of curves observed.
35
- # If the functional data are muliivariate , this array will
35
+ # If the functional data are mulivariate , this array will
36
36
# be an N by NCURVE by NVAR matrix, where NVAR the number
37
37
# of functions observed per case. For example, for the
38
38
# gait data, NVAR = 2, since we observe knee and hip
@@ -128,14 +128,18 @@ nbasis <- basisobj$nbasis # number of basis functions
128
128
# set up initial coefficient array
129
129
130
130
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 )
137
133
}
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.
139
143
140
144
# check WTVEC
141
145
0 commit comments