How to create a program to compute the Hii of the Hat Marix in matlab?

3 views (last 30 days)
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 Comments
amj
amj on 10 Jan 2018
Edited: amj on 10 Jan 2018
This is the code without using csv file:
a = [1 20;1 30;1 40]
for i = 1:length(a)
disp(a(i,:)'.*(a'*a).*a(i,:))
end
But, the result i got as 2x2 matrix not as expected

Sign in to comment.

Accepted Answer

the cyclist
the cyclist on 10 Jan 2018
Is this what you want?
x = rand(10,1);
i = 3;
x(i)' .* x'*x .* x(i)
  3 Comments
the cyclist
the cyclist on 10 Jan 2018
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.
amj
amj on 11 Jan 2018
Edited: amj on 11 Jan 2018
Dear The cyclist,
Let me try.
Thanks you very much

Sign in to comment.

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!