issue with isnan()
by Artur T.
Dear all,
this small gretl code defintely used to work in the past. However, it
produces an error with todays current git version on Ubuntu:
"isnan: argument should be scalar, is matrix
Data types not conformable for operation"
The manual states that the argument can be either scalar or matrix
<hansl>
matrix A = {0,1}
A = isnan(A) ? 0 : A
A
</hansl>
Best,
Artur
7 years, 11 months
Re: [Gretl-users] Unit roots and structural breaks
by George Matysiak
No problem Allin. I should have more carefully formulated my question as
testing for unit roots plus structural break(s) routines, such as Zivot &
Andrews etc.
George
*Contact number +48 781 415 432**"In God we trust, all others bring data."*
7 years, 11 months
Re: [Gretl-users] Unit roots and structural breaks
by George Matysiak
Sven,
That's precisely what I was looking for, *the combination*. I'm fully aware
of the the ADF/KPSS tests etc and the structural break package, so not that
helpless. The perron97.inp script would be a good starting point. Thanks.
George
*"In God we trust, all others bring data."*
7 years, 11 months
Re: [Gretl-users] Correlation heatplot
by cociuba mihai
The correlation plot is a great addition to Gretl!
When using the corrplot package in R a very nice feature is the possibility
to show the correlation values on the corrplot.
I've attached an image made with the corrplot package as an example.[image:
Inline image 1]
Another feature of the corrplot package is the possibility to print the
significance test results directly in the correlation plot.
Also the possibility to control the name of series, font size and
orientation could solve any problems arising from large datasets.
Regarding the problem of black and white the example from
https://cran.r-project.org/web/packages/corrplot/vignettes/corrplot-intro...
shows that using circles (or squares with values) would generate a nice
ready to publish image.
Mihai
On Sat, Jan 7, 2017 at 7:00 PM, <gretl-users-request(a)lists.wfu.edu> wrote:
> Send Gretl-users mailing list submissions to
> gretl-users(a)lists.wfu.edu
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.wfu.edu/mailman/listinfo/gretl-users
> or, via email, send a message with subject or body 'help' to
> gretl-users-request(a)lists.wfu.edu
>
> You can reach the person managing the list at
> gretl-users-owner(a)lists.wfu.edu
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Gretl-users digest..."
>
>
> Today's Topics:
>
> 1. Re: Correlation heatplot (Allin Cottrell)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 6 Jan 2017 12:07:37 -0500 (EST)
> From: Allin Cottrell <cottrell(a)wfu.edu>
> To: Gretl list <gretl-users(a)lists.wfu.edu>
> Subject: Re: [Gretl-users] Correlation heatplot
> Message-ID:
> <alpine.LNX.2.20.16.1701061147330.11151(a)localhost.localdomain>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
>
> On Thu, 5 Jan 2017, Allin Cottrell wrote:
>
> > On Wed, 4 Jan 2017, Artur Tarassow wrote:
> >
> >> Btw, do you think this could become a public package similar to the (of
> >> course) much more sophisticated R-package corrplot (URL:
> >> https://cran.r-project.org/web/packages/corrplot/
> vignettes/corrplot-intro.html)?
> >
> > I agree this is a nice thing to have, and in fact I'm considering adding
> it
> > as built-in functionality.
>
> I've made a first stab at this (in git and snapshots). I'll briefly
> describe what's there, and pose a few questions for consideration.
>
> Command line: the "corr" command now has a --plot=whatever option
> (along the same lines as the "freq" command). You can use --plot=none
> to suppress a heatmap plot in interactive mode, --plot=display to
> show it on-screen, or --plot=somename.pdf, and so on.
>
> GUI: when you call for a correlation matrix (for more than 2 series)
> in the GUI, the correlation window toolbar now has a heatmap icon that
> calls up a plot.
>
> For now I'm showing positive correlations in red, of varying
> intensity, and negative correlations in blue, with white in the middle
> (around zero). To cut down on visual clutter I've extended the white
> range to cover correlations that are not significantly different from
> zero at the 20% significance level.
>
> When the heatmap is shown in the GUI, moving the mouse over the matrix
> displays the correlation coefficients in the status bar.
>
> By default, the whole matrix is shown but there's a --triangle option
> to show just the lower triangle.
>
> Some questions:
>
> * Full matrix vs triangle: which should be the default? Is the choice
> worth having or should we just fix on one or the other?
>
> * Right now there's a minimum dimension of 3 for doing the heatmap:
> should the minimum be bigger than that? (3 x 3 looks kinda silly, but
> maybe it should be available anyway?)
>
> * The plot works reasonably well for up to about 30 series, but is
> going to get quite messy for more than that. Should we set a max?
> And/or, should we make a special effort to get the plot working
> acceptably for bigger dimensions? (Smaller font, not sure what else
> could be done.)
>
> Allin
>
>
> ------------------------------
>
> _______________________________________________
> Gretl-users mailing list
> Gretl-users(a)lists.wfu.edu
> http://lists.wfu.edu/mailman/listinfo/gretl-users
>
> End of Gretl-users Digest, Vol 120, Issue 12
> ********************************************
>
7 years, 11 months
Correlation heatplot
by Artur Tarassow
Dear all,
I programmed a function which plots a nice correlation heatmap between
various variables. However, I would like to neglect "nan" in the matrix.
I sent gnuplot the command "printf "set datafile missing 'nan'\n" but it
doesn't work, and I still obtain the error: "warning: matrix contains
missing or undefined values. Btw, the plot is compiled nicely but I
can't get rid of this error message.
I am using gnuplot 5.0 patchlevel 4, but I remember that this issue
already occurred in previous version. Has anyone a clue?
Artur
<hansl>
clear
set echo off
set messages off
function void corrheat (matrix M, strings name,
string fname "Path and name of the figure",
int fontsize "Set font size in pt",
int color[0:5:4] "Select color")
set warnings off
string path = "heatmap.gp"
if $windows
sprintf tmpfile "@dotdir\@path"
else
sprintf tmpfile "@dotdir/@path"
endif
outfile @tmpfile --write
printf "set encoding utf8 \n"
printf "set nokey \n"
printf "set term pdfcairo font 'Helvetica,%d'\n", fontsize
# Put the border more to the background by applying it
# only on the left and bottom part and put it and the tics in gray
printf "set style line 11 lc rgb \"#808080\" lt 1 \n"
printf "set border 3 back ls 11\n" # get rid of upper + left border
printf "set tics nomirror \n"
if color==1
printf "set palette defined ( 0 '#000fff', 1 '#90ff70', 2
'#ee0000') \n"
elif color==2
# MATLAB COLORS:
printf "set palette defined (0 0 0 0.5, 1 0 0 1, 2 0 0.5 1, 3 0
1 1, 4 0.5 1 0.5, 5 1 1 0, 6 1 0.5 0, 7 1 0 0, 8 0.5 0 0)\n"
elif color==3
printf "set palette maxcolors 10 \n"
elif color==4
printf "set palette rgbformulae 22,13,10 \n"
elif color==5
printf "set palette grey\n"
endif
#printf "set palette negative \n" # reverse colorbar
# Reverse row and columns values
M = mreverse(M) #reverse rows
M = mreverse(M')'#reverse cols
scalar count = nelem(name)-1
printf "set ytics ("
loop i=1..nelem(name) -q
if i<nelem(name)
printf "\"%s\" %d, ", name[i], count
else
printf "\"%s\" %d", name[i], count
endif
count--
endloop
printf " ) font 'Helvetica,%d' out \n", fontsize #rotate by 45
scalar count = nelem(name)-1
printf "set xtics ("
loop i=1..nelem(name) -q
if i<nelem(name)
printf "\"%s\" %d, ", name[i], count
else
printf "\"%s\" %d", name[i], count
endif
count--
endloop
printf " ) font 'Helvetica,%d' out \n", fontsize #rotate by 45
printf "set xtics rotate by 45 right\n"
printf "set datafile missing 'nan'\n"
#printf "set datafile missing '0'\n"
printf "set datafile separator ' ' \n" # Discard empty entries
#add a slight grid to make it easier to follow the exact position
of the curves
printf "set style line 12 lc rgb \"#808080\" lt 0 lw 1 \n" # light
grey color
#printf "set grid back ls 12\n"
printf "set style fill transparent solid 0.8 noborder \n" # set
lighter shaded area
# HEATMAP
printf "plot \\\n"
printf "'-' using 1:2:3 matrix with image\n"
loop i=1..rows(M) -q
loop j=1..cols(M) -q
if M[i,j]<0 || M[i,j]>0
printf "%.6f", M[i,j]
else
printf "nan"
endif
if j<cols(M)
printf ", "
endif
endloop
printf "\n"
endloop
printf "e \n"
outfile --close
gnuplot --input="@tmpfile" --output="@fname"
end function
#---------
# Example
#---------
open denmark.gdt -q
list y = LRM LRY IBO IDE
list y = y diff(y)
corr y
M = lower( mcorr({y}) )
M = (M ? M : NA)
matrix Obs = seq(1,rows(M))
string xlab = ""
string ylab = ""
strings names = varnames(y)
string fname = "@workdir/corrcheck.pdf"
scalar fs = 13
scalar color = 4
corrheat (M, names, fname, fs, color)
</hansl>
7 years, 11 months
type of variable
by Pedro Bação
Hello,
Is there a Gretl function will that tell us what is the type of the
variable given as argument? If not, is there a way of getting that sort of
information in Gretl?
Thanks,
Pedro
7 years, 11 months
GMM PANEL DATA
by Nik Pouranis
Hello
I would like to ask you how i can run GMM for panel data, what i should imput as instruments variables?
Thank you
7 years, 11 months
Problems when trying to interac with R
by Jan Tille
Dear Gretl users,
wishing you all a Happy New Year 2017.
Unfortunately I am encountering a problem when trying to interact with R, i.e. passing data back and forth.
I am using a tiny test script to make myself familiar with the interaction. This is more or less a copy-past version of the user manual's example (36.1)
mwrite(funds,"funds.mat",1)
foreign language=R --send-data --quiet
funds1<-gretl.loadmat("funds.mat")
gretl.export(funds1,"funds12")
end foreign
matrix funds1={}
funds1 = mread("funds12.mat",1)
Gretl writes the matrix properly into the dotdir and passes it to R. The matrix, which is unaltered is saved in my dotdir as well, though somewhat larger (3.9 MB vs. 2.2 MB).
However, when I try to import that matrix from the dotdir I always get an error message.
I have no clue why this happens, because I just rename an existing matrix.
My current Gretl version is 2016b (April 2016) - running it on windows 31bit
R is 3.1.2 from 2014, which is used automatically by gretl. I do have a newer version (3.2.4) but it is installed in my users folder. I do not have admin rights to install a newer version in the "program" folder.
Thanks in advance and all the best,
Jan
7 years, 11 months
problem with tsls in Monte Carlo simulation
by juergen.malitte@t-online.de
First of all I wish a happy new year 2017.
My problem is the following:
Given the simultaneous system of equations withe the endegenous variables
p and e, the exegenous variable A and the error terms u and v.
* p = 1.5 + 0.5e + u
* e = 2.5 + 0.5p -0.4A + v
Say that we have β1 = 1.5, β2= 0.5 in (1) and α1 = 2.5, α2 = 0.5, α3 =
-0.4
I want to estimate the parameter of e in the first equation p = 1.5 +
0.5e + u performing a Monte Carlo simulation.
First I want to show that the OLS-estimation produces a bias in the
estimation of e (see the script below).
For u,v and A I create the following variables:
series u = normal(0,1)
series v = normal(0,1)
series A = normal(0,1)
Then I take the reduced form equations from the structurel form (1)/(2)
to produce the endegenous variables p and e:
series p = (2.75 - 0.2*A + 0.5*v + u)/0.75
series e = (3.25 - 0.4*A + 0.5*u + v)/0.75
The formulas are the result oft he following general (reduced) formulas:
p = (β1 + α1* β2 + α3* β2*A + u + β2*v) / (1 – α2* β2)
e = (α1 + α2* β1 + α3*A + v + α2*u) / (1 – α2* β2)
Taking 500 times a sample of size N=50 and executing the OLS-regression
p against e in (1) I collect the 500 estimated parameters in the variables
koeff_beta1 and koeff_beta2. The frequency distribution for the
coefficients of variable "e" looks very good! The mean value is „0.76283“
and „0.26283“ is nearly the expected bias of β2= 0.5 ( with an
appropriate mathematical formula I calculated the bias and he gives me the
value of 0.266 !!!). So all seems good.
But when I perform an TSLS or IV-estimation (see below) of (1), using the
external variable A as an instrument for e (what is allowed), I get for
the estimated α2 the mean value „0.16681“ (instead of expected roughly
0.5). The test-statistic of chi-quadrat is 92024.584, that means no
normality in the frequency distribution of α2 !!!! I got this (bad)
result, when I changed the command
„ols p const e“ to
„tsls p const e ; const A“
or alternatively:
ols e const A
series e_dach = $yhat
ols p const e_dach
scalar koeff_beta2[t] = $coeff(e_dach) -------------------
gives the same result
Is something wrong with the tsls – command or am I wrong using A as an
instrument for e ?
Here is my script:
nulldata 500
series koeff_beta1 = 0
series koeff_beta2 = 0
set seed 16577899
smpl 1 50
#series A = 2
loop for (t=1; t<=500; t++) --quiet
series u = normal(0,1)
series v = normal(0,1)
series A = normal(0,1)
series p = (2.75 - 0.2*A + 0.5*v + u)/0.75
series e = (3.25 - 0.4*A + 0.5*u + v)/0.75
#tsls p const e ; const A alternative tsls
!!!!!!!!! goes wrong
ols p const e
koeff_beta1[t] = $coeff(const)
koeff_beta2[t] = $coeff(e)
endloop
smpl full
Greetings
Jürgen Malitte
7 years, 11 months