Running 'Allison's alternative Hausman test' after GLS-RE model
by Clive Nicholas

Hello all!
I've just joined the list and I'm a brand new user of -gretl-. I've only
been using it for three days and I must praise the team for delivering a
highly usable, flexible and interactive package that runs pretty much all
of the econometric models that I want to fit (and a big, fat users' guide,
too!) - and for free. Can't say fairer than that.
I do have one query, however. Following Allison (2009), I'm seeking to
implement his alternative to the Hausman test after fitting a random
effects panel model, which he argues has "probably better statistical
properties" than Hausman. On pp. 23-27, he lays out the following steps:
(a) leave Y untransformed;
(b) calculate and include the unit-specific means (M) for each time-varying
X variable (which I did quite easily by adding variables and using the
-pmean()- command);
(c) calculate and include the mean deviations (D) from the same X
variables' unit-specific means (dvar=var-mvar));
(d) include all relevant time-invariant Z variables;
(e) run the random effects GLS panel model: Y = DX1 + MX1 + DX2 + MX2 + DXk
+ MXk + Z1 + Z2 + Zk + e)
(f) in place of the Hausman test of fixed vs. random, run the Wald test for
the equality of all pairs of X coefficients, with the null representing
equality.
I decided to test this out on the -abdata- dataset, regressing w on the
transformed pairs of the variable set {n,k,ys} and the T-1 time dummies:
Model 2: Random-effects (GLS), using 1031 observations
Included 140 cross-sectional units
Time-series length: minimum 7, maximum 9
Dependent variable: w
coefficient std. error t-ratio p-value
--------------------------------------------------------
const -2.58543 2.27350 -1.137 0.2557
m_n -0.0900681 0.0361907 -2.489 0.0130 **
d_n -0.107425 0.0200510 -5.358 1.04e-07 ***
m_k 0.0852161 0.0320885 2.656 0.0080 ***
d_k 0.0572876 0.0171438 3.342 0.0009 ***
m_ys 1.27558 0.490848 2.599 0.0095 ***
d_ys 0.214818 0.0492901 4.358 1.44e-05 ***
dt_2 -0.0745933 0.0110719 -6.737 2.70e-11 ***
[...]
dt_9 0.0319181 0.0176179 1.812 0.0703 *
Mean dependent var 3.142988 S.D. dependent var 0.263008
Sum squared resid 65.49712 S.E. of regression 0.253776
Log-likelihood -42.06415 Akaike criterion 114.1283
Schwarz criterion 188.2026 Hannan-Quinn 142.2399
'Within' variance = 0.0058566
'Between' variance = 0.0506465
Wald test for joint significance of time dummies
Asymptotic test statistic: Chi-square(8) = 224.855
with p-value = 3.62557e-44
Breusch-Pagan test -
Null hypothesis: Variance of the unit-specific error = 0
Asymptotic test statistic: Chi-square(1) = 2994.67
with p-value = 0
Hausman test -
Null hypothesis: GLS estimates are consistent
Asymptotic test statistic: Chi-square(11) = 21.8284
with p-value = 0.0257372
Everything goes to plan until I try to implement step (f). Clicking on the
Tests tab and then selecting Lingg ear Restrictions, I typed:
b[m_n] = b[d_n]
but I receive a "parse error in 'b[m_n] = b[d_n]'" error message. Deleting
the spaces either side of the = made no difference. I only got results by
running:
Restriction set
1: b[m_n] - b[d_n] = 0
2: b[m_k] - b[d_k] = 0
3: b[m_ys] - b[d_ys] = 0
Test statistic: F(3, 1016) = 3.27298, with p-value = 0.0205637
This test would appear to comprehensively reject the RE model in favour of
retaining the FE model. Or does it? Is this an acceptable test in place of
the Wald test for jointly equal parameters that I can't run in -gretl-?
Since the shape of the F and chi-square distributions are virtually
identical and we have the obvious mathematical statement that (var1 = var2)
= (var1 - var2 = 0), is it not acceptable to use the results of this test
instead to come to the same conclusion? If not, how can I implement the
Wald test in -gretl-? It must be possible!
Thanks once again.
--
Clive Nicholas (clivenicholas.posterous.com)
[Please DO NOT mail me personally here, but at <clivenicholas(a)hotmail.com>.
Please respond to contributions I make in a list thread here. Thanks!]
Allison PD (2009) Fixed Effects Regression Models, QASS Series Paper
07-160, Thousand Oaks, CA: Sage
10 years, 11 months

Fisher's Exact Test in gretl
by yinung＠Gmail

