Logistic
Example 1
Summary: Opens a data table, fits a logistic model to predict age based on weight, and visualizes the results using JMP's built-in Ternary Plot feature.
Code:
// Logistic
// Open data table
dt = Open("data_table.jmp");
// Logistic
Logistic( Y( :age ), X( :weight ) );
Code Explanation:
- Open data table.
- Fit logistic model.
Example 2
Summary: Opens a data table, fits a logistic regression model, and performs inverse prediction to visualize the relationship between response and dose.
Code:
// Logistic
// Open data table
dt = Open("data_table.jmp");
// Logistic
Logistic(
Y( response ),
X( dose ),
Inverse Prediction( Response( 0.5 ) )
);
Code Explanation:
- Open data table.
- Fit logistic regression.
- Perform inverse prediction.
Example 3
Summary: Visualizes a logistic model using the specified variables, including response and predictor variables, and performs inverse prediction with a set response value.
Code:
// Logistic
// Open data table
dt = Open("data_table.jmp");
// Logistic
Logistic(
Y( Response ),
X( Temperature ),
Inverse Prediction(
Response( 0.00063 )
)
);
Code Explanation:
- Open table.
- Fit logistic model.
- Specify response variable.
- Specify predictor variable.
- Perform inverse prediction.
- Set response value for prediction.
Example 4
Summary: Visualizes a logistic regression analysis using the specified variables, opening a data table and fitting the model to predict the response variable based on the natural logarithm of dose.
Code:
// Logistic
// Open data table
dt = Open("data_table.jmp");
// Logistic
Logistic(
Y( Response ),
X( "ln(dose)"n ),
Freq( count )
);
Code Explanation:
- Open data table.
- Fit logistic regression.
Example 5
Summary: Opens a data table, fits a logistic regression model using the 'age' variable as the response and 'weight (lb.)' as the predictor, and visualizes the results.
Code:
// Logistic
// Open data table
dt = Open("data_table.jmp");
// Logistic
Logistic(
Y( :age ),
X( :"weight (lb.)"n )
);
Code Explanation:
- Open data table.
- Fit logistic regression model.
- Set response variable.
- Set predictor variable.
Example 6
Summary: Fits a logistic regression model to predict sex based on height, with customizable report scales and display of odds ratios, rate curve, ROC curve, and lift curve.
Code:
dt = Open("data_table.jmp");
Logistic(
Y( :sex ),
X( :height ),
Positive Level( "M" ),
Odds Ratios( 1 ),
Show Rate Curve( 1 ),
ROC Curve( 1 ),
Lift Curve( 1 ),
SendToReport(
Dispatch( {}, "1", ScaleBox, {Format( "Custom", Formula( In Minutes( value ) ), 12 )} ),
Dispatch( {}, "2", ScaleBox, {Format( "Custom", Formula( In Days( value ) ), 12 )} )
)
);
Code Explanation:
- Open data table;
- Fit logistic regression model.
- Set Y variable as "sex".
- Set X variable as "height".
- Define positive level as "M".
- Enable odds ratios display.
- Show rate curve.
- Generate ROC curve.
- Create lift curve.
- Customize report scales.
Example 7
Summary: Fits a logistic regression model to predict Response based on ln(dose) and Count, using data from the Plasticizer 78.jmp table.
Code:
Names Default To Here( 1 );
dt = Open("data_table.jmp");
obj = Logistic( Y( :Response ), X( :Name( "ln(dose)" ) ), Freq( :Count ) );
Code Explanation:
- Set default names scope.
- Open data table;
- Fit logistic model.
Example 8
Summary: Runs a logistic regression analysis with ROC curve generation and report dispatching, utilizing the specified variables to test the model's performance.
Code:
dt under test = Open("data_table.jmp");
obj = Logistic(
Y( :Name( "Claim(Y/N)" ) ),
X( :Premium USD ),
Positive Level( "Y" ),
Logistic Plot( 0 ),
ROC Curve,
SendToReport(
Dispatch( {}, "Whole Model Test", OutlineBox, {Close( 1 )} ),
Dispatch( {}, "Parameter Estimates", OutlineBox, {Close( 1 )} ),
Dispatch( {"Parameter Estimates"}, "Covariance of Estimates", OutlineBox, {Close( 0 )} ),
Dispatch( {"Receiver Operating Characteristic"}, "ROC Table", OutlineBox,
{Set Title( "ROC Table - Testing, ROC table should have a message about truncation" )}
)
)
);
Code Explanation:
- Open data table;
- Define dt under test.
- Run logistic regression.
- Set Y variable to Claim(Y/N).
- Set X variable to Premium USD.
- Define positive level as "Y".
- Disable logistic plot.
- Generate ROC curve.
- Close Whole Model Test.
- Close Parameter Estimates.
Example 9
Summary: Creates a logistic regression model to predict response based on dose, utilizing inverse prediction and term value methods.
Code:
dt under test = Open("data_table.jmp");
obj = Logistic( Y( :response ), X( :dose ), Inverse Prediction( Response( 0.5 ), Term Value( dose( . ) ) ) );
Code Explanation:
- Open data table.
- Perform logistic regression.
- Set response variable.
- Set predictor variable.
- Enable inverse prediction.
- Specify response level.
- Use term value method.
- Set dose variable.
- Analyze data.
- Display results.
Example 10
Summary: Runs the logistic regression analysis and visualization of age based on weight, generating ROC, lift, and rate curves, as well as a report with customized title.
Code:
dt under test = Open("data_table.jmp");
obj = Logistic(
Y( :age ),
X( :weight ),
Logistic Plot( 0 ),
Show Rate Curve( 1 ),
ROC Curve,
Lift Curve,
SendToReport(
Dispatch( {}, "Logistic Fit of age By weight", OutlineBox, {Set Title( "ROC Curve, Lift Curve" )} ),
Dispatch( {}, "Whole Model Test", OutlineBox, {Close( 1 )} ),
Dispatch( {}, "Parameter Estimates", OutlineBox, {Close( 1 )} )
)
);
Code Explanation:
- Open data table;
- Fit logistic model.
- Predict age from weight.
- Plot logistic curve.
- Show rate curve.
- Generate ROC curve.
- Generate lift curve.
- Rename report title.
- Close whole model test.
- Close parameter estimates.
Example 11
Summary: Creates a logistic regression model to predict age based on weight, utilizing the Open function and Logistic platform in JMP.
Code:
dt under test = Open("data_table.jmp");
obj = Logistic( Y( :age ), X( :weight ) );
Code Explanation:
- Open data table;
- Create logistic object.
- Set response variable: age.
- Set predictor variable: weight.
Example 12
Summary: Runs a logistic regression analysis to model the relationship between dose and response, generating rate curves, ROC curves, lift curves, and performing inverse prediction.
Code:
Open("data_table.jmp");
Logistic(
Y( :Response ),
X( :Name( "ln(dose)" ) ),
Freq( :Count ),
Positive Level( "Cured" ),
Odds Ratios( 1 ),
Show Rate Curve( 1 ),
ROC Curve,
Lift Curve,
Inverse Prediction( Response( 0.6 ), Term Value( Name( "ln(dose)" )(.) ) ),
SendToReport(
Dispatch( {}, "Iterations", OutlineBox, {Close( 0 )} ),
Dispatch( {"Parameter Estimates"}, "Covariance of Estimates", OutlineBox, {Close( 0 )} ),
Dispatch( {"Receiver Operating Characteristic"}, "ROC Table", OutlineBox, {Close( 0 )} )
)
);
Code Explanation:
- Open data table;
- Fit logistic regression model.
- Set response variable.
- Set predictor variable.
- Specify frequency variable.
- Define positive level.
- Calculate odds ratios.
- Display rate curve.
- Generate ROC curve.
- Create lift curve.
- Perform inverse prediction.
- Close iterations report.
- Close covariance report.
- Close ROC table report.
Example 13
Summary: Creates a logistic regression model with automatic recalculation, odds ratios, and rate curve generation for sex prediction based on height, utilizing Local Data Filter for interactive filtering.
Code:
Open("data_table.jmp");
obj = Logistic(
Y( :sex ),
X( :height ),
Automatic Recalc( 1 ),
Positive Level( "M" ),
Odds Ratios( 1 ),
Show Rate Curve( 1 ),
ROC Curve,
Lift Curve,
);
obj << Local Data Filter(
Location( {748, 19} ),
Mode,
Add Filter( columns( :height ), Where( :height >= 51 & :height <= 60 ), Display( :height ) )
);
rpt = obj << Report;
actN = rpt[Number Col Box( 12 )] << Get( 1 );
Code Explanation:
- Open data table;
- Create logistic model object.
- Set response variable to sex.
- Set predictor variable to height.
- Enable automatic recalculation.
- Define positive level as "M".
- Include odds ratios in output.
- Show rate curve in report.
- Generate ROC curve.
- Generate lift curve.
Example 14
Summary: Fits a logistic regression model to predict sex based on height, with interactive filtering and reporting capabilities.
Code:
dt = Open("data_table.jmp");
obj = Logistic(
Y( :sex ),
X( :height ),
Automatic Recalc( 0 ),
Positive Level( "M" ),
Odds Ratios( 1 ),
Show Rate Curve( 1 ),
ROC Curve,
Lift Curve,
);
obj << Local Data Filter(
Location( {0, 0} ),
Add Filter( columns( :age ), Where( :age == 12 ) ),
Mode( Select( 0 ), Show( 1 ), Include( 1 ) )
);
rpt = obj << Report;
actN = rpt[Number Col Box( 12 )] << Get( 1 );
Code Explanation:
- Open data table;
- Fit logistic regression model.
- Set response variable to "sex".
- Set predictor variable to "height".
- Disable automatic recalculation.
- Define positive level as "M".
- Enable odds ratios.
- Show rate curve.
- Generate ROC curve.
- Generate lift curve.
Example 15
Summary: Fits logistic regression models, applying local data filters, and retrieving reports from a JMP data table.
Code:
dt = Open("data_table.jmp");
obj = Logistic(
Y( :sex ),
X( :height ),
Automatic Recalc( 1 ),
Positive Level( "M" ),
Odds Ratios( 1 ),
Show Rate Curve( 1 ),
ROC Curve,
Lift Curve,
);
obj << Local Data Filter(
Location( {748, 19} ),
Mode,
Add Filter( columns( :height ), Where( :height >= 51 & :height <= 60 ), Display( :height ) )
);
rpt = obj << Report;
actN = rpt[Number Col Box( 12 )] << Get( 1 );
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Logistic(
Y( :sex ),
X( :height ),
Automatic Recalc( 0 ),
Positive Level( "M" ),
Odds Ratios( 1 ),
Show Rate Curve( 1 ),
ROC Curve,
Lift Curve,
);
obj << Local Data Filter(
Location( {0, 0} ),
Add Filter( columns( :age ), Where( :age == 12 ) ),
Mode( Select( 0 ), Show( 1 ), Include( 1 ) )
);
rpt = obj << Report;
actN = rpt[Number Col Box( 12 )] << Get( 1 );
Code Explanation:
- Open data table;
- Fit logistic regression model.
- Set local data filter.
- Retrieve report.
- Extract number from report.
- Close table without saving.
- Reopen "data_table.jmp" table.
- Refit logistic regression model.
- Set different local data filter.
- Retrieve updated report.
Example 16
Summary: Analyze a logistic regression model to estimate parameter estimates for male and female subjects, utilizing automatic recalculation and certification statistics.
Code:
dt = Open("data_table.jmp");
logi = dt << Logistic( Y( :age ), X( :weight ) );
logi << Automatic Recalc( 1 );
dt << select where( :sex == "M" );
dt << Hide and Exclude( 1 );
sumStats1 = Report( logi )["Parameter Estimates"][Table Box( 1 )] << get as matrix;
certStats1 = [0.393203762208981 1.91892269729832 0.0419875340971164 0.837643536448633,
1.13043931761916 1.93098213870009 0.342718852608946 0.558264037147018,
2.3348227827045 1.99291402299498 1.37255804198051 0.241372862515658,
3.00809074533778 2.04277525460176 2.16840644961753 0.140872145410627,
4.25563785435111 2.21532457004247 3.69023988190693 0.0547317441777929,
-0.0138583587243675 0.0186466407676287 0.552360214435949 0.457354912300557];
dt << Clear Row states;
dt << Select Where( :sex == "F" );
dt << Hide and Exclude( 1 );
sumStats2 = Report( logi )["Parameter Estimates"][Table Box( 1 )] << get as matrix;
certSTats2 = [9.0261659982534 3.22352736990941 7.84050269652724 0.00510883976577484,
10.5348245915297 3.36627401317594 9.79390052836118 0.00175091667426672,
12.5538281939888 3.65041661098598 11.8268066710511 0.000583840370554629,
14.8146898586434 4.05346127141199 13.3577426561281 0.000257357892347003,
15.844166097879 4.20648344178999 14.1873213450831 0.000165481790740533,
-0.111858230037988 0.033318992344299 11.2707331859847 0.000787386240902122];
Code Explanation:
- Open table.
- Fit logistic model.
- Enable automatic recalculation.
- Select male rows.
- Hide and exclude males.
- Get parameter estimates.
- Define certification statistics for males.
- Clear row states.
- Select female rows.
- Hide and exclude females.
Example 17
Summary: Fits a logistic model to a data table, filtering by country, and extracting probability values for specific categories.
Code:
dt = Open("data_table.jmp");
obj1 = dt << Logistic( Y( :Type ), X( :Weight ), Where( :Country == "Japan" ), Run );
obj1 << Save Probability Formula( 1 );
b save1 = (dt:Name( "Prob[Sporty] Where" ) << get values) || (dt:Name( "Prob[Small] Where" ) << get values) || (dt
:Name( "Prob[Compact] Where" ) << get values) || (dt:Name( "Prob[Medium] Where" ) << get values) || (dt:Name( "Prob[Large] Where" ) <<
get values);
Code Explanation:
- Open data table.
- Fit logistic model.
- Specify response variable.
- Specify predictor variable.
- Apply filter condition.
- Run the analysis.
- Save probability formula.
- Extract probability values.
- Concatenate probability arrays.
- Assign combined array.
Example 18
Summary: Fits a logistic model to predict probabilities based on weight and country, with interactive filtering by country.
Code:
dt = Open("data_table.jmp");
obj1 = dt << Logistic( Y( :Type ), X( :Weight ), Where( :Country == "USA" ), Run );
obj1 << Save Probability Formula( 1 );
b save2 = (dt:Name( "Prob[Sporty] Where" ) << get values) || (dt:Name( "Prob[Small] Where" ) << get values) || (dt
:Name( "Prob[Compact] Where" ) << get values) || (dt:Name( "Prob[Medium] Where" ) << get values) || (dt:Name( "Prob[Large] Where" ) <<
get values);
Code Explanation:
- Open data table.
- Fit logistic model.
- Specify response variable.
- Specify predictor variable.
- Filter for USA.
- Run the model.
- Save probability formula.
- Retrieve probability values.
- Concatenate probability arrays.
- Store concatenated values.
Example 19
Summary: Fits a logistic model to predict probabilities based on weight and country, then extracts and concatenates probability values for specific categories.
Code:
dt = Open("data_table.jmp");
obj1 = dt << Logistic( Y( :Type ), X( :Weight ), Where( :Country == "Other" ), );
obj1 << Save Probability Formula( 1 );
b save3 = (dt:Name( "Prob[Sporty] Where" ) << get values) || (dt:Name( "Prob[Small] Where" ) << get values) || (dt
:Name( "Prob[Compact] Where" ) << get values) || (dt:Name( "Prob[Medium] Where" ) << get values) || (dt:Name( "Prob[Large] Where" ) <<
get values);
Code Explanation:
- Open data table.
- Fit logistic model.
- Specify response variable.
- Specify predictor variable.
- Apply filter condition.
- Save probability formula.
- Extract probability values.
- Concatenate probability arrays.
Example 20
Summary: Creates a logistic model to predict probabilities by country, utilizing the Country variable and Weight as predictors.
Code:
dt = Open("data_table.jmp");
val = dt:Country << get values;
obj = dt << Logistic( Y( :Type ), X( :Weight ), by( :Country ), );
obj << Save Probability Formula( 1 );
save = (dt:Name( "Prob[Sporty] By Country" ) << get values) || (dt:Name( "Prob[Small] By Country" ) << get values) || (dt
:Name( "Prob[Compact] By Country" ) << get values) || (dt:Name( "Prob[Medium] By Country" ) << get values) || (dt
:Name( "Prob[Large] By Country" ) << get values);
For( i = 1, i <= N Items( val ), i++,
Match( val[i], "Japan", , "USA", , "Other", )
);
Code Explanation:
- Open data table;
- Get Country values.
- Fit logistic model.
- Save probability formula.
- Concatenate probability values.
- Loop through Country values.
- Match Japan condition.
- Match USA condition.
- Match Other condition.
Example 21
Summary: Fits a logistic regression model to predict age based on weight, generating a report and journal from the analysis, and setting the journal window title.
Code:
dt = Open("data_table.jmp");
myrpt = Logistic( Y( :age ), X( :weight ) ) << report;
myrpt << journal;
Current Journal() << set window title( "test" );
Current Journal() << closewindow( no save );
Code Explanation:
- Open data table;
- Fit logistic regression model.
- Generate model report.
- Create journal from report.
- Set journal window title.
- Close journal without saving.
Example 22
Summary: Creates a logistic model with inverse prediction and report generation using JMP's Logistic platform.
Code:
Open("data_table.jmp");
obj1 = Logistic(
Y( :Y Binary ),
X( :BMI ),
Lift Curve( 1 ),
ROC Curve( 1 ),
Target Level( "High" ),
Inverse Prediction( Response( 0.5, 0.1 ), Term Value( BMI( . ) ) ),
Inverse Prediction( Response( 0.9 ), Term Value( BMI( . ) ) )
);
rpt1 = obj1 << report;
Code Explanation:
- Open data table;
- Create logistic model object.
- Set response variable.
- Set predictor variable.
- Enable lift curve.
- Enable ROC curve.
- Set target level.
- Perform inverse prediction at 0.5 response.
- Perform inverse prediction at 0.9 response.
- Generate report object.
Example 23
Summary: Creates a logistic model with inverse predictions for binary response and continuous predictor variables, utilizing the JMP scripting language.
Code:
dt = Open("data_table.jmp");
obj1 = Logistic(
Y( :Y Binary ),
X( :BMI ),
Lift Curve( 1 ),
ROC Curve( 1 ),
Target Level( "High" ),
Inverse Prediction( Response( 0.5, 0.1 ), Term Value( BMI( . ) ) ),
Inverse Prediction( Response( 0.9 ), Term Value( BMI( . ) ) )
);
rpt1 = obj1 << report;
Code Explanation:
- Open data table;
- Create logistic model.
- Set response variable.
- Add predictor variable.
- Enable lift curve.
- Enable ROC curve.
- Set target level.
- Calculate inverse prediction at 0.5.
- Specify BMI term value.
- Calculate inverse prediction at 0.9.
Example 24
Summary: Creates a logistic regression model using age as the response variable and weight as the predictor variable, opening a data table from a specified file.
Code:
dt = Open("data_table.jmp");
obj = Logistic( Y( :age ), X( :weight ) );
Code Explanation:
- Open data table;
- Create logistic model object.
- Set response variable to age.
- Set predictor variable to weight.
Example 25
Summary: Creates a logistic regression model to predict sex based on weight, with a positive level set to 'M' and ROC curve generation.
Code:
dt = Open("data_table.jmp");
lg3 = Logistic( Y( :sex ), X( :weight ), Positive Level( "M" ), ROC Curve );
Code Explanation:
- Open data table;
- Create logistic model.
- Set response variable: sex.
- Set predictor variable: weight.
- Define positive level as "M".
- Generate ROC curve.
Logistic using For Each
Summary: Fits and creates reports for logistic models for multiple samples, utilizing a For Each loop to apply presets and set report titles.
Code:
plat_samples = ["Logistic" => {"Logistic with ROC Curves"}, => {}];
dt = Open("data_table.jmp");
For Each( {sample}, plat_samples["Logistic"],
obj = dt << Logistic( Y( :Response ), X( :"ln(dose)"n ) );
Eval( Eval Expr( obj << Apply Preset( "Sample Presets", Expr( sample ) ) ) );
obj << Set Report Title( sample );
);
Code Explanation:
- Define preset dictionary.
- Open data table;
- Loop through logistic samples.
- Fit logistic model.
- Apply preset to model.
- Set report title.
- Repeat for each sample.
Logistic using New Window
Example 1
Summary: Creates a new window with a horizontal list box, fitting a logistic model on the first dataset and adding a new data box for the second dataset.
Code:
dt = Open("data_table.jmp");
dt2 = Open("data_table.jmp");
win = New Window( "multi dt",
H List Box(
dt << Logistic( Y( :age ), X( :weight ), SendToReport( Dispatch( {}, "Parameter Estimates", OutlineBox, {Close( 1 )} ) ) ),
dt2 << New Data Box()
)
);
win << Save Window Report( "$TEMP/multipletables.jrp", embed data( 0 ) );
win << Close Window;
Code Explanation:
- Open data table;
- Open data table;
- Create new window titled "multi dt".
- Add horizontal list box.
- Fit logistic model on first dataset.
- Hide parameter estimates in report.
- Add new data box for second dataset.
- Save window report to file.
- Embed data in report.
- Close the window.
Example 2
Summary: Creates a new window with a horizontal list box, fitting a logistic model to data and adding a new data box, then saves and opens the report.
Code:
dt = Open("data_table.jmp");
dt2 = Open("data_table.jmp");
win = New Window( "multi dt",
H List Box(
dt << Logistic( Y( :age ), X( :weight ), SendToReport( Dispatch( {}, "Parameter Estimates", OutlineBox, {Close( 1 )} ) ) ),
dt2 << New Data Box()
)
);
win << Save Window Report( "$TEMP/multipletables.jrp", embed data( 0 ) );
win << Close Window;
Try( w = Open( "$TEMP/multipletables.jrp" ) );
w << set window size( 1200, 700 );
Code Explanation:
- Open data table;
- Open data table;
- Create new window named "multi dt".
- Add horizontal list box.
- Fit logistic model on data_table data.
- Hide parameter estimates outline.
- Add new data box for Little Pond data.
- Save window report as multipletables.jrp.
- Close the window.
- Open saved report.
- Set window size to 1200x700.
Logistic using Select Rows
Summary: Analyze a data table by selecting specific rows, excluding one row, running logistic regression with automatic recalculation and local data filtering, and extracting text from the report.
Code:
dt1 = Open("data_table.jmp");
r = dt1 << Select Rows( [2, 4, 6, 13, 15, 18, 19, 28, 32] );
r << Exclude( 1 );
report1 = dt1 << Logistic(
Y( :Size Co ),
X( :Name( "Sales ($M)" ) ),
Automatic Recalc( 1 ),
Local Data Filter(
COUNT EXCLUDED ROWS( 1 ),
Add Filter( columns( :Type ), Where( :Type == "Pharmaceutical" ), Display( :Type, Size( 181, 34 ), List Display ) )
)
);
text1 = (Report( report1 ) << parent)[Outline Box( 1 )][Text Box( 1 )] << get text;
Code Explanation:
- Open data table;
- Select specific rows.
- Exclude one row.
- Run logistic regression.
- Set Y variable.
- Set X variable.
- Enable automatic recalculation.
- Add local data filter.
- Filter by Pharmaceutical type.
- Extract text from report.
Logistic using Save
Summary: Selects and analyzes specific rows in a data table, performing logistic regression with automatic recalculation and local data filtering for Type 'Computer', before extracting text from the report and deleting the temporary file.
Code:
dt2 = Open("data_table.jmp");
dt2 << Save( "$TEMP/companiesOmit.jmp" );
r = dt2 << Select Rows( [2, 4, 6, 13, 15, 18, 19, 28, 32] );
report2 = dt2 << Logistic(
Y( :Size Co ),
X( :Name( "Sales ($M)" ) ),
Automatic Recalc( 1 ),
Local Data Filter(
COUNT EXCLUDED ROWS( 0 ),
Add Filter( columns( :Type ), Where( :Type == "Computer" ), Display( :Type, Size( 181, 34 ), List Display ) )
)
);
text2 = (Report( report2 ) << parent)[Outline Box( 1 )][Text Box( 1 )] << get text;
Delete File( "$TEMP/companiesOmit.jmp" );
Code Explanation:
- Open data table;
- Save as companiesOmit.jmp.
- Select specific rows.
- Perform logistic regression.
- Set automatic recalculation.
- Add local data filter.
- Filter for Type "Computer".
- Extract text from report.
- Delete temporary file.
Logistic using Set Modeling Type
Example 1
Summary: Fits a logistic model to predict probability values based on weight and country, with specific probabilities saved for Japan.
Code:
dt = Open("data_table.jmp");
dt:Type << Set Modeling Type( "Ordinal" );
obj1 = dt << Logistic( Y( :Type ), X( :Weight ), Where( :Country == "Japan" ) );
obj1 << Save Probability Formula( 1 );
b save1 = (dt:Name( "Prob[Sporty] Where" ) << get values) || (dt:Name( "Prob[Small] Where" ) << get values) || (dt
:Name( "Prob[Compact] Where" ) << get values) || (dt:Name( "Prob[Medium] Where" ) << get values) || (dt:Name( "Prob[Large] Where" ) <<
get values);
Code Explanation:
- Open data table.
- Set modeling type ordinal.
- Fit logistic model.
- Save probability formula.
- Extract probability values.
Example 2
Summary: Fits a logistic model to examine the relationship between Type and Weight, with specific consideration for observations from the USA.
Code:
dt = Open("data_table.jmp");
dt:Type << Set Modeling Type( "Ordinal" );
obj1 = dt << Logistic( Y( :Type ), X( :Weight ), Where( :Country == "USA" ) );
obj1 << Save Probability Formula( 1 );
b save2 = (dt:Name( "Prob[Sporty] Where" ) << get values) || (dt:Name( "Prob[Small] Where" ) << get values) || (dt
:Name( "Prob[Compact] Where" ) << get values) || (dt:Name( "Prob[Medium] Where" ) << get values) || (dt:Name( "Prob[Large] Where" ) <<
get values);
Code Explanation:
- Open data table.
- Set modeling type ordinal.
- Fit logistic model.
- Save probability formula.
- Retrieve probability values.
Example 3
Summary: Fits a logistic model to examine the relationship between Type and Weight, with interactive filtering by Country.
Code:
dt = Open("data_table.jmp");
dt:Type << Set Modeling Type( "Ordinal" );
obj1 = dt << Logistic( Y( :Type ), X( :Weight ), Where( :Country == "Other" ) );
obj1 << Save Probability Formula( 1 );
b save3 = (dt:Name( "Prob[Sporty] Where" ) << get values) || (dt:Name( "Prob[Small] Where" ) << get values) || (dt
:Name( "Prob[Compact] Where" ) << get values) || (dt:Name( "Prob[Medium] Where" ) << get values) || (dt:Name( "Prob[Large] Where" ) <<
get values);
Code Explanation:
- Open data table.
- Set modeling type ordinal.
- Fit logistic model.
- Save probability formula.
- Extract probability values.
Example 4
Summary: Analyze logistic regression models by country, generating probability values for different categories and saving them as a data table.
Code:
dt = Open("data_table.jmp");
dt:Type << Set Modeling Type( "Ordinal" );
val = dt:Country << get values;
obj = dt << Logistic( Y( :Type ), X( :Weight ), by( :Country ) );
obj << Save Probability Formula( 1 );
save = (dt:Name( "Prob[Sporty] By Country" ) << get values) || (dt:Name( "Prob[Small] By Country" ) << get values) || (dt
:Name( "Prob[Compact] By Country" ) << get values) || (dt:Name( "Prob[Medium] By Country" ) << get values) || (dt
:Name( "Prob[Large] By Country" ) << get values);
For( i = 1, i <= N Items( val ), i++,
Match( val[i], "Japan", , "USA", , "Other", )
);
Close( dt, no save );
b note1 = "Ready/Not Ready";
b note2 = "Not Ready/Ready";
Code Explanation:
- Open table.
- Set modeling type ordinal.
- Get country values.
- Fit logistic model.
- Save probability formula.
- Concatenate probability values.
- Loop through country values.
- Match country values.
- Close table without saving.
- Define notes.
Example 5
Summary: Analyze logistic regression by country, generating probability formulas and concatenating results for further exploration.
Code:
dt = Open("data_table.jmp");
dt:Type << Set Modeling Type( "Ordinal" );
val = dt:Country << get values;
obj = dt << Logistic( Y( :Type ), X( :Weight ), by( :Country ) );
obj << Save Probability Formula( 1 );
save = (dt:Name( "Prob[Sporty] By Country" ) << get values) || (dt:Name( "Prob[Small] By Country" ) << get values) || (dt
:Name( "Prob[Compact] By Country" ) << get values) || (dt:Name( "Prob[Medium] By Country" ) << get values) || (dt
:Name( "Prob[Large] By Country" ) << get values);
For( i = 1, i <= N Items( val ), i++,
Match( val[i], "Japan", , "USA", , "Other", )
);
Code Explanation:
- Open data table.
- Set modeling type for "Type".
- Get unique values from "Country".
- Perform logistic regression by country.
- Save probability formula.
- Concatenate probability columns.
- Loop through country values.
- Match country values (no action specified).
- End loop.
- Close script.
Logistic using Log Capture
Summary: Creates and analyzes a log output, including logistic regression with inverse prediction and report generation.
Code:
log1 = Log Capture(
dt = New Table( "LogRegInvPredDiff",
Add Rows( 8 ),
New Column( "dose", Numeric, Continuous, Set Values( [0.1, 0.3, 1, 3, 0.1, 0.3, 1, 3] ) ),
New Column( "logdose", Numeric, Continuous, Formula( Log10( :dose ) ), Lock( 1 ) ),
New Column( "NominalY", Numeric, Nominal, Set Values( [0, 0, 0, 0, 1, 1, 1, 1] ) ),
New Column( "count", Numeric, Continuous, Set Values( [1, 2, 5, 8, 7, 6, 3, 0] ) ),
New Column( "OrdinalY", Numeric, Ordinal, Set Values( [0, 0, 0, 0, 1, 1, 1, 1] ) )
);
ford = Logistic( Y( :OrdinalY ), X( :logdose ), Freq( :count ), Inverse Prediction( Response( 0.5 ) ) );
);
con = Contains( log1, "Inverse Response only works for Nominal responses" );
rord = Report( ford );
Close( dt, NoSave );
dt = Open("data_table.jmp");
lg3 = Logistic( Y( :sex ), X( :weight ), Positive Level( "M" ), ROC Curve );
Code Explanation:
- Capture log output.
- Create new table "LogRegInvPredDiff".
- Add 8 rows to the table.
- Define "dose" column with numeric values.
- Define "logdose" column with formula Log10(dose).
- Define "NominalY" column with nominal values.
- Define "count" column with continuous values.
- Define "OrdinalY" column with ordinal values.
- Perform logistic regression with OrdinalY as response.
- Check log for specific message.
- Generate report from logistic model.
- Close table without saving.
- Open data table.
- Perform logistic regression with sex as response.
Logistic using Response Screening
Summary: Runs a series of data manipulation and modeling tasks, including response screening, p-value extraction, and logistic regression fitting.
Code:
dt = Open("data_table.jmp");
obj1 = dt << Response Screening( Y( :sex ), X( :height ) );
dt1 = obj1 << Save PValues();
PValue1 = dt1:PValue[1];
obj2 = dt << Response Screening( Y( :sex, :weight ), X( :age, :height ), PValues Table on Launch( 1 ) );
dt2 = Data Table("data_table");
row = dt2 << Get Rows Where( :Y == "sex" & :X == "height" );
PValue2 = dt2:PValue[row][1];
obj3 = dt << Fit Group( Logistic( Y( :sex ), X( :height ) ) );
Code Explanation:
- Open data table.
- Perform response screening.
- Save p-values to new table.
- Extract first p-value.
- Perform response screening with multiple variables.
- Retrieve p-values table.
- Find specific row based on conditions.
- Extract p-value from found row.
- Fit logistic model to data.
- Perform group fitting.