Script JMP per generare valore cumulativo dopo la modellazioneCiao a tutti
Sono nuovo di JMP e ho provato a scrivere uno script
Utilizzo lo standard JMP 18 ed eseguo l'analisi di ricorrenza. Il modello che utilizzo è NHPP loglineare. Voglio generare un valore cumulativo specifico per 100.000, 200.000, 300.000, 400.000 e 500.000 transazioni. Vedo che c'è un'opzione di clic nell'interfaccia utente per ogni transazione (mostrata nell'allegato). Ma voglio automatizzare questo processo utilizzando degli script. Di seguito è riportato lo script che ho provato: Genera un errore nella figura. C'è un errore? Potresti aiutarmi con il codice?


// 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 );
);
Automazione e scriptingRe: Script JMP per generare un valore cumulativo dopo la modellazioneMolto probabilmente desideri includere Table Box all'interno dell'indice del tuo report invece di inviargli un messaggio
estimates_table = rec_report["Loglinear NHPP Report", "Estimates", Table Box(1)]
Inoltre, penso che le tue "Stime" dovrebbero essere "Stime dei parametri" (o usare il carattere jolly ?). Ecco un esempio fino a quel punto, utilizzando i dati campione di 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 per generare valore cumulativo dopo la modellazioneCiao, ecco qua.
Ora funziona. Grazie mille.
Non dovrei provare a creare una mia formula. C'è "Intensità specifica e cumulativa" in "Modello di ricorrenza adattato" dopo aver eseguito il modello in JMP. Può generare il valore cumulativo con intervallo di confidenza. Posso semplicemente usare la formula invece di crearne una nuova. Ho provato a far sì che la formula generasse nuovi risultati in una tabella. Ma non ci sono riuscito. Potresti aiutarmi? L'errore è nell'immagine. Grazie ancora.

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 per generare un valore cumulativo dopo la modellazioneIl tuo script sembra molto simile a quello generato dall'intelligenza artificiale... Nota che questi non sono documentati nell'indice di scripting (<< Salva formula di intensità e << Salva formula cumulativa) ma puoi "capirlo" armeggiando un po'
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();
@julian
Re: Script JMP per generare valore cumulativo dopo la modellazioneCiao, jthi
Grazie, funziona. Tutto il mio codice è generato dall'intelligenza artificiale. Ho iniziato a scrivere script in JMP la settimana scorsa. Riesco a malapena a scrivere una sola riga di codice da solo. C'è un posto dove posso imparare a scrivere script in JMP?
Grazie.
Re: Script JMP per generare valore cumulativo dopo la modellazioneUtilizza l'accesso avanzato in JMP e scopri i diversi metodi con cui JMP è in grado di creare alcuni script per te. È disponibile anche la Guida agli script , a cui puoi accedere direttamente dal menu Aiuto di JMP. La Community di JMP offre numerosi contenuti, come Introduzione al linguaggio di scripting JMP , Club degli scripter JMP e Ricettario JSL .