cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Learn some foundational elements of JMP Scripting Language (JSL) and how to extend point & click automation into repeatable, shareable routines. Register. June 26, 2 p.m. US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Caozheng0115
Level III

JSL coding

Dear JMP community
I wrote a code the loop through all Site values (29 total) to extract  fail probability and part_actions (Estimate Probability( 1 ), Estimate Quantile( 1 )) to one table. It is calculating fail probability and part_actions at 0.15 percent fail from a Weibull analysis.  Following is the code. It keeps failing. Could you help me debug?

Names Default To Here( 1 );

dt = Data Table( "WeiBull Random Sampling_062606backup2" );

siteSummary = dt << Summary( Group( :Site ), N Rows( 1 ), Freq( "None" ) );
siteList = Column( siteSummary, 1 ) << get values;
Close( siteSummary, NoSave );

obj = dt << Life Distribution(
    Perspective( Compare Groups ),
    Y( :part_action ),
    Grouping( :R_ind ),
    Censor( :follow_censor ),
    Censor Code( 0 ),
    Label( :BOT ID ),
    Confidence Interval Method( Wald ),
    Interval Type( Pointwise ),
    Fit Distribution( "Weibull" ),
    Select Distribution( Distribution, Weibull ),
    Select Scale( Nonparametric ),
    Tabbed Report( 0 ),
    Show Quantile Functions( 1 ),
    Select Distribution( Quantile, Weibull ),
    Estimate Probability( 1 ),
    Estimate Probability( Compute( [150000] ) ),
    Estimate Quantile( 1 ),
    Estimate Quantile( Compute( [0.15] ) ),
    SendToEmbeddedScriptable(
        Dispatch( {"Individual Group", "Life Distribution R_ind=no"},
            {Y( :part_action ), Censor( :follow_censor ), Censor Code( 0 ),
            Label( :BOT ID ), <<Fit Weibull, Confidence Interval Method( Wald ),
            Interval Type( Pointwise ), Show Event Plot Frequency Label( 0 )}
        ),
        Dispatch( {"Individual Group", "Life Distribution R_ind=yes"},
            {Y( :part_action ), Censor( :follow_censor ), Censor Code( 0 ),
            Label( :BOT ID ), <<Fit Weibull, Confidence Interval Method( Wald ),
            Interval Type( Pointwise ), Show Event Plot Frequency Label( 0 )}
        )
    ),
    By( :Site ),
    SendToReport(
        Dispatch(
            {"Individual Group", "Life Distribution R_ind=no",
            "Compare Distributions"}, "Distribution Profiler", OutlineBox,
            {Set Summary Behavior( "Collapse" )}
        ),
        Dispatch(
            {"Individual Group", "Life Distribution R_ind=yes",
            "Compare Distributions"}, "Distribution Profiler", OutlineBox,
            {Set Summary Behavior( "Collapse" )}
        )
    )
);

Wait( 1 );

Show( "Sites: ", siteList );
Show( "N obj: ", N Items( obj ) );  // should equal N Items( siteList )

out = Empty();

For( i = 1, i <= N Items( obj ), i++,
    site = Char( siteList[i] );

    tmp = Report( obj[i] )["Compare Quantile", "Estimate Quantile - Weibull",
        Table Box( 2 )] << Make Into Data Table( invisible );

    tmp << New Column( "Site", Character, "Nominal" );
    For( r = 1, r <= N Row( tmp ), r++,
        Column( tmp, "Site" )[r] = site
    );

    If( Is Empty( out ),
        out = tmp;
    ,
        out << Concatenate( tmp, Append to First Table );
        Close( tmp, NoSave );
    );

    Show( "OK: " || site );
);

For( i = 1, i <= N Items( obj ), i++,
    obj[i] << Close Window;
);

Show( out );
3 REPLIES 3
Caozheng0115
Level III

Re: JSL coding

The error is as following

Caozheng0115_0-1782335744232.png

 

txnelson
Super User

Re: JSL coding

You can keep the line

obj[i] << Close Window;

from aborting the run by placing it in a Try() function.

try(obj[i] << Close Window);
Jim
jthi
Super User

Re: JSL coding

Have you tried using Make Combined Data table instead of Make into data table? You could combine it with Group Options(Return Group(1)) within the platform launch to get a single object back instead of a list.

Here is example using Bivariate and getting the results from table box under Fit Mean

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

obj = dt << Bivariate(
	Y(:weight),
	X(:height),
	Fit Mean({Line Color({230, 159, 0})}),
	By(:age),
	SendToReport(Dispatch({}, "Fit Mean ", OutlineBox, {Close(0)})),
	Group Options(Return Group(1))
);

res = Report(obj)[OutlineBox("Fit Mean "), Table Box(1)] << Make Combined Data Table;
obj << Close Window;

 

-Jarmo

Recommended Articles