JMP脚本生成建模后的累积值大家好
我是 JMP 新手,尝试编写一个脚本
我使用 JMP 18 标准进行递归分析。我使用的模型是对数线性 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 );
);
自动化和脚本回复: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;
回复: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;
回复: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();
@朱利安
回复:JMP脚本用于在建模后生成累积值你好,jthi
谢谢,这有效。我所有的代码都是用AI生成的。我上周开始用JMP写脚本。我自己几乎写不出一行代码。有没有什么地方可以学习JMP脚本?
谢谢。
回复:JMP脚本用于在建模后生成累积值使用 JMP 中的增强日志,了解 JMP 如何为您创建脚本的不同方法。此外,JMP 还提供脚本指南,您可以从 JMP 的“帮助”菜单直接访问“脚本索引”。JMP 社区也提供丰富的内容,例如JMP 脚本语言简介、 JMP 脚本编写者俱乐部和JSL 手册。