How to create a program to compute the Hii of the Hat Marix in matlab?
2 次查看(过去 30 天)
显示 更早的评论
I'm facing with the problem to compute the Hii of the Hat Matrix at shown in the picture.
Can anyone help me on how to compute? It is supposed to get a single values. However, in my code, it is appeared as 2x2 matrix. Thanks in advance
4 个评论
采纳的回答
the cyclist
2018-1-10
Is this what you want?
x = rand(10,1);
i = 3;
x(i)' .* x'*x .* x(i)
3 个评论
the cyclist
2018-1-10
I misinterpreted your notation in the example. I believe you can calculate the diagonal element as
a = [1 20;1 30;1 40]
i = 3;
Hii = a(i,:) * inv(a'*a) * a(i,:)'
and the full H matrix as
H = a * inv(a'*a) * a'
There is probably a more efficient way to calculate that, rather than using the full inverse, but I am too lazy to figure it out.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!