On Tue, 16 Apr 2013, Beek Pang wrote:
I am usingĀ gretl and, recently, a number of issues came up
when I was preparing a cross-sectional dataset for analysis.
Specifically:
(1) Within gretl, is it possible to change the ordering of
variables, and keep i.e. save this changed ordering? E.g. is
it possible, in a dataset with 10 variables, to assign the
variable which currently has the ID no. 7 another ID, e.g.
the ID no. 2?
In the GUI program, you can select a series in the main
window, right-click and select "Edit attributes" (or just
press "e"). In the dialog box that appears there's a control
for changing the ID number of the series; this will change
its position in the ordering. Alternatively you can use the
"store" command to save the dataset with a different ordering
of the variables, then re-open the data. The order in which
series are given to "store" is respected in the data save.
(2) Within gretl, suppose a dataset contains observation
labels e.g. company names. Is it possible to remove all
observation labels from the dataset so that there are none?
In the GUI: /Data/Observation markers and select "Remove the
markers". Via CLI: "markers --delete". Also see the --omit-obs
option to the "store" command.
(3) Finally, I would like to standardize the regressors (not
the dependent variable) in my dataset, such that each
regressor has mean 0 and standard deviation of 1. Is there a
"summary way" to do this e.g. by declaring the dataset to be
a matrix, then operating on this matrix using some matrix
operators?
Using a list and a loop is probably the easiest way. (In the
example below ENROLL is taken to be the dependent variable.)
<hansl>
open data4-10
list L = dataset - ENROLL
print L --byobs
loop foreach i L
$i = ($i - mean($i))/sd($i)
endloop
print L --byobs
</hansl>
But doing the transformation using a matrix is also possible
<hansl>
open data4-10
list L = dataset - ENROLL
matrix X = {L}
X = (X .- meanc(X)) ./ sdc(X)
loop foreach i L
$i = X[,i]
endloop
print L --byobs
</hansl>
Allin Cottrell