octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #43086] princomp() failed with one out argumen


From: anonymous
Subject: [Octave-bug-tracker] [bug #43086] princomp() failed with one out argument
Date: Wed, 27 Aug 2014 05:41:03 +0000
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36

URL:
  <http://savannah.gnu.org/bugs/?43086>

                 Summary: princomp() failed with one out argument
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Wed 27 Aug 2014 05:41:02 AM UTC
                Category: Octave Forge Package
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Regression
                  Status: None
             Assigned to: None
         Originator Name: Tong Qu
        Originator Email: address@hidden
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.8.1
        Operating System: Mac OS

    _______________________________________________________

Details:

package: statistics
version: 1.2.3
function: princomp()


octave:4> pkg load all
octave:5> COEFF = princomp(rand(100))
error: 'r' undefined near line 103 column 51
error: invalid limit value in colon expression
error: evaluating argument list element number 1
error: called from:
error:   /opt/local/share/octave/packages/statistics-1.2.3/princomp.m at line
103, column 13
octave:5>


I ckecked the 'princomp.m' file and did found there are something wrong with
th e code:


   if nargout > 1

      # Get the Scores
      SCORE = Xcentered*COEFF;
        
      # Get the rank of the SCORE matrix        
      r = rank(SCORE); 

      # Only use the first r columns, pad rest with zeros if economy !=
'econ'
      SCORE = SCORE(:,1:r) ; 
         
      if !(nargin == 2 && strcmpi ( varargin{:} , "econ"))
            SCORE = [SCORE, zeros(nobs , nvars-r)];
      else
            COEFF   = COEFF(: , 1:r);   
      endif

    endif

    # This is the same as the eigenvalues of the covariance matrix of X
    latent  = (diag(S'*S)/(size(Xcentered,1)-1))(1:r);

    if nargout > 2
      if !(nargin == 2 && strcmpi ( varargin{:} , "econ"))
          latent= [latent;zeros(nvars-r,1)];
      endif
    endif

    if nargout > 3
        # Calculate the Hotelling T-Square statistic for the observations
        tsquare = sumsq(zscore(SCORE(:,1:r)),2);
    endif


If there is only one input argument, the variable 'r' is then not defined.




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?43086>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]