1function m = nanmean(o) % --*-- Unitary tests --*--
2
3% Returns the mean of the variables in a @dseries object o.
4%
5% INPUTS
6%  o o             dseries object [mandatory].
7%  o geometric     logical [default is false], if true returns the geometric mean.
8%
9% OUTPUTS
10%  o m             1*vobs(o) vector of doubles.
11
12% Copyright (C) 2019 Dynare Team
13%
14% This file is part of Dynare.
15%
16% Dynare is free software: you can redistribute it and/or modify
17% it under the terms of the GNU General Public License as published by
18% the Free Software Foundation, either version 3 of the License, or
19% (at your option) any later version.
20%
21% Dynare is distributed in the hope that it will be useful,
22% but WITHOUT ANY WARRANTY; without even the implied warranty of
23% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24% GNU General Public License for more details.
25%
26% You should have received a copy of the GNU General Public License
27% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
28
29m = nanmean(o.data);
30
31%@test:1
32%$ % Define a dataset.
33%$ A = repmat([1.005, 1.05], 10, 1);
34%$ A(3,1) = NaN;
35%$ A(5,2) = NaN;
36%$
37%$ % Instantiate a time series object and compute the mean.
38%$ try
39%$    ts = dseries(A);
40%$    m = nanmean(ts);
41%$    t(1) = 1;
42%$ catch
43%$    t = 0;
44%$ end
45%$
46%$ if t(1)
47%$    t(2) = dassert(isequal(size(m),[1, 2]), true);
48%$    t(3) = dassert(m, [1.005, 1.05]);
49%$ end
50%$ T = all(t);
51%@eof:1