On Mon, 9 Sep 2019, Artur Tarassow wrote:
Am 08.09.19 um 10:59 schrieb Riccardo (Jack) Lucchetti:
> On Sun, 8 Sep 2019, Artur Tarassow wrote:
>
>> Hi all,
>>
>> for some function I need to check whether the passed series corresponds to
>> the variable defining the cross-sectional dimension of a panel dataset.
>
> [...]
>
>> Do you some other ideas?
>
> If the variable in question is guaranteed to be discrete, you could use
> this:
>
> <hansl>
> function scalar is_crossdim_index_series(series x)
> ret = isdiscrete(x)
> if !ret
> return ret
> endif
>
> matrix H = mxtab(x, $unit) .> 0
> # check for 1-to-1 correspondence
> chk = sumr(H) | sumc(H)'
> ret = (maxc(chk) == 1) && (minc(chk) == 1)
> return ret
> end function
>
> # example
>
> open abdata.gdt --quiet
> eval is_crossdim_index_series(YEAR)
> discrete unit
> eval is_crossdim_index_series(unit)
> </hansl>
Nice solution, Jack. Works fine here. Maybe another candidate for extra.gfn?
Looks like a basic helper function to me.
Sorry, I haven't been following this very closely, but might it work
just to check whether the putative "crossdim_index_series" has
correlation 1.0 with $unit? And similarly for the built-in "time" if
you want to check for a putative panel-time variable.
Moreover (but here I have to stress the caveat above more firmly)
why would one need this when you have $unit and time?
Allin