plrt.model: Pseudo-Likelihood Ratio Test for Models of the Mean Function

Description Usage Arguments Value References See Also Examples

View source: R/plrt.model.R

Description

Implement the Pseudo-Likelihood Ratio Test (PLRT) of Azzalini and Bowman (1993) with functional data. The test is used to assess whether a mean function belongs to a given finite-dimensional function space.

Usage

1
 plrt.model(x, y, model, verbose = FALSE) 

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 at x.

verbose

logical; if TRUE, information on the candidate model, kernel bandwidth, test statistic, and p value is printed; otherwise no print.

Value

the p value of the PLRT.

References

Azzalini, A. and Bowman, A. (1993). On the use of nonparametric regression for checking linear relationships. Journal of the Royal Statistical Society. Series B 55, 549-557.

See Also

scb.model

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
## Example: Gaussian process with mean = linear function + bump 
## and Onstein-Uhlenbeck covariance. The bump is high in the y   
## direction and narrow in the x direction. The SCB and PLRT 
## tests are compared.

# The departure from linearity in the mean function is strong  
# in the supremum norm (SCB test) but mild in the euclidean norm 
# (PLRT). With either n = 20 or n = 100 curves, the SCB test 
# strongly rejects the incorrect linear model for the mean 
# function while the PLRT retains it. 

p    <- 100    # number of observation points
x 	  <- seq(0, 1, len = p)
mu <- -1 + 1.5 * x + 0.2 * dnorm(x, .6, .02) 
plot(x, mu, type = "l")
R 	  <- (.25)^2 * exp(20 * log(.9) * abs(outer(x,x,"-"))) # covariance 
eigR <- eigen(R, symmetric = TRUE)  	
simR <- eigR$vectors %*% diag(sqrt(eigR$values)) 	 

n  <- 20
set.seed(100)
y  <- mu + simR %*% matrix(rnorm(n*p), p, n) 		
y  <- t(y) 	
points(x, colMeans(y))									
h  <- cv.select(x, y, 1)	
scb.model(x, y, 1, bandwidth = h)		 # p value: <1e-16
plrt.model(x, y, 1, verbose = TRUE)	# p value: .442
n  <- 100
y  <- mu + simR %*% matrix(rnorm(n*p), p, n) 		
y  <- t(y) 	
h  <- cv.select(x, y, 1)	
scb.model(x, y, 1, bandwidth = h)		 # p value: <1e-16
plrt.model(x, y, 1, verbose = TRUE)	# p value: .456

Example output

Goodness-of-fit test
Model for the mean function: linear
Bandwidth: 0.0051 
SCB type: normal 
Significance level: 0.05 
Test statistic and p value
  stat   p     
  136.8  <1e-16

Pseudo-Likelihood Ratio Test
Model for the mean function: linear
Bandwidth: 0.02 
Test statistic and p value
     F      p
 11.11 0.4057

Goodness-of-fit test
Model for the mean function: linear
Bandwidth: 0.0051 
SCB type: normal 
Significance level: 0.05 
Test statistic and p value
  stat   p     
  236.3  <1e-16

Pseudo-Likelihood Ratio Test
Model for the mean function: linear
Bandwidth: 0.02 
Test statistic and p value
     F      p
 11.26 0.4822

SCBmeanfd documentation built on May 2, 2019, 4:19 a.m.