Am 14.07.2021 03:34 schrieb Allin Cottrell:
On Tue, 13 Jul 2021, atecon wrote:
> Am 13.07.2021 10:40 schrieb Sven Schreiber:
>> Am 13.07.2021 um 09:39 schrieb atecon:
>>
>>> <hansl>
>>> matrix m = {NA; NA}
>>> eval uniq(m)
>>>
>>> ? eval uniq(m)
>>> Data error
>>> </hansl>
>>>
>>> The doc is silent about the case when all entries of the column are
>>> NA.
>>> I am a bit surprised that this leads to a data error and hence full
>>> stop. What about returning an empty matrix in this case?
>>
>> Sounds good to me.
That's now in git: values and uniq return empty matrices given input
that's all-NAs.
Thank you for this new feature, Allin.
> I just see that this is a "structural" issue. The same
applies also
> for quantile() (and probably many more functions):
>
> <hansl>
> matrix m1 = {1, NA; 3, NA}
> matrix m2 = {1, -1; 3, -3}
>
> eval quantile(m2, 0.5)
> eval quantile(m1, 0.5)
>
> ? eval quantile(m2, 0.5)
> 2 -2
>
> ? eval quantile(m1, 0.5)
> Data error
This seems a somewhat different issue. Would you want to see a return
value of {2, nan} for m1?
Python's numpy does exactly that:
<Python>
import numpy as np
m = [[1, 2], [np.nan, np.nan]]
np.quantile(m, 0.5, axis=1)
array([1.5, nan]) # return
</Python>
Could anyone say what R, Julia, Stata or Eviews do in this case?
Artur