Pm {DCCA} | R Documentation |
Creates the m+1
by m+1
projection matrix defined by P = D(D'D)^{-1}D'
where D
is the design matrix associated to a polynomial regression of degree nu + 1.
Pm(m = 2, nu = 0)
nu |
the degree of the polinomial fit. |
m |
a positive integer satisfying |
To perform matrix inversion, the code makes use of the routine DGETRI in LAPACK, which applies an LU decomposition approach to obtain the inverse matrix. See the LAPACK documentation available at http://www.netlib.org/lapack.
an m+1
by m+1
matrix.
Taiane Schaedler Prass
P = Pm(m = 5, nu = 0)
P
n = 10
t = 1:n
D = cbind(rep(1,n),t,t^2)
# Calculating in R
PR = D%*%solve(t(D)%*%D)%*%t(D)
# Using the provided function
P = Pm(m = n-1, nu = 1)
# Difference:
sum(abs(P-PR))