I wrote simple code, but it looks messy because I am removing NaN and I usually want to apply elementbyelement. To illustrate, I show my calculation of the Pearson correlation coefficient:
function r(obs, mod)
om = (obs  mean(obs[!isnan.(obs)])) .* (mod  mean(mod[!isnan.(mod)]))
oo = (obs  mean(obs[!isnan.(obs)])).^2
mm = (mod  mean(mod[!isnan.(mod)])).^2
sum(om[!isnan.(om)]) ./ sqrt.(sum(oo[!isnan.(oo)]) .* sum(mm[!isnan.(mm)]))
end
where obs
and mod
are arrays of floats of arbitrary dimension. It looks messy because of the additions of:

[!isnan.()]
to the argument of every use ofsum()
andmean()
; and 
.
for the functionsisnan()
andsqrt()
, but of course not forsum()
andmean()
.
There must be a less verbose, or more elegant, way to write this?
If you have comments on the functional part of the code, like bugs, those are welcome as well! My intention was to codify the equation for r, given by Stow et al., 2009 (alternative source).