Script JMP para generar valor acumulativo después del modeladoHola a todos
Soy nuevo en JMP y traté de escribir un script.
Uso el estándar JMP 18 y realizo análisis de recurrencia. El modelo que utilizo es el NHPP loglineal. Quiero generar un valor acumulado específico en 100 000, 200 000, 300 000, 400 000 y 500 000 transacciones. Veo que hay una opción de clic en la interfaz de usuario para cada transacción (mostrada en el archivo adjunto). Pero quiero automatizar esto mediante scripts. El siguiente es el script que probé: genera un error en la figura. ¿Podrían ayudarme con el código?


// 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 );
);
Automatización y scriptingRe: Script JMP para generar valor acumulativo después del modeladoLo más probable es que desees incluir el cuadro de tabla dentro del subíndice de tu informe en lugar de enviarle un mensaje.
estimates_table = rec_report["Loglinear NHPP Report", "Estimates", Table Box(1)]
También creo que sus "Estimaciones" deberían ser "Estimaciones de Parámetros" (o usar el comodín ?). Aquí hay un ejemplo hasta ese punto usando los datos de muestra de 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: Script JMP para generar valor acumulativo después del modeladoHola, aquí tienes.
Ya funciona. Muchas gracias.
No debería intentar crear mi propio formulario. Después de ejecutar el modelo en JMP, aparece "Intensidad específica y acumulada" en "Modelo de recurrencia ajustado". Este puede generar el valor acumulado con un intervalo de confianza. Puedo usar el formulario en lugar de crear uno nuevo. Intenté que el formulario generara nuevos resultados en una tabla, pero no lo logré. ¿Podrían ayudarme? El error está en la imagen. Gracias de nuevo.

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: Script JMP para generar valor acumulativo después del modeladoTu script se parece mucho a uno generado por IA... Ten en cuenta que estos no están documentados en el Índice de scripts (<< Guardar fórmula de intensidad y << Guardar fórmula acumulativa) pero puedes "averiguarlo" haciendo ajustes.
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();
@juliano
Re: Script JMP para generar valor acumulativo después del modeladoHola, jthi
Gracias, esto funciona. Todo mi código lo genera IA. Empecé a programar en JMP la semana pasada. Apenas puedo escribir una sola línea de código. ¿Hay algún sitio donde pueda aprender a programar en JMP?
Gracias.
Re: Script JMP para generar valor acumulativo después del modeladoUtilice el inicio de sesión mejorado en JMP y aprenda los diferentes métodos con los que JMP puede crear algunos scripts. También dispone de la Guía de Scripting , acceso directo al Índice de Scripting desde el menú Ayuda de JMP y la Comunidad JMP ofrece una amplia gama de contenido, como Introducción al Lenguaje de Scripting JMP , Club de Scripters de JMP y Libro de Recetas JSL .