removing nan and inf from a matrix
by Logan Kelly

Hello,
I need to take the log difference of a matrix, i.e. log(M[2 rows(M):,]/M[1:rows(M)-1,]). Unfortunately, M has elements equal to zero. I need to replace the nan's and inf's with 0's. This almost works
M = isnan(M) ? 0 : M
but does not remove inf's. Any sugestions?
7 years, 8 months

Computing an index for unique combinations of discrete variables
by Giuseppe Vittucci

Hi,
I have firm level data and two categorical variables (region and
sector).
I need to define another variable which is an index identifying the
unique combinations region-sector each firm belongs to, so I can use it
in computing cluster-robust s.e.
One way to do this is to use the command "values" for region and sector
and then use a nested loop, but this seems quite time-consuming...
Is there a simpler way in gretl to do it?
BTW, it could be useful to allow one to use the option "cluster" also
with the FE estimator.
Since the robust s.e. used in FE is the Arellano estimator and this is a
s.e. clusterized over cross-sectional units and thus it can be
considered a specification of the cluster-robust estimator, it seems
quite natural to allow one to identify clusters different from the
units.
Something like:
panel y 0 x --robust=cvar
or
panel y 0 x --cluster=cvar
where the default behavior
panel y 0 x --robust
is to clusterize over cross-sectional units.
Bye
Giuseppe
9 years, 9 months

Re: [Gretl-users] problems replicating Johansen et al (2000)
by Artur T.

Just as an information for those who are interested in it:
I ran the same model in JMulti (2 breaks and allowing for breaks in
levels and trend jointly) and do obtain exactly the same results as
before using gretl. So I guess the script does its job correctly.
Artur
Am 28.11.2013 12:03, schrieb Artur T.:
> Hi all,
>
> I am trying to replicate the example in Johansen et al. (2000) paper
> "Cointegration analysis in the presence of structural breaks in the
> deterministic trend" (Econometrics Journal)
>
> I attached a zip-file with the data and a hansl-script:
>
> The issue is with the rank-test (table 8 in the paper), actually with
> the trace test statistics (I know that the p-values have to be
> calculated separately e.g. by using Jack's script
> "http://web.uvic.ca/~dgiles/blog/sb.inp").
> I do not obtain the same results as in the paper, so I am wondering
> whether it is due to the setup of the break dummies or a software issue.
> Maybe somebody here in the has already dealt with this model in more
> detail and could give me a hint what's wrong here. The model I want to
> apply is called H_l with 2 breaks (3 regimes) as in the paper.
>
> Best,
> Artur
>
10 years, 3 months

quantiles
by Annaert Jan

I have a question regarding the way Gretl computes quantiles. There is probably a small typo in the reference guide. It says that the p-th quantile q of series y with n observations is computed as
q=y[k] +(n·p-k)(y[k+1] -y[k])
where k is the integer part of n·p. Probably this should read "where k is the integer part of (n+1)·p".
Running the following script
clear
matrix x=seq(1,4)'
matrix p={0.25, 0.5, 0.75}
q=quantile(x,p)
print q
Returns
q (3 x 1)
1.25
2.5
3.75
Jan Annaert
10 years, 3 months

y axis inversion
by Dmitri Skripkin

Hello everyone!
Is is possible to inverse y axis to obtain mirror series?
I know that it is possible by reconfiguring gnuplot but i want to make some
analysis on mirrored series.
Thank you!
93
10 years, 3 months

VECM: stability analysis
by Artur T.

Hi all,
I' am working on some cointegration analysis, and would like to run some
stability analysis for VECM models.
In the past I've done some of this stuff using JMulti or CATS (RATS), but I
am wondering whether somebody here in the list has already programmed up
some stuff like for instance the recursive eigenvalues test proposed by
Hansen and Johansen (1999) for gretl.
Alternatively, maybe somebody has a MATLAB or GAUSS code for running
similar tests. Then it shouldn't be big problem to adapt a gretl version of
it for me. Unfortunately, I always found JMulti's GAUSS code a bit messy to
translate it in appropriate time.
I already found some gretl code written by Jack for computing Johansen et
al. (2000) modified Trace tests for cointegration in the presence of
structural breaks, which is a nice thing. But as I don't know the break
point ex ante, a test for an unknown break point is more helpful in my case.
May be somebody of you has some first code or other suggestions.
Thanks in advance.
Artur
10 years, 3 months

question: how to replicate MLE --hessian flag standard errors
by Pindar

