The point is that in ur application u treat (1,2) and (2,1) as
different, but sometimes 'uniq' shall mean a 'communication' between the
2 'factors' and then the different treatment is wrong. At first I was up
to think that the short formula would not differentiate between them
opposed to my (very long) solution to ur problem. But the not
differentiating solution is the problematic one.
21.11.2013 16:25, Giuseppe Vittucci:
I don't see your point...
In your case ndigits is 0 and therefore:
unique = region * 10 + sector
This is enough to produce unique values for each region/sector
combination.
(1,2) and (2,1) must be treated as different and they do...
On Thu, 2013-11-21 at 15:57 +0100, Pindar wrote:
> Yes, nice, but one has to check that 'region' and 'sector' do not
> share a common cluster ID like in
>
> <hansl>
> region = randgen(i,1,10)
> sector = randgen(i,1,5)
> <hansl>
>
> Since combinations like (1,2) and (2,1) are treated as being
> different.
> Hence, with a primary data manipulation 'sector = randgen(i,1,5) +100'
> things should be fine.
>
> 21.11.2013 15:13, Riccardo (Jack) Lucchetti:
>
>> On Thu, 21 Nov 2013, Giuseppe Vittucci wrote:
>>
>>> 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?
>> You mean, like this?
>>
>> <hansl>
>> nulldata 1024
>>
>> # simulated data
>> region = randgen(i,1,20)
>> sector = randgen(i,10,99)
>> # ----------------------------------------------
>> scalar ndigits = floor(log10(max(sector)))
>> series unique = region * 10^(ndigits+1) + sector
>> </hansl>
>>
>>
>> -------------------------------------------------------
>> Riccardo (Jack) Lucchetti
>> Dipartimento di Scienze Economiche e Sociali (DiSES)
>>
>> Università Politecnica delle Marche
>> (formerly known as Università di Ancona)
>>
>> r.lucchetti(a)univpm.it
>>
http://www2.econ.univpm.it/servizi/hpp/lucchetti
>> -------------------------------------------------------
>>
>>
>> _______________________________________________
>> Gretl-users mailing list
>> Gretl-users(a)lists.wfu.edu
>>
http://lists.wfu.edu/mailman/listinfo/gretl-users
> _______________________________________________
> Gretl-users mailing list
> Gretl-users(a)lists.wfu.edu
>
http://lists.wfu.edu/mailman/listinfo/gretl-users
_______________________________________________
Gretl-users mailing list
Gretl-users(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users