Skip to content

Commit

Permalink
Option renamed inside corrOrdinal
Browse files Browse the repository at this point in the history
MarcoRianiUNIPR committed Dec 31, 2024
1 parent 4ada13f commit 9e76965
Showing 9 changed files with 130 additions and 68 deletions.
Binary file modified toolbox/datasets/multivariate/cinema.mat
Binary file not shown.
4 changes: 2 additions & 2 deletions toolbox/graphics/balloonplot.m
Original file line number Diff line number Diff line change
@@ -186,8 +186,8 @@
colslab={'Wife' 'Alternating' 'Husband' 'Jointly'};
% If the DimensionNames is set the xlabel and ylabel will be added
% automatically.
Ntable.Properties.DimensionNames=["Repartition in the couple" "13 housetasks"];
Ntable=array2table(N,'VariableNames',colslab,'RowNames',rowslab);
Ntable.Properties.DimensionNames=["Repartition in the couple" "13 housetasks"];
% Call to balloonplot with option 'contrib2Index' boolean equal to
% true. In this case the contributions to the Chi2 statistic
% are shown. The color is associated to the sign.
@@ -199,7 +199,7 @@
%% Example of ballonplot with option contrib2Index as a matrix.
load SportHealth.mat
out=corrOrdinal(SportHealth);
balloonplot(SportHealth,'contrib2Index',out.IndCont2CminusD)
balloonplot(SportHealth,'contrib2Index',out.Contrib2CminusD)
%}

%% Beginning of code
96 changes: 48 additions & 48 deletions toolbox/helpfiles/FSDA/corrOrdinal.html
Original file line number Diff line number Diff line change
@@ -38,26 +38,26 @@
% zero, this indicates a strong positive association between the
% written and the oral examination.</pre></div></div><pre class="codeoutput">Test of H_0: independence between rows and columns
The standard errors are computed under H_0
Coeff se zscore pval
_____ ____ ______ ____
Coeff se zscore pval
_______ ________ ______ __________

gamma 0.50 0.10 5.09 0.00
taua 0.18 0.05 3.86 0.00
taub 0.31 0.06 5.09 0.00
tauc 0.27 0.05 5.09 0.00
dyx 0.31 0.06 5.09 0.00
gamma 0.5 0.098239 5.0896 3.588e-07
taua 0.18342 0.047553 3.8571 0.00011474
taub 0.30557 0.060038 5.0896 3.588e-07
tauc 0.27375 0.053786 5.0896 3.588e-07
dyx 0.31466 0.061823 5.0896 3.588e-07

-----------------------------------------
Indexes and 95% confidence limits
The standard error are computed under H_1
Value StandardError ConflimL ConflimU
_____ _____________ ________ ________
Value StandardError ConflimL ConflimU
_______ _____________ ________ ________

gamma 0.50 0.09 0.33 0.67
taua 0.18 0.01 0.16 0.21
taub 0.31 0.06 0.19 0.42
tauc 0.27 0.05 0.17 0.38
dyx 0.31 0.06 0.20 0.43
gamma 0.5 0.0876 0.32831 0.67169
taua 0.18342 0.011904 0.16009 0.20675
taub 0.30557 0.05852 0.19087 0.42027
tauc 0.27375 0.053786 0.16833 0.37917
dyx 0.31466 0.059899 0.19726 0.43205

</pre></p></div></div><div id="example_2" class="example_module expandableContent"><div id="Example_2"></div><h3 class="expand"><span><a href="javascript:void(0);" style="display: block;" title="Expand/Collapse"><span class="example_title"> <li><img alt="" src="images_help/M.gif" style="width: 12px; height: 12px"> Compare calculation of tau-b with that which comes from
Matlab function corr.</li></span></a></span></h3><div class="collapse"><p><div class="programlisting"><div class="codeinput"><pre class="matlab-code">% Starting from a contingency table, create the original data matrix to
@@ -119,53 +119,53 @@
% It is clear the positive relationship between
% 'Self-Reported Health' and 'Exercise Frequency'</pre></div></div><pre class="codeoutput">Test of H_0: independence between rows and columns
The standard errors are computed under H_0
Coeff se zscore pval
_____ ____ ______ ____
Coeff se zscore pval
_______ ________ ______ ____

