I'm working on a script that loops through a list of Y responses and runs degradation (stability test) on each before outputting parts of the report to a combined data table. It consists of the following steps:
- Opens a dialog box where the user selects several "Y, response", the "Time", and the "label, system ID".
- For each "Y, response", the script loops through and runs a degradation stability test, outputs the "Model Comparisons" information into a report.
- Concatenates the reports into a master table.
I've included code to take the name of the y-column for each loop and add it as a new column to each report and then concatenate each report to a new master table. The individual reports and the 'combinedDataTable' both have the new column ("Source Y Column"); however, it does not populate the cells with the respective column name. The script runs fine and without errors. I've included a number of screenshots below. The problematic code is toward the end of the script.
// Initialize an empty data table to store combined results
combinedDataTable = New Table( "Combined Degradation Data" );
// Loop through each selected Y column and perform degradation analysis
For( i = 1, i <= N Items( YCols ), i++,
currentYCol = Column( dt, YCols[i] );
// Calculate the min and max values of the current Y column
minValue = Col Minimum( currentYCol );
maxValue = Col Maximum( currentYCol );
// Adjust the min and max values by 2%
adjustedMin = minValue * 0.98;
adjustedMax = maxValue * 1.02;
// Determine the increment value based on the highest value
If( maxValue < 5,
incValue = 0.25,
If( maxValue > 5 & maxValue < 15,
incValue = 0.25,
If( maxValue > 90,
incValue = 0.5,
incValue = (adjustedMax - adjustedMin) / 10
)
)
);
//Determine the X Scale Box Based on Number of Timepoints
maxTimepoint = Col Maximum( Column( dt, XCols[1] ) );
adjustedMaxTimepoint = maxTimepoint + 1;
// Perform Degradation Analysis
degReport = dt << Degradation(
Y( currentYCol ),
Time( Column( dt, XCols[1] ) ), // Assuming only one X column is selected
Label( Column( dt, BCols[1] ) ), // Assuming only one By column is selected
Application( "Stability Test" ),
Connect Data Markers( 0 ),
Show Fitted Lines( 1 ),
Show Spec Limits( 1 ),
Show Median Curves( 0 ),
Show Legend( 1 ),
No Tab List( 0 ),
Use Pooled MSE for Nonpoolable Model( 0 ),
Set Censoring Time( . ),
Show Residual Plot( 1 ),
Show Inverse Prediction Plot( 1 ),
Show Curve Interval( 1 ),
Inverse Prediction Interval( "Confidence Interval" ),
Inverse Prediction Alpha( 0.05 ),
Inverse Prediction Side( "Lower One Sided" ),
SendToReport(
Dispatch( {"Overlay"}, "1", ScaleBox, {Min( -1 ), Max( adjustedMaxTimepoint ), Inc( 6 ), Minor Ticks( 1 )} ),
Dispatch(
{"Overlay"},
"2",
ScaleBox,
{Format( "Fixed Dec", 12, 1 ), Min( adjustedMin ), Max( adjustedMax ), Inc( incValue ), Minor Ticks( 0 )}
)
)
);
// Extract the data from the specified location
extractedData = Report( degReport )["Degradation Data Analysis"]["Overlay"]["Stability Tests"][Table Box( 2 )] << Make Combined Data Table;
// Add a column to indicate the source Y column
currentYColName = Column( dt, YCols[i] ) << Get Name;
extractedData << New Column( "Source Y Column", Character, "Nominal", Set Values( Repeat( currentYColName, N Rows( extractedData ) ) ) );
// Combine the extracted data into the combined data table
combinedDataTable << Concatenate( extractedData, Append to first table( 1 ) );
// Close the individual report window
Close( Window( degReport ) );
);
// Show the combined data table
combinedDataTable << Show Window;
Notes:
Here is the output window from one of the degradation analyses. I'm extract the information in the red outline.
Here is the master output table that has both Y, responses but the 'Source Y Column' is not populated.