Learn R Programming

SCBmeanfd (version 1.2.2)

scb.model: 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. 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.
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 gridsize spanning the range of x.
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 length(x).
keep.y
logical; if TRUE, keep y in the result.
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 ("no"). The function boot is used and can be run in parallel using the package parallel. Both options "multicore" and "snow" are available for parallel computing.
ncpus
the number of cores to use for parallel computing when parallel = "multicore".
cl
the 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.equal), some components of the object are set to NULL. The component list is: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

scb.equal, scb.mean

Examples

Run this code
## 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

Run the code above in your browser using DataLab