Am 19.08.20 um 18:32 schrieb Alecos Papadopoulos:
Gretl 2020d, Windows 64-bit.
I give the command
matrix meancolumnsB = meanc(B)
The matrix "meancolumnsB " is generated as a single-row matrix as
expected, but with "nan" in all its cells.
I can see the matrix B ok, it is a 10000 X 9 matrix, I can copy-paste
it, export it in spreadsheet etc.
What I observe is that there are 6 rows in the "B" matrix with "nan"
values.
So it appears that the meanc() function , in contrast to the mean()
function, cannot skip missing values?
If this is the case can we do something about it? The matrix B
collects results from MLE simulations, and there are various instances
where we are bound to get a "nan" value (the MLE did not converge, or
the B may collect the elements of the Hessian but the Hessian is not
computable and the algorithm drops back to OPG, etc)
Note: I also run
matrix meanrowsB = meanr(B)
Here, the result came out ok, with a "nan" result for the 6 rows of
"B" that were filled with "nan" originally. But what would happen if
in some row I would have some numbers and some "nan"? Will the meanr()
return then a "nan" result?
Hi,
Here is a hack from Jack. He posted it some years ago:
<hansl>
function matrix my_meanc(const matrix X)
matrix B = ok(X)
return sumc(B ? X : 0) ./ sumc(B)
end function
matrix A = {NA, 1; 2, 2; 1, 3}
mA = my_meanc(A)
mA
</hansl>
Best,
Artur