


Compute the standard deviation for each observed variable (possibly with missing observations).


0001 function dataset_ = compute_stdv(dataset_) 0002 % Compute the standard deviation for each observed variable (possibly with missing observations). 0003 0004 %@info: 0005 %! @deftypefn {Function File} {@var{dataset_} =} compute_stdv(@var{dataset_}) 0006 %! @anchor{compute_stdv} 0007 %! This function computes the standard deviation of the observed variables (possibly with missing observations). 0008 %! 0009 %! @strong{Inputs} 0010 %! @table @var 0011 %! @item dataset_ 0012 %! Dynare structure describing the dataset, built by @ref{initialize_dataset} 0013 %! @end table 0014 %! 0015 %! @strong{Outputs} 0016 %! @table @var 0017 %! @item dataset_ 0018 %! Dynare structure describing the dataset, built by @ref{initialize_dataset} 0019 %! @end table 0020 %! 0021 %! @strong{This function is called by:} 0022 %! @ref{descriptive_statistics}. 0023 %! 0024 %! @strong{This function calls:} 0025 %! @ref{ndim}, @ref{demean}, @ref{nandemean}. 0026 %! 0027 %! @strong{Remark 1.} On exit, a new field is appended to the structure: @code{dataset_.descriptive.stdv} is a 0028 %! @tex{n\times 1} vector (where @tex{n} is the number of observed variables as defined by @code{dataset_.info.nvobs}). 0029 %! 0030 %! @end deftypefn 0031 %@eod: 0032 0033 % Copyright (C) 2011 Dynare Team 0034 % stephane DOT adjemian AT univ DASH lemans DOT fr 0035 % 0036 % This file is part of Dynare. 0037 % 0038 % Dynare is free software: you can redistribute it and/or modify 0039 % it under the terms of the GNU General Public License as published by 0040 % the Free Software Foundation, either version 3 of the License, or 0041 % (at your option) any later version. 0042 % 0043 % Dynare is distributed in the hope that it will be useful, 0044 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0045 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0046 % GNU General Public License for more details. 0047 % 0048 % You should have received a copy of the GNU General Public License 0049 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0050 0051 if dataset_.missing.state 0052 dataset_.descriptive.stdv = sqrt(nanmean(bsxfun(@power,nandemean(transpose(dataset_.data)),2))); 0053 else 0054 dataset_.descriptive.stdv = sqrt(mean(bsxfun(@power,demean(transpose(dataset_.data)),2))); 0055 end