PCvM statistic for the Functional Linear Model with scalar response
Source:R/Adot.R
PCvM.statistic.Rd
Projected Cramer-von Mises statistic (PCvM) for the Functional Linear Model with scalar response (FLM): \(Y=\big<X,\beta\big>+\varepsilon\).
Arguments
- X
Functional covariate for the FLM. The object must be either in the class
fdata
or in the class fd. It is used to compute the matrix of inner products.- inpr
Matrix of inner products of
X
. Computed if not given.- residuals
Residuals of the estimated FLM.
- p
Number of elements of the functional basis where the functional covariate is represented.
- Adot.vec
Output from the
Adot
function (see Details). Computed if not given.
Value
For PCvM.statistic
, the value of the statistic. For Adot
,
a suitable output to be used in the argument Adot.vec
.
Details
In order to optimize the computation of the statistic, the critical parts
of these two functions are coded in FORTRAN. The hardest part corresponds to the
function Adot
, which involves the computation of a symmetric matrix of dimension
\(n\times n\) where each entry is a sum of \(n\) elements.
As this matrix is symmetric, the order of the method can be reduced from \(O(n^3)\)
to \(O\big(\frac{n^3-n^2}{2}\big)\). The memory requirement can also be reduced
to \(O\big(\frac{n^2-n+2}{2}\big)\). The value of Adot
is a vector of
length \(\frac{n^2-n+2}{2}\) where the first element is the common diagonal
element and the rest are the lower triangle entries of the matrix, sorted by rows (see Examples).
References
Escanciano, J. C. (2006). A consistent diagnostic test for regression models using projections. Econometric Theory, 22, 1030-1051. doi:10.1017/S0266466606060506
Garcia-Portugues, E., Gonzalez-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. doi:10.1080/10618600.2013.812519
Author
Eduardo Garcia-Portugues. Please, report bugs and suggestions to eduardo.garcia.portugues@uc3m.es
Examples
# Functional process
X=rproc2fdata(n=10,t=seq(0,1,l=101))
# Adot
Adot.vec=Adot(X)
# Obtain the entire matrix Adot
Ad=diag(rep(Adot.vec[1],dim(X$data)[1]))
Ad[upper.tri(Ad,diag=FALSE)]=Adot.vec[-1]
Ad=t(Ad)
Ad=Ad+t(Ad)-diag(diag(Ad))
Ad
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
#> [1,] 34.55752 22.56919 23.42445 22.48372 21.52212 22.14313 22.24761 23.16975
#> [2,] 22.56919 34.55752 23.11677 23.22390 22.88832 23.43477 23.72314 22.61706
#> [3,] 23.42445 23.11677 34.55752 22.27545 23.64458 23.07480 23.11521 22.74769
#> [4,] 22.48372 23.22390 22.27545 34.55752 22.87413 23.14084 22.75209 23.15580
#> [5,] 21.52212 22.88832 23.64458 22.87413 34.55752 23.21242 24.01934 22.70983
#> [6,] 22.14313 23.43477 23.07480 23.14084 23.21242 34.55752 23.14678 22.84749
#> [7,] 22.24761 23.72314 23.11521 22.75209 24.01934 23.14678 34.55752 22.38071
#> [8,] 23.16975 22.61706 22.74769 23.15580 22.70983 22.84749 22.38071 34.55752
#> [9,] 23.19679 22.08812 23.39765 22.85707 23.26055 22.92071 22.78013 22.67189
#> [10,] 23.56713 24.23112 23.34407 23.32780 23.06404 23.78524 24.01663 23.20940
#> [,9] [,10]
#> [1,] 23.19679 23.56713
#> [2,] 22.08812 24.23112
#> [3,] 23.39765 23.34407
#> [4,] 22.85707 23.32780
#> [5,] 23.26055 23.06404
#> [6,] 22.92071 23.78524
#> [7,] 22.78013 24.01663
#> [8,] 22.67189 23.20940
#> [9,] 34.55752 23.34617
#> [10,] 23.34617 34.55752
# Statistic
PCvM.statistic(X,residuals=rnorm(10),p=5)
#> [1] 4.21528