モデリング後に累積値を生成するJMPスクリプトこんにちは、みんな
私はJMPを初めて使い、スクリプトを書こうとしました
JMP 18 Standardを使用して、回帰分析を行っています。モデルは対数線型NHPPです。10万、20万、30万、40万、50万のトランザクションごとに特定の累積値を生成したいと考えています。各トランザクションのUIにはクリックオプションがあります(添付ファイルを参照)。しかし、スクリプトを使ってこれを自動化したいと思っています。試したスクリプトは以下のとおりです。図にエラーが発生します。コードについてご教示いただけますか?


// Run the analysis and capture the report
rec_report = Recurrence Analysis(
Y( :Accumulated Transactions ),
Label( :BOT ID ),
Cost( :SAP Purchase Price ),
Grouping( :Bot Series ),
Event Plot( 0 ),
MCF Confid Limits( 1 ),
Fit Model(
Scale Effects( :Bot Series ),
Shape Effects( :Bot Series ),
Run Model,
Model Type( "Loglinear Nonhomogeneous Poisson Process" )
)
);
// --- Extract Estimates ---
// Get the "Estimates" table directly from the report and convert it to a scriptable object
estimates_table = rec_report["Loglinear NHPP Report", "Estimates"] << Table Box;
// Get the 'Estimate' column values as a list.
// The order is consistently Lambda, then Beta.
estimates_list = estimates_table << Get Values( "Estimate" );
// Assign the parameter estimates from the list
lambda_hat = estimates_list[1]; // Lambda (λ) is the first estimate
beta_hat = estimates_list[2]; // Beta (β) is the second estimate
// Define the transactions for which to calculate values
transactions = {100000, 200000, 300000, 400000, 500000};
// Calculate and display intensity and cumulative values
For( i = 1, i <= N Items( transactions ), i++,
transaction_time = transactions[i];
// Cumulative Mean Function C(t) = λ * t^β
cumulative = lambda_hat * (transaction_time ^ beta_hat);
// Instantaneous Intensity λ(t) = λ * β * t^(β-1)
intensity = lambda_hat * beta_hat * (transaction_time ^ (beta_hat - 1));
// Print the results to the log
Show( transaction_time, cumulative, intensity );
);
自動化とスクリプトRe: モデリング後に累積値を生成するJMPスクリプトおそらく、レポートのサブスクリプトにメッセージを送信するのではなく、テーブルボックスを含めることを望んでいるでしょう。
estimates_table = rec_report["Loglinear NHPP Report", "Estimates", Table Box(1)]
また、「推定値」は「パラメータ推定値」(またはワイルドカード「?」)にすべきだと思います。JMPのサンプルデータを使用した、その点までの例を以下に示します。
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Reliability/Bladder Cancer.jmp");
ra = dt << Recurrence Analysis(
Y(:Age),
Label(:Patient Number),
Cost(:Cost),
Grouping(:Treatment Group),
Event Plot(1),
Fit Model(
Scale Effects(:Intensity),
Shape Effects(:Intensity),
Run Model,
Model Type("Power Nonhomogeneous Poisson Process")
)
);
tb = Report(ra)[OutlineBox("Fitted Recurrence Model"), OutlineBox("Parameter Estimates"), TableBox(1)];
estimates = tb[NumberColBox("Estimate")] << get;
Re: モデリング後に累積値を生成するJMPスクリプトこんにちは、どうぞ。
動作するようになりました。ありがとうございます。
自分で数式を作るのはやめましょう。JMPでモデルを実行すると、「当てはめた回帰モデル」の下に「比強度と累積」という項目があります。これで信頼区間付きの累積値を生成できます。新しい数式を作る代わりに、既存の数式を使うことができます。この数式を使って表に新しい結果を生成しようとしたのですが、うまくいきませんでした。何か助けていただけないでしょうか?エラーは画像にあります。改めて感謝いたします。

Names Default To Here( 1 );
// --- Run the analysis ---
rec_report = Recurrence Analysis(
Y( :Accumulated Transactions ),
Label( :BOT ID ),
Cost( :SAP Purchase Price ),
Grouping( :Bot Series ),
Event Plot( 0 ),
MCF Confid Limits( 1 ),
Fit Model(
Scale Effects( :Bot Series ),
Shape Effects( :Bot Series ),
Run Model,
Model Type( "Loglinear Nonhomogeneous Poisson Process" )
)
);
// --- Save JMP’s own formulas into the source table ---
rec_report << Save Intensity Formula;
rec_report << Save Cumulative Formula;
// Grab those formulas so we can reuse them in a clean table
dt_src=Current Data Table();
intensity_formula = Column( dt_src, "Intensity" ) << Get Formula;
cumulative_formula = Column( dt_src, "Cumulative" ) << Get Formula;
// --- Define the transaction times you care about ---
transactions = {100000, 200000, 300000, 400000, 500000};
// --- Build a results table with JMP-calculated fitted values ---
dt_sic = New Table( "Specific Intensity and Cumulative",
New Column( "Accumulated Transactions", Numeric, "Continuous", Values( transactions ) ),
New Column( "Intensity", Numeric, Formula( intensity_formula ) ),
New Column( "Cumulative", Numeric, Formula( cumulative_formula ) )
);
// Evaluate formulas and show the table
dt_sic << Recalculate;
dt_sic << Bring Window To Front;
Re: モデリング後に累積値を生成するJMPスクリプトあなたのスクリプトはAIによって生成されたように見えます...これらはスクリプトインデックス(<< 強度式を保存、<< 累積式を保存)には記載されていませんが、いじくり回すことで「理解」できます。
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Reliability/Bladder Cancer.jmp");
ra = dt << Recurrence Analysis(
Y(:Age),
Label(:Patient Number),
Cost(:Cost),
Grouping(:Treatment Group),
Event Plot(1),
Fit Model(
Scale Effects(:Age),
Run Model,
Model Type("Proportional Intensity Poisson Process")
)
);
fit = Report(ra)[OutlineBox("Fitted Recurrence Model")] << Get Scriptable Object;
intensity_col = fit << Save Intensity Formula;
cumul_col = fit << Save Cumulative Formula;
i_f = intensity_col << Get Formula;
c_f = cumul_col << Get Formula;
transactions = {1, 2, 3, 4, 5};
dt_s = New Table("Specific Intensity and Cumulative",
New Column("Age", Numeric, "Continuous", Values(transactions))
);
Eval(Eval Expr(
dt_s << New Column("Intensity", Numeric, Continuous, Formula(
Expr(NameExpr(i_f))
));
));
Eval(Eval Expr(
dt_s << New Column("Cumulative", Numeric, Continuous, Formula(
Expr(NameExpr(c_f))
));
));
Write();
@ジュリアン
Re: モデリング後に累積値を生成するJMPスクリプトこんにちは、jthi
ありがとうございます、うまくいきました。私のコードはすべてAIによって生成されています。先週からJMPでスクリプトを書き始めましたが、自分では1行もコードを書くことができません。JMPスクリプトを学べる場所はありますか?
ありがとう。
Re: モデリング後に累積値を生成するJMPスクリプトJMPの拡張ログイン機能を使って、JMPがスクリプトを作成する様々な方法を学びましょう。また、 スクリプトガイドも用意されており、JMPのヘルプメニューからスクリプトインデックスに直接アクセスできます。JMPコミュニティには、 JMPスクリプト言語入門、 JMPスクリプターズクラブ、 JSLクックブックなど、多くのコンテンツがあります。