On Thu, 15 Oct 2015, Artur T. wrote:
Dear all,
I would like to compute the mean of a vector which involves NAs, implying
that the NAs should simply be neglected/not counted. But this is not the
way gretl handles matrices:
<gretl>
matrix A = {NA, 1; 2, 2; 1, 3}
mA = meanc(A)
mA
</gretl>
yields
<output>
mA (1 x 2)
nan 2
</output>
Is this intended? For instance, R, it seems, fully neglects the NAs and
computes the mean.
Yes, it's intended. There's really no such thing as NA in a gretl
matrix, the "closest translation" is NaN (not-a-number) and that's
what gets written into the matrix if you give NA as an element. And
NaN (a standard C-library/IEEE concept) turns everything it touches
into another NaN: x + NaN = NaN, x * NaN = NaN, and so on.
How are NAs (NaNs) getting into your matrix? Why do you think they
ought to be ignored/skipped instead of propagating when doing
calculations on the matrix?
Allin Cottrell