I am trying to do some Survival analysis, where I am combining some analysis into one script. So what I am trying to do, is they enter the columns into the Survival Platform, then I take those columns and use them in the Proportional Hazards Platform. My script works great except for the Y, response, it will not find the Y response variable. If I change Y( As Column( Ycolname ) ), to something like Y("Time to Failure"), it works great. But when I try to use the variable, it does not work.
I have two questions - why does my method work for Censor and the Xs, but not the Ys.
Second question, if they do not enter a by or frequency column, how do I tell the fit model that there is not a column to enter. If I use As Column (variable) it says it cannot find my column, which is right.
Names Default To Here( 1 );
Clear Log();
dt = Current Data Table();
If( Not( Is Scriptable( dt ) ),
dtsel = Pick File( "Open File", {"JMP|jmp", "All files|*"} );
If( dtsel == "",
Stop(),
Try( dt = Open( dtsel ), Stop() )
);
);
dtname = Data Table( dt ) << Get Name;
validated = 0;
New Window( "Survival/Reliability",
<<Modal,
<<On Validate(
survival = {};
Insert Into( survival, Substitute( olb[List Box Box( 2 )] << Get Items, {}, Expr( Y() ) ) );
Insert Into( survival, Substitute( olb[List Box Box( 3 )] << Get Items, {}, Expr( Grouping() ) ) );
Insert Into( survival, Substitute( olb[List Box Box( 4 )] << Get Items, {}, Expr( Censor() ) ) );
Insert Into( survival, Substitute( olb[List Box Box( 5 )] << Get Items, {}, Expr( Freq() ) ) );
Insert Into( survival, Substitute( olb[List Box Box( 6 )] << Get Items, {}, Expr( By() ) ) );
Insert Into( survival, Insert( Expr( Censor Code() ), olb[Number Edit Box( 1 )] << Get ) );
Insert Into(
survival,
Insert( Expr( Plot failure instead of Survival() ), olb[Check Box Box( 1 )] << Get )
);
survival expr = Expr( Send( dt ) );
Insert Into( survival expr, Substitute( survival, {}, Expr( Survival() ) ) );
obj = survival expr;
obj << Save Estimates;
validated = 1;
),
olb = Outline Box( "",
dt << Survival(
Failure Plot( 1 ),
Show Points( 1 ),
Show Shaded Simultaneous CI( 1 ),
Show Simultaneous CI( 1 ),
Weibull Plot( 1 ),
Weibull Fit( 1 )
)
)
);
If( !validated, Stop() );
Eval(PH);
dt2 = Data Table( dtname || " Survival" );
columnnamegroup = Column( dt2, 1 ) << Get Name;
GroupID = Associative Array( Column( dt2, 1 ) ) << Get Keys;
Show( GroupID );
n = N Items( GroupID );
Show( n );
Current Data Table( dt2 );
dt2 << select where( As Column( columnnamegroup ) == "Combined" );
dt2 << hide and exclude;
dt2 << Clear Select;
Graph Builder(
Variables( X( :"log(Time)"n ), Y( :"log(-log(Surv))"n ), Overlay( As Column( columnnamegroup ) ) ),
Elements( Points( X, Y, Legend( 17 ) ), Line Of Fit( X, Y, Legend( 18 ) ) ),
SendToReport(
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
17,
Base( 0, 0, 0, Item ID( "Op1", 1 ) ),
Base( 1, 0, 0, Item ID( "Op2", 1 ) ),
Base( 2, 0, 0, Item ID( "Op3", 1 ) )
)}
)
)
);
PH = Expr(
Ycolname = Arg( survival[1], 1 );
Effectname = Arg( survival[2], 1 );
Censorname = Arg( survival[3], 1 );
Freqname = Arg( survival[4], 1 );
Byname = Arg( survival[5], 1 );
CensorCodename = Arg( survival[6], 1 );
Show( Ycolname );
Current Data Table( dt );
dt << Fit Model(
// Freq(),
// By(),
Y( As Column( Ycolname ) ),
Censor( As Column( Censorname ) ),
Effects( As Column( Effectname ) ),
Personality( "Proportional Hazard" ),
Censor Code( "1" ),
Run Model( Likelihood Ratio Tests( 1 ), Likelihood Confidence Intervals( 1 ), Risk Ratios( 1 ) )
);
);