Dear all,
I notice that "xtab" command can do Fisher's exact test. I found that
fisher.test(.) in R (requires vcd package) also produces Fisher's exact
test results. Does anyone know the differences between gretl's and R's
Fisher's exact test?
I test the following data (which can be downloaded from
http://ibeif.files.wordpress.com/2012/12/fishertea.xls
obs real guess
1 1 1
2 1 1
3 1 1
4 1 2
5 2 2
6 2 2
7 2 1
8 2 2
In gretl, the following script
<hansl>
open http://ibeif.files.wordpress.com/2012/12/fishertea.xls
xtab real guess
</hansl>
produces the results:
Cross-tabulation of real (rows) against guess (columns)
[ 1][ 2] TOT.
[ 1] 3 1 4
[ 2] 1 3 4
TOTAL 4 4 8
Pearson chi-square test = 2 (1 df, p-value = 0.157299)
Warning: Less than of 80% of cells had expected values of 5 or greater.
Fisher's Exact Test:
Left: P-value = 0.985714
Right: P-value = 0.242857
2-Tail: P-value = 0.257143
However, in gretl with the following R script
fisher.test(table(real,guess))
produces the different results:
Fisher's Exact Test for Count Data
data: table(real, guess)
p-value = 0.4857
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.2117329 621.9337505
sample estimates:
odds ratio
6.408309
Thanks
Yi-Nung Yang
10 years, 11 months

gretl API
by jean.p＠hushmail.com

hi,
just a couple of quick questions regarding the gretl API: *trying to
use the kalman_smooth function in c++ code, I realized that this
function is not declared in the header file. Is it declared somewhere
else? *in order to ensure smooth (no pun intended) compilation /
linkage, is this function part of the library /usr/lib/libgretl-1.0.so
? many thanks for your help!
jean
10 years, 11 months

loops in hansl
by Stefano Fachin

just thinking: it would be nice to have a "goto" control inside loops. In Monte Carlo sometimes there is the need to discard one of the
replications, jumping to the next.
Merry Xmas and Happy New Year!
Stefano
--
_________________________________________________________________________
Stefano Fachin
Professore Ordinario di Statistica Economica
Dip. di Scienze Statistiche
Università di Roma "La Sapienza"
P.le A. Moro 5 - 00185 Roma - Italia
Tel. +39-06-49910834
fax +39-06-49910072
URL http://w3.uniroma1.it/fachin/
10 years, 11 months

Contributed function packages (gfn files)
by Allin Cottrell

Hello all,
I'm pleased to see that we have a large and expanding number
of contributed packages on the gretl server. Good work, guys!
If you're not a package author the rest of this mail may not
concern you but if you are an author, please read on.
I've been running various checks on the gfn files, (a) to
ensure that changes in gretl CVS haven't broken any of them
and (b) to check that the packages themselves are in working
order. I found a few small bugs in the packages (noted below)
but first let me emphasize a general point: a valid package
MUST contain a self-contained and functional sample script.
This is for the benefit of both the end user and the package
checker (me, at present): I need to be able to extract the
sample script from each package and run it "as is" to check
that the package actually works.
A problem with several packages on the server is that the
sample script is broken in some way. The most common breakage
is that the "open" command is used but no valid datafile name
is provided. The argument to "open" must be either (a) the
name of a file that's included in the gretl distribution or
(b) a valid URL of the form
http://server/path/file
that points to a file of a type that gretl can open. Case (a)
is preferable; case (b) is OK provided that the URL is likely
to remain stable. Also note that in case (a) a full path
should NOT be given (that's specific to your system), just the
plain name of the file, as in
open australia.gdt
Note that if you can't come up with suitable data input for
your sample script in either of the ways just mentioned, it's
OK to use the "nulldata" command and construct artificial
data. In that case you should include a "set seed" line so
that the output is reproducible.
Another problem with some packages is that the command to
"include" the gfn file is broken. This must always just give
the plain package name, as in
include mypackage.gfn
without any path stuff. And the include command should not be
duplicated.
Specifics on the packages:
When I found a trivial problem with a package, I fixed the gfn
file myself and uploaded the fixed version to the server. If
any of the following packages are yours, please sync your own
copy to the version that's on the server.
* clustered_ols.gfn : The function call in the sample script
didn't match the name of the function in the package.
* hetero.gfn : The line "include hetero.gfn" was duplicated.
* HIP.gfn : Wrong command "include ../HIP.gfn".
* SETAR.gfn : The "open" command was invalid (and there was
some unsupported use of @variables as arguments to printf).
For the following gfn files the sample script was invalid and
I wasn't in a position to fix it myself:
BVNormal.gfn
lmTest.gfn
MCO_Ridge.gfn
MVStatistic.gfn
Panelregression.gfn
Ttest.gfn
For the time being I'm moving these files out of the public
area on the server. If you have a package on this list, please
review it and see if you can come up with a working sample
script -- we'd like to get your package back on line!
If you need to grab a copy from the server, see
http://ricardo.ecn.wfu.edu/gretl/cgi-bin/current_fnfiles/invalid/
Allin Cottrell
10 years, 11 months

Principal Components Analysis Misbehavior
by Henrique Andrade

Dear Gretl Team,
I think I found a possible error using the
"pca" command. Please take a look at the
following code:
<hansl>
open australia.gdt
pca PAU PUS E --save-all
# It saves all the components
clear
open australia.gdt
pca PAU PUS E --save[1]
# It saves only the first component
clear
open australia.gdt
pca PAU PUS E --save[2]
# It was supposed to save only the second
# component, but Gretl saves only the first
clear
open australia.gdt
pca PAU PUS E --save[3]
# It was supposed to save only the third
# component, but Gretl saves only the first
<hansl>
According to the Gretl's Help, in respect to
the option "--save[=n]":
"If you provide a value for n with this option
then the most important n components are
saved."
Additionally, inside a BIG loop I am building,
the order of the options "--save[1]" and "--quiet"
is changing the behavior of Gretl.
Using the format "pca ... --save[1] --quiet"
doesn't suppress the printing of the PCA
results. To suppress, I need to use
"pca ... --quiet --save[1]".
Best regards,
Henrique Andrade*
*
10 years, 11 months

kalman filter through the c++ api
by jean.p＠hushmail.com

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
hello,
I am trying to understand how to use Gretl's kalman smoothing
capabilities within c++ code by creating a C++ function which would
take as argument a one-dimensional time series (for instance of
type std::vector<double>) and would return a smoothed series (of
the same type)
a very simple example would be a time series following a random
walk process such as:
X(t) = X(t-1) + w(t), where w(t) follows a Gaussian N(0,0.005)
with the observed process :
Z(t)= X(t) + v(t), with v(t) ~ N(0,1)
looking at the API guide online, it seems I would need to include
<gretl/libgretl.h> as well as <gretl/kalman.h> and then probably
call kalman_new and kalman_smooth but I am not at all sure
I would really appreciate if someone could share some .cpp code
that I could work through and use as a template
many thanks for your help !
jean
-----BEGIN PGP SIGNATURE-----
Charset: UTF8
Version: Hush 3.0
Note: This signature can be verified at https://www.hushtools.com/verify
wsBcBAEBAgAGBQJQzyElAAoJEDq09S2mX5hdo68H/Rlu4PrKDY/jYRWFUvOL5BUwsuLe
gGl2cNhC11fcrAeNKTA39mgKZBFPNRVjxmiEapRlldb0Jghk56u9lk2UNuujyhmbswH8
x8LujXqvzTP3EzYx1W6B/BQx24Zv+gflo/K2u5N2vadbpcLYW18Ol7llDc7zrr/TBjGM
Of59sl1hn3erSDjCWgFVEDtTE8QgyH4VRGFIkCoZbNH+qJ8gozg7mBGnS5EUeIuNRcEc
f0a1P0ykmX6w3C6xLfDusPHfSUgnawxp3llMY6Yaho56sWsh3tX4lU70tAj+vA/2Q9y5
2j/jShEKiYF2dQbqT16beMoxrLt72fsbpujqePxX14c=
=8Sm/
-----END PGP SIGNATURE-----
10 years, 11 months

ordering in the lags() function
by Sven Schreiber

Hi,
when lags() is applied to a list (of series), then the result is grouped
by variables, i.e. lags(2,mylist) gives
x_1 x_2 y_1 y_2
if x and y are the list members.
In the VAR/VECM context we typically have the variables ordered by lags
instead, i.e. we need
x_1 y_1 x_2 y_2.
(For example, implicitly this standard ordering is also used by the nice
accessor $vecGamma which I just recently discovered.)
I wrote a little loop that roughly does what I need by repeatedly taking
lags; it's good enough for me I guess, although names turn out like
x_1_1 instead of x_2, but I can live with that (thanks to the new
extended character limit for names!). But still I was wondering whether
this would be an argument to extend the lags() function to do that more
cleanly, maybe with an optional parameter or something.
thanks,
sven
10 years, 11 months

clear--dataset
by artur tarassow

Hi gret programmers,
using the command "clear --dataset" should only clear the existing dataset,
but actually everything is cleared (matrices, strings). I get this behavior
using gretl (built date 2012-12-01) on Windows.
Best,
Artur
10 years, 11 months