Hi,
for the standard Poisson model I'd like to explore different methods of
covariance estimation.
Could you please tell me how to replicate the --hessian flag with the
'Hess' function?
(it's not included in MLE-advanced.inp, I read in the manuel 'negative
inverse of the hessian', but I make something wrong since invpd(h) does
not do the job).
Have a nice weekend
Leon
<hansl>
open poisson.gdt
poisson y 0 x1 x2
series fake_y = ln(y+1)
ols fake_y 0 x1 x2 --quiet
list xList = $xlist
matrix b = $coeff
matrix mX = {xList}'
function matrix score(matrix b, series y, matrix mX)
series e = y - exp(mX'b)
return {e} .* mX'
end function
function void Hess(matrix *H, matrix b, series y, matrix mX)
#computes the negative Hessian for Poisson model,
H = -(qform(mX, (mX'b)*(mX'b)'))
end function
matrix H = {}
mle loglik = y*Xb - exp(Xb)
series Xb = mX'b
deriv b = score(b, y, mX)
hessian Hess(&H, b, y, mX)
end mle
# How to replicate --hessian with the 'Hess' function ?
mle loglik = y*Xb - exp(Xb)
series Xb = mX'b
deriv b = score(b, y, mX)
end mle --hessian
<hansl>
10 years, 3 months

Poisson command w/o constant
by Pindar

Hi,
when checking whether the coefficients of Poisson FE correspond to those
of the Poisson model with unitdummies I noticed that when using the
poisson command without constant only the beta_hat of regressors
starting from x2 on were identical. When using global constant all
estimated coefficients were identical.
This script demonstrates the phenomenon of different coefficient
estimates in a poisson model w/o constant for identical regressors:
<hansl>
open "rac3d.gdt" -q
smpl 4800 --random
# construction of panel
matrix mTime = seq(2001,2004)'
series time = ones(1200,1)**mTime
matrix units = seq(1,1200)'
series pid = units**ones(rows(uniq(time)),1)
delete SEX AGE AGESQ LEVYPLUS FREEPOOR FREEREPA
store "rac3d_Panel.gdt"
open "rac3d_Panel.gdt" -q
setobs pid time --panel-vars
DVISITS += randgen(P,2)
# Poisson w constant
list X = HSCORE HOSPADMI
poisson DVISITS const X -q
eval $coeff[2]~$coeff[3]
list X = HOSPADMI HSCORE
poisson DVISITS const X -q
eval $coeff[3]~$coeff[2]
# Poisson w/o constant
list X = HSCORE HOSPADMI
poisson DVISITS X -q
eval $coeff[1]~$coeff[2]
list X = HOSPADMI HSCORE
poisson DVISITS X -q
eval $coeff[2]~$coeff[1]
<hansl>
10 years, 3 months

Two minor issues
by Giuseppe Vittucci

Hi,
there are two behaviors of gretl I am not particularly comfort with.
1) When an open dataset is "Saved as..." with a different name
(sometimes subsampled), gretl does not change anymore to the new file,
but keeps on working on the old file.
Example:
I open dI.gdt. If I make some changes to this dataset and save it as a
new file with the name dII.gdt, gretl does not automatically move to
dII.gdt but it keeps on working on dI.gdt.
Is this an intended behavior or a bug?
I find it quite annoying as most of the time when I save the dataset in
a new file I want that gretl switches automatically to it.
2) I found the possibility to automatically create interaction variables
with the command "^" very useful.
There is nonetheless one effect of the command that is annoying: when
you use (dummy) variables in the command that are grouped together, some
of the new interactions variables are placed in the same group.
Here is an example:
I have a panel of firms in different regions.
I want to create region-time dummies.
genr timedum
creates the time dummies and group them together in the list of
variables, and that's fine
I have a categorical variable called "reg".
The following commands work as expected and create the region-time
dummies I need:
list dt = dt_*
list H = reg ^ dt
i.e. dt_1_reg_1,...,dt_1_reg_20,dt_2_reg_1,...
The only problem with the result is that gretl puts all the variables
dt_#_reg_#, EXCEPT dt_1_reg_#, in the same group of dt_#
What I would expect is that:
- all the new variables are grouped together in a new group, or
- all the new variables are placed in the time-dummies group, or
- the new variables are not placed in any group...
I know these are only minor issues, but since the new release is coming
I thought this is the right moment to "ask" ;-)
Bye
Giuseppe
10 years, 3 months

Poisson Fixed Effects
by Pindar

Hi there,
am I right that an implementation of a Poisson Fixed Effects model needs
some coding effort (and experience with MLE) ?
In Greene Chapter 21 (21.9.5 Poisson models for Panel Data) the steps
are documented.
It should be "like a Fixed Effect Probit model (21.5.1.b) with minor
modifications."
I found Jack's felogit.gfn on the server. I guess there is no feprobit
because of the incidental parameters problem, or?
Best
Leon
10 years, 3 months