rp.flm.statistic: Statistics for testing the functional linear model using...

Description Usage Arguments Details Value Author(s) References Examples

View source: R/rp.flm.test.R

Description

Computes the Cramer-von Mises (CvM) and Kolmogorov-Smirnov (KS) statistics on the projected process

T_{n, h}(u)=1/n∑_{i = 1}^n (Y_i - <X_i, \hat β>)1_{<X_i, h> ≤ u},

designed to test the goodness-of-fit of a functional linear model with scalar response.

Usage

1
rp.flm.statistic(proj.X, residuals, proj.X.ord = NULL, F.code = TRUE)

Arguments

proj.X

matrix of size c(n, n.proj) containing, for each column, the projections of the functional data X_1,…,X_n into a random direction h. Not required if proj.X.ord is provided.

residuals

the residuals of the fitted functional linear model, Y_i - <X_i, \hat β, Y_i>. Either a vector of length n (same residuals for all projections) or a matrix of size c(n.proj, n) (each projection has an associated set residuals).

proj.X.ord

matrix containing the row permutations of proj.X which rearranges them increasingly, for each column. So, for example proj.X[proj.X.ord[, 1], 1] equals sort(proj.X[, 1]). If not provided, it is computed internally.

F.code

whether to use faster FORTRAN code or R code.

Details

NA's are not allowed neither in the functional covariate nor in the scalar response.

Value

A list containing:

statistic

a matrix of size c(n.proj, 2) with the CvM (first column) and KS (second) statistics, for the n.proj different projections.

proj.X.ord

the computed row permutations of proj.X, useful for recycling in subsequent calls to rp.flm.statistic with the same projections but different residuals.

Author(s)

Eduardo García-Portugués (edgarcia@est-econ.uc3m.es) and Manuel Febrero-Bande (manuel.febrero@usc.es).

References

Cuesta-Albertos, J.A., García-Portugués, E., Febrero-Bande, M. and González-Manteiga, W. (2019). Goodness-of-fit tests for the functional linear model based on randomly projected empirical processes. Annals of Statistics, 47(1):439-467. https://doi.org/10.1214/18-AOS1693

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
# Simulated example
set.seed(345678)
t <- seq(0, 1, l = 101)
n <- 100
X <- r.ou(n = n, t = t)
beta0 <- fdata(mdata = cos(2 * pi * t) - (t - 0.5)^2, argvals = t,
               rangeval = c(0,1))
Y <- inprod.fdata(X, beta0) + rnorm(n, sd = 0.1)

# Linear model
mod <- fregre.pc(fdataobj = X, y = Y, l = 1:3)

# Projections
proj.X1 <- inprod.fdata(X, r.ou(n = 1, t = t))
proj.X2 <- inprod.fdata(X, r.ou(n = 1, t = t))
proj.X12 <- cbind(proj.X1, proj.X2)

# Statistics
t1 <- rp.flm.statistic(proj.X = proj.X1, residuals = mod$residuals)
t2 <- rp.flm.statistic(proj.X = proj.X2, residuals = mod$residuals)
t12 <- rp.flm.statistic(proj.X = proj.X12, residuals = mod$residuals)
t1$statistic
t2$statistic
t12$statistic

# Recycling proj.X.ord
rp.flm.statistic(proj.X.ord = t1$proj.X.ord, residuals = mod$residuals)$statistic
t1$statistic

# Sort in the columns
cbind(proj.X12[t12$proj.X.ord[, 1], 1], proj.X12[t12$proj.X.ord[, 2], 2]) -
apply(proj.X12, 2, sort)

# FORTRAN and R code
rp.flm.statistic(proj.X = proj.X1, residuals = mod$residuals)$statistic -
rp.flm.statistic(proj.X = proj.X1, residuals = mod$residuals,
                 F.code = FALSE)$statistic

# Matrix and vector residuals
rp.flm.statistic(proj.X = proj.X12, residuals = mod$residuals)$statistic
rp.flm.statistic(proj.X = proj.X12,
                 residuals = rbind(mod$residuals, mod$residuals * 2))$statistic

egarpor/rp.flm.test documentation built on Oct. 20, 2021, 12:31 a.m.