Renamed compute_stdv as nanvariance (computes variances instead of standard deviations).

time-shift
Stéphane Adjemian (Charybdis) 2014-05-23 18:06:32 +02:00
parent bdd7b8aacc
commit b2c28530ea
1 changed files with 12 additions and 14 deletions

View File

@ -1,21 +1,21 @@
function dataset_ = compute_stdv(dataset_) function variances = nanvariance(data)
% Compute the standard deviation for each observed variable (possibly with missing observations). % Compute the standard deviation for each observed variable (possibly with missing observations).
%@info: %@info:
%! @deftypefn {Function File} {@var{dataset_} =} compute_stdv(@var{dataset_}) %! @deftypefn {Function File} {@var{variances} =} nanvariance(@var{data})
%! @anchor{compute_stdv} %! @anchor{nanvariance}
%! This function computes the standard deviation of the observed variables (possibly with missing observations). %! This function computes the variances of the observed variables (possibly with missing observations).
%! %!
%! @strong{Inputs} %! @strong{Inputs}
%! @table @var %! @table @var
%! @item dataset_ %! @item datas
%! Dynare structure describing the dataset, built by @ref{initialize_dataset} %! A T*N array of real numbers.
%! @end table %! @end table
%! %!
%! @strong{Outputs} %! @strong{Outputs}
%! @table @var %! @table @var
%! @item dataset_ %! @item variances
%! Dynare structure describing the dataset, built by @ref{initialize_dataset} %! A N*1 vector of real numbers
%! @end table %! @end table
%! %!
%! @strong{This function is called by:} %! @strong{This function is called by:}
@ -30,7 +30,7 @@ function dataset_ = compute_stdv(dataset_)
%! @end deftypefn %! @end deftypefn
%@eod: %@eod:
% Copyright (C) 2011-2012 Dynare Team % Copyright (C) 2011-2014 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -47,10 +47,8 @@ function dataset_ = compute_stdv(dataset_)
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
% Original author: stephane DOT adjemian AT univ DASH lemans DOT fr if isanynan(data)
variances = transpose(nanmean(bsxfun(@power,nandemean(data),2)));
if dataset_.missing.state
dataset_.descriptive.stdv = sqrt(nanmean(bsxfun(@power,nandemean(transpose(dataset_.data)),2)));
else else
dataset_.descriptive.stdv = sqrt(mean(bsxfun(@power,demean(transpose(dataset_.data)),2))); variances = transpose(mean(bsxfun(@power,demean(data),2)));
end end