On Thu, 25 Feb 2010, Sven Schreiber wrote:
Allin Cottrell schrieb:
> On Wed, 24 Feb 2010, Sven Schreiber wrote:
>
>> Allin Cottrell schrieb:
>>>
>>> Now we need a nice example of the use of Octave to illustrate the
>>> yet-to-be-written entry for the User's Guide. Any suggestions?
>> Well as Jack mentioned, maybe (cross-) spectral stuff would be a good
>> area because of complex numbers. For example the "cohesion" measure
by
>> Croux/Forni/Reichlin?
>
> Thanks for the suggestion. I was kinda hoping that somebody who
> knows Octave better than I might actually contribute an example
> for the manual. The only things that I know how to do in Octave
> are boring stuff that you could do just as well in gretl.
The Matlab code is on
www.economia.unimore.it/forni_mario/matlab.htm --
I could take a look next week whether that also works on octave and make
a "foreign" example. Actually to have the standard coherence available
in gretl via this wrapper would be nice. (cohesion would be nice, too,
of course, but coherence is standard spectral stuff.)
Thanks, that was enought of a hint to get me started. Could anyone
check that the following is correct?
1) In Octave, ensure that the "specfun" and "signal" packages are
installed. I did:
pkg install specfun-1.0.8.tar.gz
pkg install signal-1.0.10.tar.gz
(after downloading these packages from octave-forge).
2) Get Mario Forni's code. Here's a shell script that downloads
the required files and strips the trailing Ctrl-Z's that prevent
them from working on Linux:
<bash>
SITE=http://www.economia.unimore.it/forni_mario/MYPROG
for f in \
coheren2.m \
coheren.m \
coher.m \
cospec.m \
crosscov.m \
crosspec.m \
crosspe.m \
spec.m ; do
wget $SITE/$f && \
cat $f | tr -d \\032 > tmp.m && mv tmp.m $f
done
</bash>
3) Sample gretl script:
<script>
open data9-7
matrix xy = { PRIME, UNEMP }
mwrite(xy, "(a)dotdir/xy.mat")
foreign language=octave
xy = gretl_loadmat("xy.mat");
x = xy(:,1);
y = xy(:,2);
# the last param is the Bartlett window size
h = coher(x, y, 8);
gretl_export(h, "h.mat");
end foreign
h = mread("(a)dotdir/h.mat")
colnames(h, "coherence")
gnuplot 1 --time --with-lines --matrix=h --output=display
</script>
Allin