I wrote the following for my class this semester and they seem to work. No doubt they
could be improved...
<hansl>
/*
Functions for centering & standardizing a list of series
*/
function list center(list L)
strings N = varnames(L)
list retlist = null
loop foreach i L --quiet
string name = "c_" ~ N[i]
series @name = L[i] - mean(L[i])
retlist += @name
endloop
return retlist
end function
function list standard(list L)
strings N = varnames(L)
list retlist = null
loop foreach i L --quiet
string name = "s_" ~ N[i]
series @name = (L[i] - mean(L[i]))/sd(L[i])
retlist += @name
endloop
return retlist
end function
</hansl>
Hth,
PS
-----Original Message-----
From: gretl-users-bounces(a)lists.wfu.edu [mailto:gretl-users-
bounces(a)lists.wfu.edu] On Behalf Of Sven Schreiber
Sent: Wednesday, November 16, 2016 9:40 AM
To: gretl-users(a)lists.wfu.edu
Subject: Re: [Gretl-users] centering series and lists
Am 16.11.2016 um 14:26 schrieb Stefano:
> Simple question: unless I missed it, it seems that there is not an
> equivalent of cdemean for series (and hence lists), i.e. a command
> centering on the mean a given series or all the series included in a
> list. In other words, something like diff(list) which computes their
> first differences. Sometimes it could come handy.
> bye, and thanks as usual!
At least for series you can use the auto-conversion of a vector to a series like
this:
series xd = cdemean( {x} )
But for lists it's probably more involved, right.
cheers,
sven
_______________________________________________
Gretl-users mailing list
Gretl-users(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users