Aquí hay un enfoque:
Names Default to Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Summarize( g = By( :sex ) );
If( N Items( g ) < 2,
biv obj = dt << Bivariate( Y( :weight ), X( :height ), Fit Line );
biv rep = biv obj << Report;
reg est = biv rep["Parameter Estimates"][NumberColBox(1)] << Get As Matrix,
// need By variable
biv obj = dt << Bivariate( Y( :weight ), X( :height ), By( :sex ), Fit Line );
biv rep = biv obj << Report;
reg est = [];
For( by = 1, by <= N Items( g ), by++,
reg est ||= (biv rep[by])["Parameter Estimates"][NumberColBox(1)] << Get As Matrix;
);
);
Show( reg est );
Hola ... me pregunto si alguien puede explicar la siguiente discrepancia con la cantidad de elementos en un informe. Tengo el siguiente código que intenta extraer la intersección y la pendiente de un ajuste lineal que se ha aplicado a una plataforma Fit Y by X. El problema que veo es si la columna: grupo contiene solo un elemento y luego las parcelas numéricas = 2, y aparece un error al intentar extraer la intersección y la pendiente de rp [1]. Tengo que extraer de rp [2]. Si el número de elementos en la columna: grupo = 2 o más alto, entonces los gráficos numéricos = el número de elementos en la columna del grupo y puedo extraer el intercepto y la pendiente de rp [1]. Al final, quiero poder extraer todas las intercepciones y pendientes para x número de grupos donde x puede ser de 1 a lo que sea, pero esta "característica" hace que la codificación sea un poco más larga porque tengo que tratar # groups = 1 diferente a # goups> = 2.
Clear Globals();
dt = Current Data Table();
bivObj = dt << Bivariate(
Y(:this),
X(:that),
Fit Line,
By(:group),
);
rp = bivObj << Report;
numPlots = nItems(rp1);
intercept = rp[1][OutlineBox("Parameter Estimates")][Columnbox("Estimate")][1];
slope = rp[1][OutlineBox("Parameter Estimates")][Columnbox("Estimate")][1];
Gracias
Cuando use un By () en una llamada de plataforma si hay más de un grupo, el resultado será una lista de las plataformas.
Considera lo siguiente:
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt <<
New Column( "Constant",
character,
formula( "a" )
);
bivObj1 = dt <<
Bivariate(
Y( :height ),
X( :weight ),
Fit Line,
By( :sex ),
);
bivObj2 = dt <<
Bivariate(
Y( :height ),
X( :weight ),
Fit Line,
By( :constant ),
);
Show( bivobj1, bivobj2 );
El registro mostrará:
/*:
bivobj1 = {Bivariate[], Bivariate[]};
bivobj2 = Bivariate[];
Por lo tanto, puede verificar su variable bivObj para ver si es una lista y actuar en consecuencia. Por ejemplo:
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt << New Column( "Constant", character, formula( "a" ) );
bivObj1 = dt << Bivariate(
Y( :height ),
X( :weight ),
Fit Line,
By( :sex ),
);
bivObj2 = dt << Bivariate(
Y( :height ),
X( :weight ),
Fit Line,
By( :constant ),
);
Show( bivobj1, bivobj2 );
If( Is List( bivobj1 ),
//bivobj1 is a list of platform references
For( i = 1, i <= N Items( bivobj1 ), i++,
rp = bivObj1[i] << Report;
intercept = rp[Outline Box( "Parameter Estimates" )][Columnbox( "Estimate" )][1];
slope = rp[Outline Box( "Parameter Estimates" )][Columnbox( "Estimate" )][1];
Show( intercept, slope );
)
,
//bivobj1 is not a list, it's a single platform reference
rp = bivObj1 << Report;
intercept = rp[Outline Box( "Parameter Estimates" )][Columnbox( "Estimate" )][1];
slope = rp[Outline Box( "Parameter Estimates" )][Columnbox( "Estimate" )][1];
);