I'm making progress! My main objective is to get a Effect Wald Test data table after every column switch. Eventually I will concatenate these tables. The code below automatically starts the column switcher (this can be seen in the log) and does produce the Effect Wald Test data table but only for the first entry in the column switcher. Any ideas on how to get the Effect Wald Test data table from each column when it switches?
obj = dt << Fit Model(
Y( :dthtt ),
Effects(
:race1c, :PC1, :PC2, :PC3, :age2c, :gender1, :bmi2c.x, :chol2.x, :curalc2.x, :pkyrs2c.x, :dbp2c.x,
:sbp2c.x, :creatin1.x, :glucos2c.x, :APOE_INT, :One_5_Anhydroglucitol_INT,
:APOE_INT * :One_5_Anhydroglucitol_INT
),
Personality( "Proportional Hazard" ),
Censor( :dth ),
Censor Code( "0" ),
Run(
:dthtt << {Summary of Fit( 1 ), Analysis of Variance( 1 ), Parameter Estimates( 1 ),
Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ), Plot Effect Leverage( 1 ),
Plot Residual by Normal Quantiles( 0 ), Box Cox Y Transformation( 0 )}
)
);
ColumnSwitcher = obj << Column Switcher(
:One_5_Anhydroglucitol_INT,
{:One_5_Anhydroglucitol_INT, :Two_Deoxyuridine_INT, :Two_Hydroxybutyric acid_INT,
:Two_Hydroxyglutaric acid_INT, :Dummy variable_INT}
);
pre = Function( {currentColumn, nextColumn, switcher},
Print(
"Before switch: " || (currentColumn << get name) || " >> " || (nextColumn << get name) ||
" [Column Switcher] current: " || (columnSwitcher << Get Current)
);
If( nextColumn << get name == "Dummy variable_INT",
0,
1
);
);
post = Function( {previousColumn, currentColumn, switcher},
Print(
"After switch: " || (previousColumn << get name) || " >> " || (currentColumn << get name) ||
" [Column Switcher] current: " || (columnSwitcher << Get Current)
)
);
columnSwitcher << Make Column Switch Handler( pre, post );
ColumnSwitcher << Set Script(
obj = Data Table( "MESA 2018Events_Exam2Main_Proteomics_Metabolomics_MARCH 13 2023" ) <<
Fit Model(
Y( :dthtt ),
Effects(
:race1c, :PC1, :PC2, :PC3, :age2c, :gender1, :bmi2c.x, :chol2.x, :curalc2.x, :pkyrs2c.x, :dbp2c.x,
:sbp2c.x, :creatin1.x, :glucos2c.x, :APOE_INT, :One_5_anhydroglucitol_INT,
:APOE_INT * :One_5_anhydroglucitol_INT
),
Personality( "Proportional Hazard" ),
Censor( :dth ),
Censor Code( "0" ),
Run( Likelihood Ratio Tests( 0 ) ),
Column Switcher(
:One_5_anhydroglucitol_INT,
{:One_5_Anhydroglucitol_INT, :Two_Deoxyuridine_INT, :Two_Hydroxybutyric acid_INT,
:Two_Hydroxyglutaric acid_INT, :Dummy variable_INT}
)
);
Report( obj )["Effect Wald Tests", Table Box( 1 )] << Make Into Data Table;
obj << Close Window;
);
ColumnSwitcher << Run;
Wait( 5/*seconds, while it animates*/ );