Hi Paolo,
here is an example on how to do the mapping:
<hansl>
set verbose off
clear
nulldata 50
set seed 1234
series y = ceil(randgen(u, 0, 3)) # sample series with 3
disctinct integer values
strings label = defarray("a", "b", "c") # mapping: 1=a, 2=b,
3=c
stringify(y, label) # do the mapping
print y -o
/* Output
y
1 c
2 b
3 b
4 c
5 b
*/
</hansl>
I guess you need to change the numbering of "y" and the string array
"label", respectively.
This may be done as follows:
<hansl>
# swap categorie 2 and 3
matrix my = {y}
series y_reordered = replace(y, {2, 3}, {3,2})
stringify(y_reordered, label)
print y y_reordered -o
/* Output
y y_reordered
1 c b
2 b c
3 b c
4 c b
5 b c
*/
</hansl>
Artur
Am 01.02.2023 11:02 schrieb Paolo Chirico:
> Dears,
> If I have a string variable with the following mapping:
> 1 = 'middle'
> 2 = 'low'
> 3 = 'high'
> there is a command to give the series a new, more logical mapping? Like
> as:
> 1 = 'low'
> 2 = 'middle'
> 3 = 'high'
> I've simplified the example, but the concept is: changing the
> numerical mapping of the entire series
>
> Paolo
> _______________________________________________
> Gretl-users mailing list -- gretl-users(a)gretlml.univpm.it
> To unsubscribe send an email to gretl-users-leave(a)gretlml.univpm.it
> Website:
>
https://gretlml.univpm.it/postorius/lists/gretl-users.gretlml.univpm.it/