Names default to here(1);
dt = Open("$Sample_data/Big Class.jmp");
// Column to adjust the difference in means between levels
nc = dt << New Column("height differenced", Numeric, "Continuous", Format("Best", 12), Formula(Parameter({b0 = 5}, If(:sex == "F", :height + b0, :height))));
distances = index(-2,7,incr=.5);
pvalless = {};
pvalmore = {};
for(d=1, d<= n items(distances), d++,
dist = distances[d];
Eval( Eval Expr( nc << Set Formula( Parameter({b0 = expr( dist ) }, If(:sex == "F", :height + b0, :height))) ) );
ow = dt << Oneway(
Y( nc ),
X( :sex ),
Means( 1 ),
t Test( 1 ),
Mean Diamonds( 1 ),
SendToReport( Dispatch( {}, "t Test", OutlineBox, {Close( 1 )} ) )
);
//Extract the prob
pvalless[d] = ((ow << XPath("//OutlineBox[text()='Pooled t Test']"))[1][NumberColBox(4)] << get as matrix)[2];
pvalmore[d] = ((ow << XPath("//OutlineBox[text()='Pooled t Test']"))[1][NumberColBox(4)] << get as matrix)[3];
ow << close window;
);
dtSum = New Table( "Results",
Add Rows( n items(distances) ),
New Column( "Distance",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( distances )
),
New Column( "pvalueless",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( pvalless )
),
New Column( "pvaluemore",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( pvalmore )
)
);
gb = dtSum << Graph Builder(
Size( 876, 379 ),
Show Control Panel( 0 ),
Variables( X( :Distance ), Y( :pvalueless ) ),
Elements( Points( X, Y, Legend( 3 ) ), Line( X, Y, Legend( 5 ) ) ),
SendToReport(
Dispatch(
{},
"pvalueless",
ScaleBox,
{Add Ref Line( 0.05, "Solid", "Black", ".05", 1 )}
),
Dispatch(
{},
"400",
ScaleBox,
{Legend Model( 3, Base( -1, 0, 0, Item ID( "pvaluemore", 1 ) ) )}
),
Dispatch(
{},
"graph title",
TextEditBox,
{Set Text(
"Likelihood of average heights of females being shorter than males by different amounts"
)}
),
Dispatch(
{},
"X title",
TextEditBox,
{Set Text( "Minimum Distance Between Average Heights" )}
),
Dispatch( {}, "Y title", TextEditBox, {Set Text( "p value" )} ),
Dispatch(
{},
"Graph Builder",
FrameBox,
{Add Line Annotation(
Line( {233, 222}, {277, 286} ),
Color( "Magenta" ),
Thick( 1 ),
Point to( 1 )
), Add Text Annotation(
Text(
"6% chance that females are not 1 or more inches shorter than males"
),
Fixed Size( 0 ),
Text Box( {43, 175, 332, 237} ),
Filled( 0 ),
Text Color( "Medium Dark Magenta" ),
"Font"("Segoe UI", 12, "Bold")
), Add Text Annotation(
Text(
"34% likelihood that females are not 2.5 or more inches shorter than males"
),
Fixed Size( 0 ),
Text Box( {142, 101, 454, 163} ),
Filled( 0 ),
Text Color( "Medium Dark Magenta" ),
Background Color( "White" ),
"Font"("Segoe UI", 12, "Bold")
), Add Line Annotation(
Line( {353, 149}, {409, 203} ),
Color( "Magenta" ),
Thick( 1 ),
Point to( 1 )
), Add Text Annotation(
Text(
"Highly unlikely that females are
6 or more inches shorter than males"
),
Fixed Size( 0 ),
Text Box( {537, 98, 826, 152} ),
Filled( 0 )
), Add Line Annotation(
Line( {678, 93}, {711, 27} ),
Color( "Magenta" ),
Thick( 1 ),
Point to( 1 )
)}
)
)
);
Names default to here(1);
dt = Open("$Sample_data/Big Class.jmp");
// Column to adjust the difference in means between levels
nc = dt << New Column("height differenced", Numeric, "Continuous", Format("Best", 12), Formula(Parameter({b0 = 5}, If(:sex == "F", :height + b0, :height))));
distances = index(-2,7,incr=.5);
pvalless = {};
pvalmore = {};
for(d=1, d<= n items(distances), d++,
dist = distances[d];
Eval( Eval Expr( nc << Set Formula( Parameter({b0 = expr( dist ) }, If(:sex == "F", :height + b0, :height))) ) );
ow = dt << Oneway(
Y( nc ),
X( :sex ),
Means( 1 ),
t Test( 1 ),
Mean Diamonds( 1 ),
SendToReport( Dispatch( {}, "t Test", OutlineBox, {Close( 1 )} ) )
);
//Extract the prob
pvalless[d] = ((ow << XPath("//OutlineBox[text()='Pooled t Test']"))[1][NumberColBox(4)] << get as matrix)[2];
pvalmore[d] = ((ow << XPath("//OutlineBox[text()='Pooled t Test']"))[1][NumberColBox(4)] << get as matrix)[3];
ow << close window;
);
dtSum = New Table( "Results",
Add Rows( n items(distances) ),
New Column( "Distance",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( distances )
),
New Column( "pvalueless",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( pvalless )
),
New Column( "pvaluemore",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( pvalmore )
)
);
gb = dtSum << Graph Builder(
Size( 876, 379 ),
Show Control Panel( 0 ),
Variables( X( :Distance ), Y( :pvalueless ) ),
Elements( Points( X, Y, Legend( 3 ) ), Line( X, Y, Legend( 5 ) ) ),
SendToReport(
Dispatch(
{},
"pvalueless",
ScaleBox,
{Add Ref Line( 0.05, "Solid", "Black", ".05", 1 )}
),
Dispatch(
{},
"400",
ScaleBox,
{Legend Model( 3, Base( -1, 0, 0, Item ID( "pvaluemore", 1 ) ) )}
),
Dispatch(
{},
"graph title",
TextEditBox,
{Set Text(
"Likelihood of average heights of females being shorter than males by different amounts"
)}
),
Dispatch(
{},
"X title",
TextEditBox,
{Set Text( "Minimum Distance Between Average Heights" )}
),
Dispatch( {}, "Y title", TextEditBox, {Set Text( "p value" )} ),
Dispatch(
{},
"Graph Builder",
FrameBox,
{Add Line Annotation(
Line( {233, 222}, {277, 286} ),
Color( "Magenta" ),
Thick( 1 ),
Point to( 1 )
), Add Text Annotation(
Text(
"6% chance that females are not 1 or more inches shorter than males"
),
Fixed Size( 0 ),
Text Box( {43, 175, 332, 237} ),
Filled( 0 ),
Text Color( "Medium Dark Magenta" ),
"Font"("Segoe UI", 12, "Bold")
), Add Text Annotation(
Text(
"34% likelihood that females are not 2.5 or more inches shorter than males"
),
Fixed Size( 0 ),
Text Box( {142, 101, 454, 163} ),
Filled( 0 ),
Text Color( "Medium Dark Magenta" ),
Background Color( "White" ),
"Font"("Segoe UI", 12, "Bold")
), Add Line Annotation(
Line( {353, 149}, {409, 203} ),
Color( "Magenta" ),
Thick( 1 ),
Point to( 1 )
), Add Text Annotation(
Text(
"Highly unlikely that females are
6 or more inches shorter than males"
),
Fixed Size( 0 ),
Text Box( {537, 98, 826, 152} ),
Filled( 0 )
), Add Line Annotation(
Line( {678, 93}, {711, 27} ),
Color( "Magenta" ),
Thick( 1 ),
Point to( 1 )
)}
)
)
);