I will surely let you know shortly
Date: Mon, 26 Nov 2018 18:06:06 -0500 (EST)
From: Allin Cottrell <cottrell(a)wfu.edu>
To: r.lucchetti(a)univpm.it, Gretl list <gretl-users(a)lists.wfu.edu>
Subject: Re: [Gretl-users] Saved results from dpanel
Content-Type: text/plain; charset=US-ASCII; format=flowed
On Mon, 26 Nov 2018, Riccardo (Jack) Lucchetti wrote:
On Sat, 24 Nov 2018, Laura Magazzini wrote:
> I am running a system GMM estimator for dynamic panel data models.
> I need to perform some computations after the second step estimation than
> involve the matrix of instruments, the matrix of regressors (both
> differenced and level), and the weighting matrix used in computation of the
> system GMM (obtained from first step estimates).
> Is it possible to recover these information after the dpanel command?
In normal circumstances, the info you need is not useful to the user and I'd
avoid storing it into the $model bundle because typically these are very
On the other hand, it would be very time consuming for the user who needs
those matrices to reconstruct them in hansl, so Laura's request is perfectly
legitimate IMO. So, I'm attaching a patch which introduces an option to the
dpanel command named --keep-extra. After applying the patch, if you run the
dpanel command with the --keep-extra option, you get two new elements in the
$model bundle, named "Z" (the instrument matrix, transposed) and "A"
I haven't pushed this to git yet because I this this is a rather sensitive
change and I'd like Allin to approve it (especially because there's a fair
chance I've f****d up memory allocation, as I regularly do when I write C
The patch looks good to me, and I've now committed the change.
Perhaps Laura could tell us if the new "A" and "Z" matrices in the
$model bundle -- after estimation with "dpanel" and the --keep-extra
option -- do the job for her.
(But note that this update is not yet in the gretl snapshots, only
the git source code. Snapshots should follow tomorrow.)
[Geek note on memory management: the new code sticks the extra
matrices onto the model using gretl_model_set_matrix_as_data().
The first thing we need to know is: does passing a matrix via this
function amount to "donating" the matrix to the model, or will it
take a copy of the matrix passed? The fact that the matrix parameter
to the function in question is _not_ marked as "const" suggests
strongly that it's case of donation, and that's correct. Next
question: would it be OK to donate the source matrix? In this case
the answer is No, since both matrices are members of a "matrix
block" and so do not have independently allocated memory. Therefore
we must copy the relevant matrices before passing them. And that's
exactly what Jack's code does, so it's perfectly correct!]