BookmarkSubscribe
Choose Language Hide Translation Bar

How do I create a plot for nested contingency tables?

Hi all,

I have two 2x2 contingency tables, one nested in the other.  For example,  I am looking at students in classes classified by their gender (M or F) and whether they actively participates in athletics program (A or NA) ; and then among those in each group, I am looking at the frequency of students who ran into disciplinary problems.  Thus the table may look like

M &A   50 (12)

F & A    40  (8)

M & NA  150 (8)

F & NA  150 (6)

Total  390 (34)

The numbers in the parenthesis are the frequency of students who ran into disciplinary problems.  So, for example, out of 50 male athletes  12 had disciplinary problems, etc.,  I want to  know how to create a graph in JMP, say a Mosaic plot, to convey the information.  Also, is there any simple way to compare between the proportions?

I would appreciate any help. Thank you in advance for your response.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How do I create a plot for nested contingency tables?

There is a plot "Share Chart" in the Categorical platform that may be what you want. Or the "Frequency Chart".

Run this JSL example to have a look:

// Example table

dt = New Table( "test",

Add Rows( 8 ),

New Column( "sex", Character, Set Values( {"M", "M", "M", "M", "F", "F", "F", "F"} ) ),

New Column( "athlete", Character, Set Values( {"A", "A", "NA", "NA", "A", "A", "NA", "NA"} ) ),

New Column( "diciplinary problems", Character, Set Values( {"DP", "NP", "DP", "NP", "DP", "NP", "DP", "NP"} ) ),

New Column( "frequency", Numeric, Set Values( [12, 38, 8, 142, 8, 32, 6, 144] ) )

);

// Test for homogeneity

dt << Categorical(

Freq( :frequency ),

X( :sex, :athlete ),

Grouping Option( Both ),

Separate Responses( :diciplinary problems ),

Share Chart(1),

Frequency Chart( 1 ),

Transposed Freq Chart( 1 ),

Test Response Homogeneity( 1 )

);

2 REPLIES 2

Re: How do I create a plot for nested contingency tables?

There is a plot "Share Chart" in the Categorical platform that may be what you want. Or the "Frequency Chart".

Run this JSL example to have a look:

// Example table

dt = New Table( "test",

Add Rows( 8 ),

New Column( "sex", Character, Set Values( {"M", "M", "M", "M", "F", "F", "F", "F"} ) ),

New Column( "athlete", Character, Set Values( {"A", "A", "NA", "NA", "A", "A", "NA", "NA"} ) ),

New Column( "diciplinary problems", Character, Set Values( {"DP", "NP", "DP", "NP", "DP", "NP", "DP", "NP"} ) ),

New Column( "frequency", Numeric, Set Values( [12, 38, 8, 142, 8, 32, 6, 144] ) )

);

// Test for homogeneity

dt << Categorical(

Freq( :frequency ),

X( :sex, :athlete ),

Grouping Option( Both ),

Separate Responses( :diciplinary problems ),

Share Chart(1),

Frequency Chart( 1 ),

Transposed Freq Chart( 1 ),

Test Response Homogeneity( 1 )

);

Re: How do I create a plot for nested contingency tables?

Thank you very much! This is what I needed.