JMP 18.1.2 YとXの適合分析からR2乗値を抽出する「分析」>「Y を X でフィット」を実行しています。データ テーブルを開く以下のコードがありますが、テーブルに RSquare 値がありません。何が足りないのか、何かアイデアはありますか?
// Open Data Table
dt = Data Table( "Raw Data" );
// Run Fit Y by X Analysis with a By Variable
fitObj = dt << Fit Y by X( Y( :"Mean(VALUEABS)" ), X( :Mean ), By( :PARM_LABEL ) );
// Get the analysis report
rpt = fitObj << Get Report;
// Find all RSquare nodes in the report
rsquareNodes = rpt << Find All Matching Elements( "RSquare" );
Show( "Number of RSquare nodes found: " || Char( N Items( rsquareNodes ) ) );
// Initialize a list to store the by group and RSquare pairs
rsquareData = {};
// Loop over each RSquare node found
For( i = 1, i <= N Items( rsquareNodes ), i++,
{
// Extract the RSquare text and convert to numeric value
rsqText = rsquareNodes[i] << Get Text ; rsqVal = Num( rsqText ) ;
// Try to retrieve the by-group label.
parentObj = rsquareNodes[i] << Get Parent ; byLabel = "" ;
While( byLabel == "" & parentObj != {},
byLabel = parentObj << Get Text;
If( byLabel == "",
parentObj = parentObj << Get Parent
);
) ;
// Append the pair (by group label, RSquare value) to list.
Append( rsquareData, {byLabel, rsqVal} ) ; }
);
Show( rsquareData );
// Create a new data table to store the RSquare values by by-group.
rsqDT = New Table( "RSquare Values",
Add Columns(
Column( "By Group", Character, "Nominal" ),
Column( "RSquare", Numeric, "Continuous" )
)
);
// Populate the new data table with the extracted values
For( i = 1, i <= N Items( rsquareData ), i++,
{New Row( rsqDT ) ; rsqDT:("By Group")[Row()] = rsquareData[i][1] ; rsqDT:RSquare[
Row()] = rsquareData[i][2] ; }
);
// Display the new data table
Show( rsqDT );
(上記の JSL はプレーンテキスト表示から JMP JSL 表示形式に移行しました) txnelson
自動化とスクリプトRe: JMP 18.1.2 Y と X の適合分析から R2 乗値を抽出するどの RSquare をお探しですか? 通常は、JMP で手動で実行し、JMP が作成したスクリプトを使用します (またはワークフローを使用してそこからスクリプトを取得します)。この場合、次のようになります。
1. テーブルを開く
2. 分析を実行する

3. 必要に応じてレポート/分析に変更を加える(Iフィットライン)

4. テーブルからデータテーブルを作成する

5. スクリプトを取得する
// Open Data Table: Big Class.jmp
// → Data Table("Big Class")
Open("$SAMPLE_DATA/Big Class.jmp");
// Combine similar TableBoxes into a Data Table
// → Data Table("Untitled")
Local({obj},
obj = Data Table("Big Class") << Bivariate(
Y(:height),
X(:weight),
Fit Line({Line Color({230, 159, 0})}),
By(:age)
);
Report(obj[1])["Linear Fit", "Summary of Fit", Table Box(1)] <<
Make Combined Data Table;
obj[1] << Close Window;
);
これを少し改良して、次のようなものにします。
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
biv = dt << Bivariate(
Y(:height),
X(:weight),
Fit Line({Line Color({230, 159, 0})}),
By(:age)
);
dt_result = Report(biv[1])["Linear Fit", "Summary of Fit", Table Box(1)] << Make Combined Data Table;
dt_result << Select Where(:Column 1 != "RSquare") << delete rows << clear select;Re: JMP 18.1.2 Y と X の適合分析から R2 乗値を抽出する構文に複数の問題がありました。以下は私がこの問題にどのように対処するかの例です。
// Open Data Table
dt = Data Table( "Raw Data" );
// Run Fit Y by X Analysis with a By Variable
fitObj = dt << Fit Y by X( Y( :"Mean(VALUEABS)" ), X( :Mean ), By( :PARM_LABEL ) );
dt=current data table();
fitObj = dt << Bivariate(
Y( :height ),
X( :weight ),
Fit Line( {Line Color( {212, 73, 88} )} ),
By( :sex )
);
nrpts = nitems(fitObj);
report(fitobj[1])[OutlineBox(1)] << get title
// Find all RSquare nodes in the report
Show( "Number of RSquare nodes found: " || Char( nrpts ) );
rsquareData = {};
// Initialize a list to store the by group and RSquare pairs
For Each( {obj}, fitObj,
r2=report(obj);
rsq = (r2["Linear Fit","Summary of Fit",numbercolbox(1)]<<GET></GET>Re: JMP 18.1.2 Y と X の適合分析から R2 乗値を抽出する初期のコードは明らかに AI によって生成されたように見えるため、構文に多くの間違いがあることがわかります。
Re: JMP 18.1.2 Y と X の適合分析から R2 乗値を抽出する返信ありがとうございます。RSquare 値を探しています。Fit Y By X 分析を実行し、ログからコードを取得しました。その後、フィット ラインを追加しましたが、そのアクションはログに記録されませんでした。しばらく経っていたので、右クリックしてデータ テーブルにする機能を忘れていました。その点についてお教えいただき、ありがとうございます。
Re: JMP 18.1.2 Y と X の適合分析から R2 乗値を抽出するジムさん、この解決策をありがとう。本当に感謝しています。
Re: JMP 18.1.2 Y と X の適合分析から R2 乗値を抽出するまさにその通りです! 前にも述べたように、右クリックの [データ テーブルにする] オプションを忘れていたので、ChatGPT に頼りました。