Learn R Programming

SCBmeanfd (version 1.1)

scb.mean: Build Simultaneous Confidence Bands for Mean Functions

Description

Fit a local linear estimator and build simultaneous confidence bands (SCB) for the mean of functional data.

Usage

scb.mean(x, y, bandwidth, level = 0.95, scbtype = c("normal", "bootstrap", "both", "no"), gridsize, keep.y = TRUE, nrep = NULL, nboot = NULL, parallel = c("no", "multicore", "snow"), ncpus = getOption( "boot.ncpus", 1L), cl = NULL)

Arguments

x
a numeric vector of x data. x must be a uniform grid; missing values are not accepted.
y
a matrix or data frame with functional observations (= curves) stored in rows. The number of columns of y must match the length of x. Missing values are not accepted.
bandwidth
the kernel bandwidth smoothing parameter.
level
the level of the simultaneous confidence bands.
scbtype
the type of simultaneous confidence bands to build: "normal", "bootstrap", "both", or "no".
gridsize
the size of the grid used to evaluate the mean function estimates and SCB. Defaults to length(x).
keep.y
logical; if TRUE, keep y in the result.
nrep
number of replicates for the Gaussian SCB method (20,000 by default).
nboot
number of replicates for the bootstrap SCB method (5,000 by default).
parallel
the computation method for the SCB. By default, computations are sequential ("no"). The bootstrap method uses function boot and can be run in parallel using the package parallel. In this case both options "multicore" and "snow" are available.
ncpus
number of cores to use for parallel computing when parallel = "multicore".
cl
name of the cluster to use for parallel computing when parallel = "snow".

Value

An object of class "SCBand". To accommodate the different functions creating objects of this class (scb.mean, scb.model, and scb.equality), some components of the object are set to NULL. The component list is:
x
the x data.
y
the y data if keep.y is TRUE, else NULL.
call
the function call.
model
NULL.
par
NULL.
nonpar
a nonparametric estimate.
bandwidth
the argument bandwidth.
degree
the degree of local polynomial used. Currently, only local linear estimation is supported.
level
the argument level.
scbtype
the argument type.
teststat
NULL.
pnorm
NULL.
pboot
NULL.
qnorm
the quantile used to build the normal SCB.
qboot
the quantile used to build the bootstrap SCB.
normscb
a matrix containing the normal SCB stored in columns.
bootscb
a matrix containing the bootstrap SCB stored in columns.
gridsize
the argument gridsize if nonnull, else length(x).
nrep
the argument nrep.
nboot
the argument nboot.
Depending on the value of scbtype, some of the fields qnorm, normscb, nrep, qboot, normboot and nboot may be NULL.

Details

The local polynomial fitting uses a standard normal kernel and is implemented via the locpoly function. Bootstrap SCB are implemented with the boot function and the typically require more computation time than normal SCB. If parallel computing is used while running R from the console, errors may occur. It may be safer to perform parallel computations using R from the command line.

References

Degras, D. (2011). Simultaneous confidence bands for nonparametric regression with functional data. Statistica Sinica, 21, 1735--1765.

See Also

scb.equal, scb.model

Examples

Run this code
## Not run: 
# ## Plasma citrate data
# data(plasma)
# time <- 8:21
# h <- cv.select(time, plasma, 1, c(.5, 1))
# scbplasma <- scb.mean(time, plasma, bandwidth = h, scbtype = "both", gridsize = 100)
# scbplasma
# plot(scbplasma, cex = .2, legend.cex = .85, xlab = "Time", ylab = "Concentration", 
#   main = "Plasma citrate data")
# ## End(Not run)

Run the code above in your browser using DataLab