Todos,
Estoy buscando para calcular los intervalos de confianza de algunos datos. Soy consciente de que es posible lograr esto usando lo siguiente:
// 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);
Lo anterior se vuelve especialmente difícil si quisiera hacer esto en grupos, supongamos que tengo que agrupar por edad. Cualquier orientación es apreciada.
No haría manipulación de matrices, haría algo como esto,
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;
Puede realizar funciones de matriz, pero requeriría encontrar todas las únicas por grupos (edad o sexo) y luego indexar las matrices. Hay una función CDF de matriz que puede ser de interés. El siguiente script es un FYI y no se recomienda, pero aquí están las fórmulas. La matriz resultante no tiene la por grupos o qué variable. Recomiendo el método anterior.
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]);