Description Usage Arguments Details Value Author(s) References Examples
Tests the composite null hypothesis of a Functional Linear Model with scalar response (FLM),
H_0: Y = <X, β> + ε vs H_1: Y != <X, β> + ε.
If β=β_0 is provided, then the simple hypothesis H_0: Y = <X, β_0> + ε is tested. The way of testing the null hypothesis is via a norm (Cramer-von Mises or Kolmogorov-Smirnov) in the empirical process indexed by the projections.
1 2 3 |
X.fdata |
functional observations in the class |
Y |
scalar responses for the FLM. Must be a vector with the same number of elements as functions are in |
beta0.fdata |
functional parameter for the simple null hypothesis, in the |
B |
number of bootstrap replicates to calibrate the distribution of the test statistic. |
n.proj |
vector with the number of projections to consider. The maximum number must be smaller than |
est.method |
estimation method for β, only used in the composite case. There are three methods:
|
p |
number of elements for the basis representation of |
p.criterion |
for |
pmax |
maximum size of the basis expansion to consider in when using |
type.basis |
type of basis if |
projs |
a |
verbose |
whether to show or not information about the testing progress. |
... |
further arguments passed to |
No NA's are allowed neither in the functional covariate nor in the scalar response.
An object with class "htest"
whose underlying structure is a list containing the following components:
p.values.fdr
a matrix of size c(n.proj, 2)
, containing in each row the FDR p-values of the CvM and KS tests up to that projection.
proj.statistics
a matrix of size c(max(n.proj), 2)
with the value of the test statistic on each projection.
boot.proj.statistics
an array of size c(max(n.proj), 2, B)
with the values of the bootstrap test statistics for each projection.
proj.p.values
a matrix of size c(max(n.proj), 2)
method
information about the test performed and the kind of estimation performed.
B
number of bootstrap replicates used.
n.proj
number of projections specified
projs
random directions employed to project X.fdata
.
type.basis
type of basis for est.method = "basis"
.
beta.est
estimated functional parameter \hat β in the composite hypothesis. For the simple hypothesis, beta0.fdata
.
p
number of basis elements considered for estimation of β.
p.criterion
criterion employed for selecting p
.
data.name
the character string "Y = <X, b> + e"
Eduardo García-Portugués (edgarcia@est-econ.uc3m.es) and Manuel Febrero-Bande (manuel.febrero@usc.es).
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
García-Portugués, E., González-Manteiga, W. and Febrero-Bande, M. (2014). A goodness-of-fit test for the functional linear model with scalar response. Journal of Computational and Graphical Statistics, 23(3), 761–778. http://dx.doi.org/10.1080/10618600.2013.812519
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | # Simulated example
set.seed(345678)
t <- seq(0, 1, l = 101)
n <- 100
X <- r.ou(n = n, t = t, alpha = 2, sigma = 0.5)
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)
## Not run:
# Test all cases
rp.flm.test(X.fdata = X, Y = Y, est.method = "pc")
rp.flm.test(X.fdata = X, Y = Y, est.method = "pls")
rp.flm.test(X.fdata = X, Y = Y, est.method = "basis",
p.criterion = fda.usc::GCV.S)
rp.flm.test(X.fdata = X, Y = Y, est.method = "pc", p = 5)
rp.flm.test(X.fdata = X, Y = Y, est.method = "pls", p = 5)
rp.flm.test(X.fdata = X, Y = Y, est.method = "basis", p = 5)
rp.flm.test(X.fdata = X, Y = Y, beta0.fdata = beta0)
## End(Not run)
# Composite hypothesis: do not reject FLM
rp.test <- rp.flm.test(X.fdata = X, Y = Y, est.method = "pc")
rp.test$p.values.fdr
pcvm.test <- flm.test(X.fdata = X, Y = Y, est.method = "pc", B = 1e3,
plot.it = FALSE)
pcvm.test
# Estimation of beta
par(mfrow = c(1, 3))
plot(X, main = "X")
plot(beta0, main = "beta")
lines(rp.test$beta.est, col = 2)
lines(pcvm.test$beta.est, col = 3)
plot(density(Y), main = "Density of Y", xlab = "Y", ylab = "Density")
rug(Y)
## Not run:
# Simple hypothesis: do not reject beta = beta0
rp.flm.test(X.fdata = X, Y = Y, beta0.fdata = beta0)$p.values.fdr
flm.test(X.fdata = X, Y = Y, beta0.fdata = beta0, B = 1e3, plot.it = FALSE)
# Simple hypothesis: reject beta = beta0^2
rp.flm.test(X.fdata = X, Y = Y, beta0.fdata = beta0^2)$p.values.fdr
flm.test(X.fdata = X, Y = Y, beta0.fdata = beta0^2, B = 1e3, plot.it = FALSE)
## End(Not run)
## Not run:
# Increasing n.proj
rp.flm.test(X.fdata = X, Y = Y, n.proj = 3, verbose = FALSE)$p.values.fdr
rp.flm.test(X.fdata = X, Y = Y, n.proj = 5, verbose = FALSE)$p.values.fdr
# Increasing B
rp.flm.test(X.fdata = X, Y = Y, B = 1e3, verbose = FALSE)$p.values.fdr
rp.flm.test(X.fdata = X, Y = Y, B = 5e3, verbose = FALSE)$p.values.fdr
## End(Not run)
## Not run:
# Tecator dataset
# Load data
data(tecator)
absorp <- tecator$absorp.fdata
ind <- 1:215 # sometimes ind <- 1:129
x <- absorp[ind, ]
y <- tecator$y$Fat[ind]
# Composite hypothesis
rp.tecat <- rp.flm.test(X.fdata = x, Y = y, verbose = FALSE, B = 1e4)
rp.tecat$p.values.fdr
# Compare with flm.test
pcvm.tecat <- flm.test(X.fdata = x, Y = y, verbose = FALSE, p = rp.tecat$p,
B = 1e4, plot.it = FALSE)
pcvm.tecat
# Simple hypothesis
zero <- fdata(mdata = rep(0, length(x$argvals)), argvals = x$argvals,
rangeval = x$rangeval)
rp.flm.test(X.fdata = x, Y = y, beta0.fdata = zero, verbose = FALSE, B = 1e4)
flm.test(X.fdata = x, Y = y, beta0.fdata = zero, B = 1e3)
# With derivatives
rp.tecat.1 <- rp.flm.test(X.fdata = fdata.deriv(x, 1), Y = y, verbose = FALSE,
B = 1e4)
rp.tecat.1$p.values.fdr
rp.tecat.2 <- rp.flm.test(X.fdata = fdata.deriv(x, 2), Y = y, verbose = FALSE,
B = 1e4)
rp.tecat.2$p.values.fdr
## End(Not run)
## Not run:
# AEMET dataset
# Load data
data(aemet)
wind.speed <- apply(aemet$wind.speed$data, 1, mean)
temp <- aemet$temp
# Remove the 5% of the curves with less depth (i.e. 4 curves)
par(mfrow = c(1, 1))
res.FM <- depth.FM(temp, draw = TRUE)
qu <- quantile(res.FM$dep, prob = 0.05)
l <- which(res.FM$dep <= qu)
lines(aemet$temp[l], col = 3)
# Data without outliers
wind.speed <- wind.speed[-l]
temp <- temp[-l]
# Composite hypothesis
rp.aemet <- rp.flm.test(X.fdata = temp, Y = wind.speed, verbose = FALSE,
B = 1e4)
rp.aemet$p.values.fdr
# Compare with flm.test
pcvm.aemet <- flm.test(X.fdata = temp, Y = wind.speed, B = 1e4,
p = rp.aemet$p, verbose = FALSE, plot.it = FALSE)
pcvm.aemet
# Simple hypothesis
zero <- fdata(mdata = rep(0, length(temp$argvals)), argvals = temp$argvals,
rangeval = temp$rangeval)
rp.flm.test(X.fdata = temp, Y = wind.speed, beta0.fdata = zero,
verbose = FALSE, B = 1e4)
flm.test(X.fdata = temp, Y = wind.speed, beta0.fdata = zero, B = 1e4,
plot.it = FALSE, verbose = FALSE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.