gamma 0.59 0.05 11.19 0.00
taua 0.34 0.04 8.82 0.00
taub 0.46 0.04 11.19 0.00
tauc 0.45 0.04 11.19 0.00
dyx 0.45 0.04 11.19 0.00
gamma 0.59385 0.053088 11.186 0
taua 0.33958 0.03852 8.8157 0
taub 0.45635 0.040796 11.186 0
tauc 0.45128 0.040343 11.186 0
dyx 0.4525 0.040451 11.186 0

-----------------------------------------
Indexes and 95% confidence limits
The standard error are computed under H_1
Value StandardError ConflimL ConflimU
_____ _____________ ________ ________
Value StandardError ConflimL ConflimU
_______ _____________ ________ ________

gamma 0.59 0.05 0.50 0.69
taua 0.34 0.01 0.32 0.36
taub 0.46 0.04 0.38 0.54
tauc 0.45 0.04 0.37 0.53
dyx 0.45 0.04 0.37 0.53
gamma 0.59385 0.04837 0.49905 0.68866
taua 0.33958 0.011291 0.31745 0.36171
taub 0.45635 0.040331 0.3773 0.5354
tauc 0.45128 0.040343 0.37221 0.53036
dyx 0.4525 0.040106 0.37389 0.53111

</pre><a href='http://rosa.unipr.it/fsda/corrOrdinal.html#ExtraExample_5'><img vspace="5" hspace="5" src="images\corrOrdinal_01.png" alt="Click here for the graphical output of this example (link to Ro.S.A. website)"> <img vspace="5" hspace="5" src="images\corrOrdinal_02.png" alt=""> </a></p></div></div><div id="Extraexample_6" class="example_module expandableContent"><div id="ExtraExample_6"></div><h3 class="expand"><span><a href="javascript:void(0);" style="display: block;" title="Expand/Collapse"><span class="example_title"><li><img alt="" src="images_help/M.gif" style="width: 12px; height: 12px"> Example 2 of use of option plots.</li></span></a></span></h3><div class="collapse"><p>
Opinion on the movied watched and age interval<div class="programlisting"><div class="codeinput"><pre class="matlab-code">load cinema.mat
Opinion on the movie watched and age interval<div class="programlisting"><div class="codeinput"><pre class="matlab-code">load cinema.mat
out=corrOrdinal(cinema,'plots',true);
% It is clear the negative relationship between
% age and satisfaction towards the watched movie</pre></div></div><pre class="codeoutput">Test of H_0: independence between rows and columns
The standard errors are computed under H_0
Coeff se zscore pval
_____ ____ ______ ____
Coeff se zscore pval
________ ________ _______ __________

gamma -0.22 0.03 -6.60 0.00
taua -0.11 0.02 -6.01 0.00
taub -0.16 0.02 -6.60 0.00
tauc -0.15 0.02 -6.60 0.00
dyx -0.13 0.02 -6.60 0.00
gamma -0.22239 0.033693 -6.6004 4.0994e-11
taua -0.10884 0.018121 -6.0064 1.8967e-09
taub -0.15598 0.023632 -6.6004 4.0994e-11
tauc -0.14501 0.02197 -6.6004 4.0994e-11
dyx -0.12946 0.019614 -6.6004 4.0994e-11

-----------------------------------------
Indexes and 95% confidence limits
The standard error are computed under H_1
Value StandardError ConflimL ConflimU
_____ _____________ ________ ________

gamma 0.00 0.03 0.00 0.00
taua 0.00 0.00 0.00 0.00
taub 0.00 0.02 0.00 0.00
tauc 0.00 0.02 0.00 0.00
dyx 0.00 0.02 0.00 0.00
gamma 0 0.033312 0 0
taua 0 0.0035492 0 0
taub 0 0.023518 0 0
tauc 0 0.02197 0 0
dyx 0 0.019609 0 0

