Hier ist ein Ansatz:
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 );
Hallo ... ich frage mich, ob jemand die folgende Diskrepanz mit der Anzahl der Elemente in einem Bericht erklären kann. Ich habe den folgenden Code, der versucht, den Achsenabschnitt und die Steigung aus einer linearen Anpassung zu extrahieren, die auf eine Y-durch-X-Plattform angepasst wurde. Das Problem, das ich sehe, ist, wenn die: group-Spalte nur ein Element enthält, dann die numplots = 2, und ich erhalte einen Fehler beim Versuch, den Schnittpunkt und die Steigung von rp [1] zu extrahieren. Ich muss aus rp [2] extrahieren. Wenn die Anzahl der Elemente in der Spalte: group = 2 oder höher ist, dann ist numplots = die Anzahl der Elemente in der Spalte group, und ich kann Intercept und Slope aus rp [1] extrahieren. Am Ende möchte ich in der Lage sein, alle Abschnitte und Steigungen für x Gruppen zu extrahieren, wobei x zwischen 1 und beliebig liegen kann, aber dieses "Feature" macht das Codieren etwas langwieriger, da ich # groups = behandeln muss 1 anders als # 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];
Vielen Dank
Wenn Sie in einem Plattformaufruf ein By () verwenden, wenn es mehr als eine Gruppe gibt, wird eine Liste der Plattformen angezeigt.
Folgendes berücksichtigen:
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 );
Das Protokoll zeigt:
/*:
bivobj1 = {Bivariate[], Bivariate[]};
bivobj2 = Bivariate[];
Sie können also Ihre bivObj-Variable überprüfen, um festzustellen, ob es sich um eine Liste handelt, und entsprechend vorgehen. Zum Beispiel:
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];
);