## Complex matrix to real matrix

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.

### Complex matrix to real matrix

Dear Tom,

I am seeking the most convenient way to transform a complex matrix into a real matrix in a formula (frml)?
Can I use something like ewise instruction?

Best regards.
g_defi

Posts: 13
Joined: Fri Nov 19, 2010 9:42 am

### Re: Complex matrix to real matrix

I'm not sure what you mean by "in a FRML". If you mean with something like an EWISE, yes:

dec rect r(n,n)
ewise r(i,j)=%real(c(i,j))
TomDoan

Posts: 2761
Joined: Wed Nov 01, 2006 5:36 pm

### Re: Complex matrix to real matrix

Apologize if I was not clear.
I call the %logdensitycv function in a multivariate case. Since my estimator operates in frequency domain, I try to transform my transfer function (that is a complex matrix) into a real matrix:

Code: Select all
`frml logl = %logdensitycv(transfer,periodogram,(float(n)/m))`

where "transfer" and "periodogram" are symmetric complex matrix that I want to turn into real matrix.
g_defi

Posts: 13
Joined: Fri Nov 19, 2010 9:42 am

### Re: Complex matrix to real matrix

The complex matrix equivalent of %LOGDENSITYCV would require arguments which are the spectral density implied by the model, the periodogram and the number of observations. The transfer function in this case would be a SERIES[CVECTOR] instead, and you would use that combined with the model spectral density in a complex equivalent of %LOGDENSITY. Which of the two do you have?
TomDoan

Posts: 2761
Joined: Wed Nov 01, 2006 5:36 pm

### Re: Complex matrix to real matrix

The attached function computes the log density of a complex Normal.
Attachments
cxlogdensity.src
Procedure/function file
TomDoan

Posts: 2761
Joined: Wed Nov 01, 2006 5:36 pm

### Re: Complex matrix to real matrix

Unfortunately I think I cannot use the complex log density of Normal because I perform a Whittle approximation of the Maximum Likelihood.
My problem is like trying to modify the FRACTINT.RPF file in order to estimate a bivariate VARFIMA(1,d,0).
g_defi

Posts: 13
Joined: Fri Nov 19, 2010 9:42 am

### Re: Complex matrix to real matrix

This extends %LOGDENSITYCV to complex matrices. That looks like what you want.

cxlogdensitycv.src
Procedure file
TomDoan

Posts: 2761
Joined: Wed Nov 01, 2006 5:36 pm

### Re: Complex matrix to real matrix

Yes it is. Thank you very much for your help!

Best regards.
g_defi

Posts: 13
Joined: Fri Nov 19, 2010 9:42 am