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

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

[Octave-patch-tracker] [patch #10014] [octave forge] (statistics) Make f


From: anonymous
Subject: [Octave-patch-tracker] [patch #10014] [octave forge] (statistics) Make function crosstab n-dimensional
Date: Sat, 9 Jan 2021 06:24:36 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0

URL:
  <https://savannah.gnu.org/patch/?10014>

                 Summary: [octave forge] (statistics) Make function crosstab
n-dimensional
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Sat 09 Jan 2021 11:24:33 AM UTC
                Category: Forge : new feature
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: s.guidoni@virgilio.it
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

This patch makes crosstab n-dimensional, improving its usefulness and MATLAB
compatibility, e.g.:


>> x = [1 1 2 3 1];
>> y = [1 2 5 3 1];
>> z = [1 1 2 2 1];
>> table = crosstab(x,y,z)
warning: crosstab: chi-square test only available for 2D results
warning: called from
    crosstab at line 91 column 5
table =

ans(:,:,1) =

   2   1   0   0
   0   0   0   0
   0   0   0   0

ans(:,:,2) =

   0   0   0   0
   0   0   0   1
   0   0   1   0


This patch also improves MATLAB compatibility in other ways, e.g. ("meas" is a
cell array of strings):


>> load fisheriris;
>> Z = linkage(meas,'average','chebychev');
>> T = cluster(Z,'maxclust',3);
>> [table,chi2,p,labels] = crosstab(T,species)
table =

   50    0    0
    0    0   10
    0   50   40

chi2 =  166.67
p = 0
labels =
{
  [1,1] = 1
  [2,1] = 2
  [3,1] = 3
  [1,2] = setosa
  [2,2] = versicolor
  [3,2] = virginica
}
>> help crosstab

 -- T = crosstab (X1, X2)
 -- Function File: T = crosstab (X1, ..., XN)
 -- Function File: [T, CHI-2, P, LABELS] = crosstab (...)
     Create a cross-tabulation (contingency table) T from data vectors.

     The inputs X1, X2, ...  XN must be vectors of equal length with a
     data type of numeric, logical, char, or string (cell array).

     As additional return values 'crosstab' returns the chi-square
     statistics CHI-2, its p-value P and a cell array LABELS, containing
     the labels of each input argument.

     Currently CHI-2 and P are available only for 1 or 2-dimensional T,
     with 'crosstab' returning a NaN value for both CHI-2 and P for
     3-dimensional, or more, T.

See also: grp2idx,tabulate.




    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Sat 09 Jan 2021 11:24:33 AM UTC  Name: crosstab.patch  Size: 5KiB   By:
None

<http://savannah.gnu.org/patch/download.php?file_id=50684>

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/patch/?10014>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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