scb.model {SCBmeanfd} | R Documentation |
Goodness-Of-Fit of a Model for the Mean Function
Description
This is the goodness-of-fit test for parametric models of the mean function described in Degras (2011). The candidate model must be a finite-dimensional function space (curvilinear regression). The test is based on the sup-norm distance between a smoothed parametric estimate and a local linear estimate. Graphically, the candidate model is retained whenever one of the estimates lies within the SCB built around the other.
Usage
scb.model(x, y, model, bandwidth, level = .05, degree = 1,
scbtype = c("normal","bootstrap","both","no"), gridsize = length(x),
keep.y = TRUE, nrep = 2e4, nboot = 5e3, parallel = c("no", "multicore", "snow"),
ncpus = getOption("boot.ncpus",1L), cl = NULL)
Arguments
x |
a numeric vector of x data. |
y |
a matrix or data frame with functional observations (= curves) stored in rows. The number of columns of |
model |
an integer specifying the degree of a polynomial basis, or a data frame/matrix containing the basis functions stored in columns. In the latter case, the basis functions must be evaluated on a uniform grid of size |
bandwidth |
the kernel bandwidth smoothing parameter. |
level |
the significance level of the test (default = .05). |
degree |
the degree of the local polynomial fit. |
scbtype |
the type of simultaneous confidence bands to build: "normal", "bootstrap", "both", or "no". |
gridsize |
the size of the grid over which the mean function is to be estimated. Defaults to |
keep.y |
logical; if |
nrep |
the number of replicates for the normal SCB method (default = 20,000). |
nboot |
the number of replicates for the bootstrap SCB method (default = 5,000). |
parallel |
the computation method for the bootstrap SCB. By default, computations are sequential ( |
ncpus |
the number of cores to use for parallel computing when |
cl |
the name of the cluster to use for parallel computing when |
Value
An object of class "SCBand"
. To accommodate the different functions creating objects of this class (scb.mean
, scb.model
, and scb.equal
), some components of the object are set to NULL
. The component list is:
x |
the argument |
y |
the argument |
call |
the function call. |
model |
the argument |
par |
a smoothed parametric estimate. |
nonpar |
a local linear estimate. |
bandwidth |
the argument |
degree |
the degree of the local polynomial. Currently, only local linear estimation is supported. |
level |
the argument |
scbtype |
the argument |
teststat |
the test statistic. |
pnorm |
the p value for the normal-based statistical test. |
pboot |
the p value for the boostrap-based statistical test. |
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 |
nrep |
the argument |
nboot |
the argument |
Depending on the value of scbtype
, some or all of
the fields pnorm
, qnorm
, normscb
, nrep
, pboot
, qboot
, normboot
and nboot
may be NULL
.
References
Degras, D. (2011). Simultaneous confidence bands for nonparametric regression with functional data.
Statistica Sinica, 21, 1735–1765.
See Also
Examples
## Example from Degras (2011)
## Gaussian process with polynomial mean function
## and Ornstein-Uhlenbeck covariance function
## The SCB and PLRT tests are compared
set.seed(100)
p <- 100 # number of observation points
x <- seq(0, 1, len = p)
mu <- 10 * x^3 - 15 * x^4 + 6 * x^5 # mean
R <- (.25)^2 * exp(20 * log(.9) * abs(outer(x,x,"-"))) # covariance
eigR <- eigen(R, symmetric = TRUE)
simR <- eigR$vectors %*% diag(sqrt(eigR$values))
# Candidate model for mu: polynomial of degree <= 3
# This model, although incorrect, closely approximates mu.
# With n = 50 curves, the SCB and PLRT incorrectly retain the model.
# With n = 70 curves, both tests reject it.
n <- 50
y <- mu + simR %*% matrix(rnorm(n*p), p, n) # simulate data
y <- t(y) # arrange the trajectories in rows
h <- cv.select(x, y, 1)
scb.model(x, y, 3, bandwidth = h) # p value: .652
plrt.model(x, y, 3, verbose = TRUE) # p value: .450
n <- 70
y <- mu + simR %*% matrix(rnorm(n*p), p, n)
y <- t(y)
h <- cv.select(x, y, 1)
scb.model(x, y, 3, bandwidth = h) # p value: .004
plrt.model(x, y, 3, verbose = TRUE) # p value: .001
# Correct model: polynomials of degree <= 5
scb.model(x, y, 5, bandwidth = h) # p value: .696
plrt.model(x, y, 5, verbose = TRUE) # p value: .628