On Wed, 27 Jan 2021, Riccardo (Jack) Lucchetti wrote:
On Tue, 26 Jan 2021, Allin Cottrell wrote:
> I've had a go at it -- see what you think. Also please check if the complex
> case is right.
Thanks Allin, I'll give it a go.
OK, I just pushed a one-line change to git so as to have hdprod() behave
sensibly in the complex case with the shorthand syntax hdprod(A).
example script:
<hansl>
set verbose off
n = 4
T = 3
###
### real case
###
X = mnormal(T, n)
Q1 = hdprod(X, X)
Q2 = hdprod(X)
# check
x = X[T,]'
check = x*x'
check1 = mshape(Q1[T,], n, n)
check2 = unvech(Q2[T,]')
print check check1 check2
###
### complex case
###
X = complex(mnormal(T, n), mnormal(T, n))
Q1 = hdprod(X, conj(X))
Q2 = hdprod(X)
# check
x = X[T,]'
check = x*x'
check1 = mshape(Q1[T,], n, n)
check2 = unvech(Q2[T,]')
print check check1 check2
</hansl>
Brief comment on the above: in the real case, each row of the matrix
returned by hdprod(X) can be thought of as the vectorisation of a
symmetric matrix, given by the outer product of the corresponding row of
(X). The "shorthand" syntax allows you to store only the vech of that
matrix, thus saving space.
With the change I just pushed to git, this property is preserved in the
complex case, where the "outer product" is, in most cases, the product of
x by its _conjugate_ transpose.
With this modification, there is the potential for a very nice efficiency
gain in the ghosts package, when computing the raw periodogram from the
FFT.
If we all agree on this modification, I'll take care of updating the docs.
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------