Baselearners for Functional Covariates
Description
Baselearners that fit effects of functional covariates.
Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16  bsignal(x, s, index = NULL, inS = c("smooth", "linear", "constant"),
knots = 10, boundary.knots = NULL, degree = 3, differences = 1,
df = 4, lambda = NULL, center = FALSE, cyclic = FALSE, Z = NULL,
penalty = c("ps", "pss"), check.ident = FALSE)
bconcurrent(x, s, time, index = NULL, knots = 10, boundary.knots = NULL,
degree = 3, differences = 1, df = 4, lambda = NULL, cyclic = FALSE)
bhist(x, s, time, index = NULL, limits = "s<=t", standard = c("no",
"time", "length"), intFun = integrationWeightsLeft, inS = c("smooth",
"linear", "constant"), inTime = c("smooth", "linear", "constant"),
knots = 10, boundary.knots = NULL, degree = 3, differences = 1,
df = 4, lambda = NULL, penalty = c("ps", "pss"), check.ident = FALSE)
bfpc(x, s, index = NULL, df = 4, lambda = NULL, pve = 0.99,
npc = NULL, npc.max = 15, getEigen = TRUE)

Arguments
x 
matrix of functional variable x(s). The functional covariate has to be supplied as n by <no. of evaluations> matrix, i.e. each row is one functional observation. 
s 
vector for the index of the functional variable x(s) giving the measurement points of the functional covariate. 
index 
a vector of integers for expanding the signal variable in 
inS 
historical effect can be smooth, linear or constant in s, which is the index of the functional covariates x(s). 
knots 
either the number of knots or a vector of the positions
of the interior knots (for more details see 
boundary.knots 
boundary points at which to anchor the Bspline basis (default the range of the data). A vector (of length 2) for the lower and the upper boundary knot can be specified. 
degree 
degree of the regression spline. 
differences 
a nonnegative integer, typically 1, 2 or 3. Defaults to 1.
If 
df 
trace of the hat matrix for the baselearner defining the
baselearner complexity. Low values of 
lambda 
smoothing parameter of the penalty, computed from 
center 
experimental implementation! See 
cyclic 
if 
Z 
a transformation matrix for the designmatrix over the index of the covariate.

penalty 
by default, 
check.ident 
use checks for identifiability of the effect, based on Scheipl and Greven (2016)
for linear functional effect using 
time 
vector for the index of the functional response y(time) giving the measurement points of the functional response. 
limits 
defaults to 
standard 
the historical effect can be standardized with a factor. "no" means no standardization, "time" standardizes with the current value of time and "length" standardizes with the length of the integral 
intFun 
specify the function that is used to compute integration weights in 
inTime 
historical effect can be smooth, linear or constant in time, which is the index of the functional response y(time). 
pve 
proportion of variance explained: used to choose the number of functional principal components (FPCs). 
npc 
prespecified value for the number of FPCs (if given, this overrides 
npc.max 
maximal number K of FPCs to use, regardless of 
getEigen 
save the eigenvalues and eigenvectors, defaults to 
Details
bsignal
implements a baselearner for functional covariates to
estimate an effect of the form \int x_i(s)β(s)ds. Defaults to a cubic
Bspline basis with first difference penalties for β(s) and numerical
integration over the entire range by using trapezoidal Riemann weights.
If bsignal
is used within FDboost
, the baselearner of
timeformula
is attached, resulting in an effect varying over the index
of the response \int x_i(s)β(s, t)ds.
The functional variable must be observed on one common grid s
.
bconcurrent
implements a concurrent effect for a functional covariate
on a functional response, i.e., an effect of the form x_i(t)β(t) for
a functional response Y_i(t) and concurrently observed covariate x_i(t).
bconcurrent
can only be used if Y(t) and x(s) are observed over
the same domain s,t \in [T1, T2].
Note that in the case of bhist
the argument index
is treated
like a variable and thus has to be given as variable in newdata
,
if predict.FDboost
is with argument newdata
.
bhist
implements a baselearner for functional covariates with
flexible integration limits l(t)
, r(t)
and the possibility to
standardize the effect by 1/t
or the length of the integration interval.
The effect is stand * \int_{l(t)}^{r_{t}} x(s)β(t,s)ds.
The baselearner defaults to a historical effect of the form
\int_{T1}^{t} x_i(s)β(t,s)ds,
where T1 is the minimal index of t of the response Y(t).
bhist
can only be used if Y(t) and x(s) are observed over
the same domain s,t \in [T1, T2].
The functional variable must be observed on one common grid s
,
see Brockhaus et al. (2016) for details on historical effects.
bfpc
is a baselearner for a linear effect of functional covariates based on
functional principal component analysis (FPCA).
For the funcitonal linear effect \int x_i(s)β(s)ds the functional covariate
and the coefficient function are represented by a FPC basis.
The functional covariate
x(s) is decomposed into x(s) \approx ∑_{k=1}^K ξ_{ik} Φ_k(s) using
fpca.sc
for the truncated KarhunenLoeve decomposition.
Then β(s) is represented in the function
space spanned by Φ_k(s), see Scheipl et al. (2015) for details.
The implementation is similar to ffpc
.
This is an experimental baselearner and not well tested yet.
It is recommended to use centered functional covariates with
∑_i x_i(s) = 0 for all s in bsignal
,
bhist
 and bconcurrent
terms.
For centered covariates, the effects are centered per timepoint of the response.
If all effects are centered, the functional intercept
can be interpreted as the global mean function.
The baselearners for functional covariates cannot deal with any missing values in the covariates.
Value
Equally to the baselearners of package mboost:
An object of class blg
(baselearner generator) with a
dpp
function (dpp, data preprocessing).
The call of dpp
returns an object of class
bl
(baselearner) with a fit
function. The call to
fit
finally returns an object of class bm
(basemodel).
References
Brockhaus, S., Scheipl, F., Hothorn, T. and Greven, S. (2015): The functional linear array model. Statistical Modelling, 15(3), 279300.
Brockhaus, S., Melcher, M., Leisch, F. and Greven, S. (2016): Boosting flexible functional regression models with a high number of functional historical effects, Statistics and Computing, accepted.
Marra, G. and Wood, S.N. (2011): Practical variable selection for generalized additive models. Computational Statistics & Data Analysis, 55, 23722387.
Scheipl, F., Staicu, A.M. and Greven, S. (2015): Functional Additive Mixed Models, Journal of Computational and Graphical Statistics, 24(2), 477501.
Scheipl, F. and Greven, S. (2016): Identifiability in penalized functiononfunction regression models. Electronic Journal of Statistics, 10(1), 495526.
See Also
FDboost
for the model fit.
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104  ######## Example for scalaronfunctionregression with bsignal
data("fuelSubset", package = "FDboost")
## center the functional covariates per observed wavelength
fuelSubset$UVVIS < scale(fuelSubset$UVVIS, scale = FALSE)
fuelSubset$NIR < scale(fuelSubset$NIR, scale = FALSE)
## to make mboost:::df2lambda() happy (all design matrix entries < 10)
## reduce range of argvals to [0,1] to get smaller integration weights
fuelSubset$uvvis.lambda < with(fuelSubset, (uvvis.lambda  min(uvvis.lambda)) /
(max(uvvis.lambda)  min(uvvis.lambda) ))
fuelSubset$nir.lambda < with(fuelSubset, (nir.lambda  min(nir.lambda)) /
(max(nir.lambda)  min(nir.lambda) ))
mod2 < FDboost(heatan ~ bsignal(UVVIS, uvvis.lambda, knots=40, df=4, check.ident=FALSE)
+ bsignal(NIR, nir.lambda, knots=40, df=4, check.ident=FALSE),
timeformula=NULL, data=fuelSubset)
summary(mod2)
## plot(mod2)
###############################################
### data simulation like in manual of pffr::ff
if(require(refund)){
#########
# model with linear functional effect, use bsignal()
# Y(t) = f(t) + \int X1(s)\beta(s,t)ds + eps
set.seed(2121)
data1 < pffrSim(scenario = "ff", n = 40)
data1$X1 < scale(data1$X1, scale = FALSE)
dat_list < as.list(data1)
dat_list$t < attr(data1, "yindex")
dat_list$s < attr(data1, "xindex")
## model fit by FDboost
m1 < FDboost(Y ~ 1 + bsignal(x= X1, s = s, knots = 5),
timeformula = ~ bbs(t, knots = 5), data=dat_list,
control = boost_control(mstop = 21))
## search optimal mSTOP
## Not run:
set.seed(123)
cv < validateFDboost(m1, grid = 1:100) # 21 iterations
## End(Not run)
## model fit by pffr
t < attr(data1, "yindex")
s < attr(data1, "xindex")
m1_pffr < pffr(Y ~ ff(X1, xind=s), yind=t, data=data1)
## Not run:
par(mfrow = c(2, 2))
plot(m1, which = 1); plot(m1, which = 2)
plot(m1_pffr, select = 1, shift = m1_pffr$coefficients["(Intercept)"])
plot(m1_pffr, select = 2)
## End(Not run)
############################################
# model with functional historical effect, use bhist()
# Y(t) = f(t) + \int_0^t X1(s)\beta(s,t)ds + eps
set.seed(2121)
mylimits < function(s, t){
(s < t)  (s == t)
}
data2 < pffrSim(scenario = "ff", n = 40, limits = mylimits)
data2$X1 < scale(data2$X1, scale = FALSE)
dat2_list < as.list(data2)
dat2_list$t < attr(data2, "yindex")
dat2_list$s < attr(data2, "xindex")
## model fit by FDboost
m2 < FDboost(Y ~ 1 + bhist(x = X1, s = s, time = t, knots = 5),
timeformula = ~ bbs(t, knots = 5), data = dat2_list,
control = boost_control(mstop = 40))
## search optimal mSTOP
## Not run:
set.seed(123)
cv2 < validateFDboost(m2, grid = 1:100) # 40 iterations
## End(Not run)
## model fit by pffr
t < attr(data2, "yindex")
s < attr(data2, "xindex")
m2_pffr < pffr(Y ~ ff(X1, xind = s, limits = "s<=t"), yind = t, data = data2)
## Not run:
par(mfrow = c(2, 2))
plot(m2, which = 1); plot(m2, which = 2)
## plot of smooth intercept does not contain m1_pffr$coefficients["(Intercept)"]
plot(m2_pffr, select = 1, shift = m2_pffr$coefficients["(Intercept)"])
plot(m2_pffr, select = 2)
## End(Not run)
}
