All,
I am looking to compute confidence intervals of some data . I am aware that it is possible to achieve this using the following:
// Gets me what I want
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Obj = dt << Distribution( Column( :Age, :Weight ) );
Obj << Confidence Interval(0.95);
// How to achieve using matrix
Mat = dt << Get As Matrix;
Obj = Distribution(Mat[0,1]) << Confidence Interval(0.95);
The above becomes especially difficult if I wanted to further do this by groups, let us assume if I had to group by age? Any guidance is appreciated
I wouldn't do matrix manipulation, I would do something like this,
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Obj = dt << Distribution( Column( :height, :weight ), by(:sex), "Invisible" );
Obj << Confidence Interval(0.95);
Report(Obj[1])["Confidence Intervals"][TableBox(1)] << make combined data table;
Obj << close window;
You can do matrix functions, but it would require finding all unique by groups (age or sex), then index the matrices. There is a matrix CDF function that might be of interest. The script below is an FYI and not recommended, but here are the formulas. The resulting matrix does not have the by groups or which variable. I recommend the method above.
Mat = dt << Get As Matrix;
//Obj = Distribution(Mat[0,1]) << Confidence Interval(0.95);
/* CDF function */
/* only one column at a time get weight*/
{Quant, CumProb} = CDF( Mat[0,3] );
mxb = V Mean(Mat);
msd = V Std(Mat);
mdf = V Sum( !IsMissing(Mat) ) -1;
xb_lci = mxb - msd:/sqrt(mdf+1) :* tquantile(0.975,mdf);
xb_uci = mxb + msd:/sqrt(mdf+1) :* tquantile(0.975,mdf);
sd_lci = msd :* sqrt( mdf :/ ChiSquareQuantile(0.975,mdf));
sd_uci = msd :* sqrt( mdf :/ ChiSquareQuantile(0.025, mdf));
show(Quant, CumProb, mxb[3], msd[3], xb_lci[3], xb_uci[3], sd_lci[3], sd_uci[3]);