Library: | xplore |
See also: | xdiag diag diagrv |
Quantlet: | xdiagp | |
Description: | calculates the diagonal elements of a projection matrix X(X'X)^(-1) X' or (diag(w)^(1/2))X(X'diag(w)X)^(-1) X'diag(w)^(1/2); the calculation may be performed with a weight vector W. |
Usage: | d = xdiagp (x {,w}) | |
Input: | ||
x | n x p matrix | |
w | optional, n x 1 weight vector | |
Output: | ||
d | n x 1 vector of diagonal elements of the projection matrix X(X'X)^(-1) X' or (diag(w)^(1/2))X(X'diag(w)X)^(-1) X'diag(w)^(1/2) |
library("xplore") n=10 x=(1:n)~matrix(n) xdiagp(x)
Contents of d [ 1,] 0.34545 [ 2,] 0.24848 [ 3,] 0.17576 [ 4,] 0.12727 [ 5,] 0.10303 [ 6,] 0.10303 [ 7,] 0.12727 [ 8,] 0.17576 [ 9,] 0.24848 [10,] 0.34545
library("xplore") n=5 x=(1:n)~matrix(n) w = sqrt((1:n)) xdiagp(x, w)
Contents of d [1,] 0.6 [2,] 0.42426 [3,] 0.34641 [4,] 0.6 [5,] 1.3416