[Gretl-users] Re: scalar and matrices
Sebastiano Putoto
sebastiano.putoto01 at universitadipavia.it
Tue May 26 13:22:30 EDT 2009
Sorry, I did not mean that
> The quantity generated should be a scalar, however.
but indeed tha the quantity indicated in blue is a scalar, so is not
concerned with conformability. Which is the point where I don't understand
Gretl.
2009/5/26 Sebastiano Putoto <sebastiano.putoto01 at universitadipavia.it>
> Good evening fellow Gretlians,
>
> I am trying to run this command sheet but it doesn't work.
>
> function LEVERAGE(matrix X, matrix y, matrix *u, matrix *h)
>> matrix beta = inv(X'X)*X'*y # calculates coeffs through OLS
>> matrix u = y - X*beta # residuals
>> matrix Px = X'(inv(X'X))*X # orthogonal projector Px
>> matrix h = diag(Px) # extract the elements fromt Px's diagonal
>> matrix dif={}
>> loop i=1..rows(X) --progressive # loop to work on each observation
>> matrix xi = X[i,] #exctracting rows from X
>> scalar u_i = u[i,]
>> scalar h_i = h[i,]
>> matrix dif[i,] = (-u_i/(1-h_i))*(inv(X'X)* xi) #calculate the
>> difference between beta(t) and beta. <--- THESE - I SUPPOSE - ARE THE
>> POINTS WHEN IT DOESN'T WORK.
>> end loop
>> return matrix dif
>> end function
>>
>> open ESERCIZIO4.gdt
>> include LEVERAGE
>> matrix X={const, inv_gdp}
>> matrix y={gdp_pw_g}
>> matrix u
>> matrix h
>> dif = LEVERAGE ( X, y, &u, &h) <--- THESE - I SUPPOSE - ARE THE POINTS
>> WHEN IT DOESN'T WORK.
>> print
>>
>
> The idea is evaluating the leverage of observations, using the command
> editor. However, when trying to create the dif matrix, using the leverage
> function on an assigned dataset (included) it tells me them are not
> conformable.
>
> The quantity generated should be a scalar, however. When using this command
> **
>
>> matrix dif[i,] = (-u_i/(1-h_i))*(inv(X'X)* xi),
>>
> am i not telling Gretl to multiply a scalar (blue) by a matricial form
> (green)?
>
> Hope the explanation is clear, and that you will be able to help me with
> this matter.
>
> --
> Cordiali saluti/Salutations/Best Regards
>
> Sebastiano Putoto
>
--
Cordiali saluti/Salutations/Best Regards
Sebastiano Putoto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wfu.edu/pipermail/gretl-users/attachments/20090526/80ebd58e/attachment.htm
More information about the Gretl-users
mailing list