Library: | glm |
See also: | glmest glmstat eigsm |
Quantlet: | glmdiagh | |
Description: | glmdiagh calculates the diagonal elements of the 'hat' matrix |
Usage: | h = glmdiagh(bv,x{,w}) | |
Input: | ||
bv | p x p matrix, the estimated covariance matrix for the coefficients. | |
x | n x p matrix, the matrix of (observed) regressor variables. | |
w | optional, n x 1 matrix, the weights used to estimate the coefficients. | |
Output: | ||
h | n x 1 matrix, the diagonal elements of the `hat' matrix: W'^(1/2)X(X'WX)^(-1) X'W^(1/2). |
library("glm") n = 100 b = 2|(-1) x = normal(n,rows(b)) m = ceil(uniform(n).*5) {y,p} = genglm("bilo",x,b,m) opt=glmopt("wx",m) l = glmest("bilo",x,y,opt) d=glmlld("bilo",x*b,y,opt) h=glmdiagh(l.bv,x, -m.*d.ll2)
Vector of diagonal elements of the hat matrix.