Warning: Ignoring extra legend entries.
</pre><a href='http://rosa.unipr.it/fsda/corrOrdinal.html#ExtraExample_6'><img vspace="5" hspace="5" src="images\corrOrdinal_03.png" alt="Click here for the graphical output of this example (link to Ro.S.A. website)"> <img vspace="5" hspace="5" src="images\corrOrdinal_04.png" alt=""> </a></p></div></div></div></div></div><div class="ref_sect" itemprop="content"><h2 id="Inputs">Input Arguments</h2><div class="expandableContent"><div class="arguments"><div class="input_argument_container"><p class="switch"><a class="expandAllLink" href="javascript:void(0);">expand all</a></p><div class="expandableContent"> <div id="inputarg_N" class="clearfix"> </div> <h3 id="input_argument_N" class="expand"> <span> <a href="javascript:void(0);" style="display: block;" title="Expand/Collapse"> <span class="argument_name"><code>N</code> &#8212; Contingency table (default) or n-by-2 input dataset. </span> </a><span class="example_desc">Matrix or Table.</span></span></h3> <div class="collapse"> <p><p>Matrix or table which contains the input contingency
@@ -249,20 +249,20 @@
standard errors (second column), lower confidence limit
(third column), upper confidence limit (fourth column).</p> <p>
Note that the standard errors in this table are computed not
assuming the null hypothesis of independence.</p></p></td></tr><tr valign="top"><td><code>IndContr2CminusD</code></td><td><p>IxJ array containing individual contributions to
the commpon numerator of all the indexes above (namely
C-D).</p></td></tr><tr valign="top"><td><code>IndContr2CminusDtable</code></td><td><p>IxJ table containing individual contributions to
the commpon numerator of all the indexes above (namely
assuming the null hypothesis of independence.</p></p></td></tr><tr valign="top"><td><code>Contrib2CminusD</code></td><td><p>IxJ array containing individual contributions to
the common numerator of all the indexes above (namely
C-D).</p></td></tr><tr valign="top"><td><code>Contrib2CminusDtable</code></td><td><p>IxJ table containing individual contributions to
the common numerator of all the indexes above (namely
C-D).</p></td></tr></table></p></div></div></div></div></div></div><div class="moreabout ref_sect"><h2 id="MoreAbout">More About</h2><div class="expandableContent"><p class="switch"><a class="expandAllLink" href="javascript:void(0);">expand all</a></p><div class="expandableContent" itemprop="content"><h3 class="expand"><span><a href="javascript:void(0);" style="display: block;" title="Expand/Collapse"><span>Additional Details</span></a></span></h3><div class="expand"><p><p>

All these indexes are based on concordant and discordant pairs.</p> <p>
A pair of observations is concordant if the subject who is higher on one
variable also is higher on the other variable, and a pair of observations
is discordant if the subject who is higher on one variable is lower on
the other variable.</p> <p>
More formally, a pair (i,j), i=1, 2, ..., n is concordant if
(x(i)-x(j)) $\times$ (y(i)-y(j))&gt;0.</p> <p>
It is discordant if (x(i)-x(j) ) $\times$ (y(i)-y(j))&lt;0
More formally, a pair $(i,j)$, $i=1, 2, ..., n$ is concordant if
$(x(i)-x(j)) \times (y(i)-y(j))&gt;0$.</p> <p>
It is discordant if $(x(i)-x(j) ) \times (y(i)-y(j))&lt;0$.</p> <p>
Let $C$ be the total number of concordant pairs (concordances) and $D$
the total number of discordant pairs (discordances) . If $C &gt; D$ the
variables have a positive association, but if $C &lt; D$ then the variables
68 changes: 65 additions & 3 deletions toolbox/helpfiles/FSDA/datasets_mv.html
Original file line number Diff line number Diff line change
@@ -211,6 +211,50 @@ <h3>Data matrices </h3>
- enterpreneous and skilled self-employed among those of working age.
</td>
</tr>
<tr>
<td bgcolor="#F2F2F2"><tt>fat</tt></td>
<td bgcolor="#F2F2F2">Phisical measurements of 251 males. The variables
are<br>
<br>
-
body_fat: Percent body fat using Brozek's equation, 457/Density - 414.2<br>
-
body_fat_siri: Percent body fat using Siri's equation, 495/Density - 450<br>
-
density: Density (gm/cm^2)<br>
-
age: Age (yrs)<br>
-
weight: Weight (lbs)<br>
-
height: Height (inches)<br>
-
BMI: Adiposity index = Weight/Height^2 (kg/m^2)<br>
- ffweight: Fat Free Weight = (1 - fraction of body fat) * Weight, using Brozek's formula (lbs)<br>
-
neck: Neck circumference (cm)<br>
-
chest: Chest circumference (cm)<br>
-
abdomen: Abdomen circumference (cm) "at the umbilicus and level with the iliac crest"<br>
-
hip: Hip circumference (cm)<br>
- thigh: Thigh circumference (cm)<br>
-
knee: Knee circumference (cm)<br>
-
ankle: Ankle circumference (cm)<br>
-
bicep: Extended biceps circumference (cm)<br>
- forearm: Forearm circumference (cm)<br>
-
wrist: Wrist circumference (cm) "distal to the styloid processes"<br>Note that
observation 182 in the original dataset has been removed because <span>it
reported a percent body fat estimate equal to 0. The purpose is to predict
body_fat from the other measurements.</span><br><span>The source of the
data is attributed to Dr. A. Garth Fisher, Human Performance Research
Center, Brigham Young University, Provo, Utah 84602,</span></td>
</tr>
<tr>
<td bgcolor="#F2F2F2"><tt>fondi</tt></td>
<td bgcolor="#F2F2F2">The fondi data set, introduced by Zani (2000),
@@ -234,12 +278,30 @@ <h3>Data matrices </h3>
which allows different transformations for positive and negative responses is neede to analyze these data. </span><br>
</td>
</tr>
<tr>
<tr>
<td bgcolor="#F2F2F2"><tt>head</tt></td>
<td bgcolor="#F2F2F2">The Swiss Heads dataset was introduced by B. Flury
and H. Riedwyl (1988). It contains information on six variables
describing the dimensions of the heads of 200 twenty year old Swiss
soldiers.</td>
</tr>
<tr>
<td bgcolor="#F2F2F2"><tt>hprice</tt></td>
<td bgcolor="#F2F2F2">Sales prices of 546 houses in the city of Windsor,
Ontario, Canada, during July, August and September, 1987.<br>The variables
are<br>- lotsize: the lot size of a property in square feet <br>-
bedrooms: number of bedrooms <br>- bathrms: number of full bathrooms <br>-
stories number of stories excluding basement&nbsp; <br>- driveway does the
house has a driveway? <br>- recroom does the house has a recreational
room? <br>- fullbase: does the house has a full finished basement? <br>-
gashw: does the house uses gas for hot water heating? <br>- airco: does
the house has central air conditioning? <br>- garagepl: number of garage
places <br>- prefarea: is the house located in the preferred neighbourhood
of the city?<br>-price: sale price of a house.<br><br>The reference is
Verbeek, Marno (2004) A Guide to Modern Econometrics, John Wiley and Sons,
chapter 3. Journal of Applied Econometrics data archive :
<a href="http://qed.econ.queensu.ca/jae/">http://qed.econ.queensu.ca/jae/</a>
.</td>
</tr>
<tr>
<td bgcolor="#F2F2F2"><tt>milk</tt></td>
@@ -435,8 +497,8 @@ <h3>Contingency tables </h3>
</tr>
<tr>
<td bgcolor="#F2F2F2"><tt>SportHealth</tt></td>
<td bgcolor="#F2F2F2">The dataset SportHealth contains a contingency table between "Physical Activity Frequency" and self assesment "Quality of Life Ratings".
The number of people interviewed is 303.</td>
<td bgcolor="#F2F2F2">The SportHealth dataset contains a contingency table between "Physical Activity Frequency" and self assesment "Quality of Life Ratings".
The number of people interviewed is 303.</td>
</tr>
</tbody>
</table>
Binary file modified toolbox/helpfiles/FSDA/images/corrOrdinal_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/corrOrdinal_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/corrOrdinal_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toolbox/helpfiles/FSDA/images/corrOrdinal_04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 15 additions & 15 deletions toolbox/multivariate/corrOrdinal.m
Original file line number Diff line number Diff line change
@@ -150,11 +150,11 @@
% (third column), upper confidence limit (fourth column).
% Note that the standard errors in this table are computed not
% assuming the null hypothesis of independence.
% out.IndContr2CminusD = IxJ array containing individual contributions to
% the commpon numerator of all the indexes above (namely
% out.Contrib2CminusD = IxJ array containing individual contributions to
% the common numerator of all the indexes above (namely
% C-D).
% out.IndContr2CminusDtable = IxJ table containing individual contributions to
% the commpon numerator of all the indexes above (namely
% out.Contrib2CminusDtable = IxJ table containing individual contributions to
% the common numerator of all the indexes above (namely
% C-D).
%
%
@@ -166,9 +166,9 @@
% variable also is higher on the other variable, and a pair of observations
% is discordant if the subject who is higher on one variable is lower on
% the other variable.
% More formally, a pair (i,j), i=1, 2, ..., n is concordant if
% (x(i)-x(j)) $\times$ (y(i)-y(j))>0.
% It is discordant if (x(i)-x(j) ) $\times$ (y(i)-y(j))<0
% More formally, a pair $(i,j)$, $i=1, 2, ..., n$ is concordant if
% $(x(i)-x(j)) \times (y(i)-y(j))>0$.
% It is discordant if $(x(i)-x(j) ) \times (y(i)-y(j))<0$.
% Let $C$ be the total number of concordant pairs (concordances) and $D$
% the total number of discordant pairs (discordances) . If $C > D$ the
% variables have a positive association, but if $C < D$ then the variables
@@ -500,7 +500,7 @@

%{
%% Example 2 of use of option plots.
% Opinion on the movied watched and age interval
% Opinion on the movie watched and age interval
load cinema.mat
out=corrOrdinal(cinema,'plots',true);
% It is clear the negative relationship between
@@ -746,7 +746,7 @@
pvaltaua = 2*(1 - normcdf(abs(ztaua))); %p-value (two-sided)

%% tau-b statistic
% For computationl purposes it is better to use relative frequencies
% For computational purposes it is better to use relative frequencies
% rather than absolute frequencies
Pi=N/n; % matrix of relative frequencies
pdiff=(con-dis)/n;
@@ -755,7 +755,7 @@
delta2=sqrt(1 - sum((ndotj/n).^2));
tauij=(2 * pdiff + Pdiff * repmat(ndotj/n,I,1) ) * delta2 * delta1 + ...
(Pdiff * repmat(nidot/n,1,J) * delta2)/delta1;
% setaub = standard errot used to compute the confidence interval
% setaub = standard error used to compute the confidence interval
setaub= sqrt(( ( sum(Pi(:) .* tauij(:).^2) - sum(Pi(:) .* tauij(:)).^2)/(delta1 * delta2)^4)/n);

% The formula written in the help section (which uses the absolute
@@ -788,7 +788,7 @@
pvaltauc = 2*(1 - normcdf(abs(ztauc))); %p-value (two-sided)

%% Somers' D statistic
% Find standard error of Somers D stat
% Find standard error of Somers' D stat
nidotrep=repmat(nidot,1,J);

% sesom = standard errot used to compute the confidence interval
@@ -846,10 +846,10 @@
out.ConfLimtable=ConfLimtable;

NconMinusNdis=Ncon-Ndis;
out.IndContr2CminusD=NconMinusNdis;
IndContr2CminusDtable=Ntable;
IndContr2CminusDtable{:,:}=NconMinusNdis;
out.IndContr2CminusDtable=IndContr2CminusDtable;
out.Contrib2CminusD=NconMinusNdis;
Contrib2CminusDtable=Ntable;
Contrib2CminusDtable{:,:}=NconMinusNdis;
out.Contrib2CminusDtable=Contrib2CminusDtable;

if dispresults == true
if NoStandardErrors == false

0 comments on commit 9e76965

Please sign in to comment.