Nonlinear
Example 1
Summary: Fits a nonlinear model to predict observed yield using a yield model, utilizing the Nonlinear platform in JMP.
Code:
// Model
// Open data table
dt = Open("data_table.jmp");
// Model
Nonlinear(
Y( :Observed Yield ),
X( :Yield Model )
);
Code Explanation:
- Open data table.
- Define model variables.
- Fit nonlinear model.
Example 2
Summary: Opens a data table, defines a full nonlinear model with Mitscherlich function, and executes the analysis to estimate the parameters.
Code:
// Full nonlinear model
// Open data table
dt = Open("data_table.jmp");
// Full nonlinear model
Nonlinear(
Y( :Algae density ),
X( :Mitscherlich ),
Finish
);
Code Explanation:
- Open data table.
- Define nonlinear model.
- Specify response variable.
- Specify predictor variable.
- Execute nonlinear analysis.
Example 3
Summary: Fits a reduced nonlinear model with equal alphas to the Algae density response variable using the :equal alphas predictor variable in a JMP data table.
Code:
// Reduced nonlinear model-with equal alphas
// Open data table
dt = Open("data_table.jmp");
// Reduced nonlinear model-with equal alphas
Nonlinear(
Y( :Algae density ),
X( :equal alphas ),
Finish
);
Code Explanation:
- Open data table.
- Define variable
dt. - Call
Openfunction. - Specify file path.
- Start
Nonlinearfunction. - Set response variable
Y. - Set predictor variable
X. - Use
:Algae densityforY. - Use
:equal alphasforX. - Execute
Finish.
Example 4
Summary: Fits a reduced nonlinear model with equal betas to the Algae density data, utilizing the Nonlinear function in JMP.
Code:
// Reduced nonlinear model-with equal betas
// Open data table
dt = Open("data_table.jmp");
// Reduced nonlinear model-with equal betas
Nonlinear(
Y( :Algae density ),
X( :equal betas ),
Finish
);
Code Explanation:
- Open data table.
- Assign data table to dt.
- Call Nonlinear function.
- Specify Y variable.
- Specify X variable.
- Finish Nonlinear model.
Example 5
Summary: Fits a nominal logistic regression model with multiple predictors using the Nonlinear platform in JMP, analyzing data from the Skull.jmp table.
Code:
// Nonlinear
// Open data table
dt = Open("data_table.jmp");
// Nonlinear
Nonlinear(
Y( :"log($ value)"n ),
X( :Model )
);
Code Explanation:
- Open data table.
- Set variable
dt. - Run nonlinear analysis.
- Specify response variable.
- Specify predictor variable.
Example 6
Summary: Fits a Meyers Model to the 'Velocity (y)' response variable using the 'Model (x)' predictor in the 'data_table.jmp' data table, utilizing the Newton optimization method.
Code:
// Meyers Model Fit
// Open data table
dt = Open("data_table.jmp");
// Meyers Model Fit
Nonlinear(
Y( :"Velocity (y)"n ),
X( :"Model (x)"n ),
Newton,
Finish
);
Code Explanation:
- Open data table.
- Specify response variable.
- Specify predictor variable.
- Choose optimization method.
- Execute nonlinear fit.
Example 7
Summary: Fits a nonlinear, disjoint linear model to predict the yield response variable using the linear predictor variable in the Skull data table.
Code:
// Nonlinear - disjoint linear
// Open data table
dt = Open("data_table.jmp");
// Nonlinear - disjoint linear
Nonlinear(
Y( :yield ),
X( :linear ),
Plot( 1 )
);
Code Explanation:
- Open data table.
- Assign data table to dt.
- Start nonlinear analysis.
- Set response variable to yield.
- Set predictor variable to linear.
- Generate plot for analysis.
Example 8
Summary: Fits a nonlinear model with a disjoint quadratic predictor to predict yield, utilizing the QuasiNewton SR1 method and enabling plot display.
Code:
// Nonlinear - disjoint quadratic
// Open data table
dt = Open("data_table.jmp");
// Nonlinear - disjoint quadratic
Nonlinear(
Y( :yield ),
X( :quad ),
Plot( 1 ),
QuasiNewton SR1
);
Code Explanation:
- Open data table.
- Fit nonlinear model.
- Specify yield as response.
- Use quad as predictor.
- Enable plot display.
- Use QuasiNewton SR1 method.
Example 9
Summary: Fits a nonlinear model with multiple predictors using the Nonlinear platform in JMP, utilizing the ModelY variable as the response and Loss function to estimate parameters.
Code:
// Nonlinear with ModelY and Loss
// Open data table
dt = Open("data_table.jmp");
// Nonlinear with ModelY and Loss
Nonlinear(
X( :Model Y ),
Loss( :Loss ),
Second Deriv Method( 1 ),
Loss is Neg LogLikelihood( 1 ),
Newton,
Finish,
Plot( 0 )
);
Code Explanation:
- Open data table.
- Define nonlinear model.
- Specify response variable.
- Specify loss function.
- Set second derivative method.
- Define loss as negative log-likelihood.
- Use Newton method.
- Finalize model fitting.
- Disable plot output.
Example 10
Summary: Fits a nonlinear model with Model2 Y and Loss2 using the Newton method, specifying numeric derivatives and relative gradient limits.
Code:
// Nonlinear with Model2 Y and Loss2
// Open data table
dt = Open("data_table.jmp");
// Nonlinear with Model2 Y and Loss2
Nonlinear(
X( :Model2 Y ),
Loss( :Loss2 ),
Relative Gradient( 0.000000001 ),
Gradient Limit( 0.000000001 ),
CL Limit( 0.00000001 ),
Numeric Derivatives Only( 1 ),
Loss is Neg LogLikelihood( 1 ),
Newton,
Finish,
Plot( 0 )
);
Code Explanation:
- Open data table.
- Define dependent variable.
- Define loss function.
- Set relative gradient limit.
- Set gradient limit.
- Set confidence limit.
- Use numeric derivatives.
- Specify loss type.
- Use Newton method.
- Finish nonlinear analysis.
Example 11
Summary: Fits a nonlinear model with no model column using the Nonlinear platform in JMP, utilizing the second derivative method and Newton's method for optimization.
Code:
// Nonlinear with no Model Column
// Open data table
dt = Open("data_table.jmp");
// Nonlinear with no Model Column
Nonlinear(
Loss( :Loss with No Model Column ),
Second Deriv Method( 1 ),
Loss is Neg LogLikelihood( 1 ),
Newton,
Finish,
Plot( 0 )
);
Code Explanation:
- Open data table.
- Set loss function.
- Use second derivative method.
- Define loss as negative log-likelihood.
- Apply Newton method.
- Finalize nonlinear analysis.
- Disable plot display.
Example 12
Summary: Fits a nominal logistic regression model with multiple predictors using the Nonlinear platform in JMP, utilizing the Poisson loss function and Newton method.
Code:
// Nonlinear
// Open data table
dt = Open("data_table.jmp");
// Nonlinear
Nonlinear(
X( :model ),
Loss( :Poisson ),
Loss is Neg LogLikelihood( 1 ),
Newton,
Finish,
Plot( 0 )
);
Code Explanation:
- Open data table.
- Specify nonlinear model.
- Define Poisson loss function.
- Use negative log-likelihood.
- Apply Newton method.
- Complete analysis.
- Disable plot display.
Example 13
Summary: Fits a nominal logistic regression model with multiple predictors using Newton's method and sending the results to reports.
Code:
dt under test = Open("data_table.jmp");
obj = Nonlinear(
Y( :pop ),
X( :Name( "X-formula" ) ),
Newton,
Finish,
SendToReport( Dispatch( {}, "Control Panel", OutlineBox, {Close( 1 )} ), Dispatch( {}, "Solution", OutlineBox, {Close( 1 )} ) )
);
Code Explanation:
- Open data table;
- Create nonlinear model object.
- Set dependent variable: population.
- Set independent variable: X-formula.
- Use Newton method for fitting.
- Finalize model fitting process.
- Close Control Panel report.
- Close Solution report.
Example 14
Summary: Fits a nonlinear model to data using the Nonlinear platform in JMP, with options for profiling and plotting.
Code:
dt under test = Open("data_table.jmp");
obj = Nonlinear(
Y( :Name( "Velocity (y)" ) ),
X( :Name( "Model (x)" ) ),
Newton,
Finish,
Plot( 0 ),
Profiler( 1, Confidence Intervals( 1 ), Term Value( Concentration( 2.5646, Lock( 0 ), Show( 1 ) ) ) ),
SendToReport(
Dispatch( {}, "Nonlinear Fit", OutlineBox, {Set Title( "Profilers: Profiler" )} ),
Dispatch( {}, "Solution", OutlineBox, {Close( 1 )} )
)
);
Code Explanation:
- Open data table.
- Define nonlinear model.
- Specify dependent variable.
- Specify independent variable.
- Use Newton method.
- Finalize model fit.
- Disable plot display.
- Enable profiler.
- Set confidence intervals.
- Set term value.
Example 15
Summary: Fits a nonlinear model to predict velocity based on a model variable, utilizing the Newton method and finishing the analysis.
Code:
dt under test = Open("data_table.jmp");
obj = Nonlinear( Y( :Name( "Velocity (y)" ) ), X( :Name( "Model (x)" ) ), Newton, Finish );
Code Explanation:
- Open data table.
- Define dependent variable.
- Define independent variable.
- Apply nonlinear model.
- Use Newton method.
- Finalize analysis.
Example 16
Summary: Fits a nonlinear model with multiple predictors using the Nonlinear platform in JMP.
Code:
dt under test = Open("data_table.jmp");
obj = Nonlinear( Y( :pop ), X( :Name( "X-formula" ) ), Newton, Finish );
Code Explanation:
- Open data table.
- Assign table to variable.
- Perform nonlinear analysis.
- Specify response variable.
- Specify predictor variable.
- Use Newton method.
- Complete analysis.
Example 17
Summary: Fits a nonlinear model using the Newton method to analyze the relationship between nitrate levels and Name in the data table.
Code:
dt under test = Open("data_table.jmp");
obj = Nonlinear( Y( :nitrate ), X( :Name( "linear" ) ), Newton, Finish );
Code Explanation:
- Open data table.
- Assign table to variable.
- Perform nonlinear analysis.
- Specify response variable.
- Specify predictor variable.
- Use Newton method.
- Finalize analysis.
Example 18
Summary: Fits a nonlinear model using the Nonlinear platform to estimate population values based on a specified formula.
Code:
dt = Open("data_table.jmp");
sol = [15.052907630874, 0.0141885129643142];
obj = dt << Nonlinear( Y( :pop ), X( :Name( "X-formula" ) ), Newton );
obj << go;
rpt = obj << report;
est = Matrix( rpt[Number Col Box( "Estimate" )] << get );
Code Explanation:
- Open data table.
- Define solution vector.
- Launch Nonlinear platform.
- Set response and predictor.
- Use Newton method.
- Execute analysis.
- Retrieve report object.
- Extract estimate column.
- Convert to matrix.
- Store estimates.
Example 19
Summary: Fits a nonlinear model with a nominal logistic regression using multiple predictors, including profiling and confidence intervals.
Code:
dt = Open("data_table.jmp");
obj = dt << Nonlinear(
Y( :pop ),
X( :Name( "X-formula" ) ),
Newton,
Finish,
Profiler( 1, Confidence Intervals( 1 ), Term Value( Year( 1910, Lock( 0 ), Show( 1 ) ) ) ),
Parameter Profiler(
1,
Confidence Intervals( 1 ),
Term Value( B0( 15.0529, Lock( 0 ), Show( 1 ) ), B1( 0.0141885, Lock( 0 ), Show( 1 ) ) )
)
);
Code Explanation:
- Open data table.
- Launch Nonlinear platform.
- Set response variable.
- Set predictor variable.
- Use Newton method.
- Finish model fitting.
- Enable Profiler.
- Show confidence intervals.
- Set term value for Year.
- Configure Parameter Profiler.
Example 20
Summary: Fits and creates reports for two nonlinear models to population data, with interactive features for exploring solution estimates and plots.
Code:
dt = Open("data_table.jmp");
obj1 = dt << Nonlinear(
Y( :pop ),
Model( Parameter( {A0 = 45000, k = 0.085, C = 0}, (C + A0 * Exp( k * (:year - 1790) )) ) ),
Finish,
Accept Current Estimates
);
rpt1 = obj1 << report;
est1 = (rpt1[Outline Box( "Solution" )][Table Box( 2 )] << get as matrix)[0, 1 :: 2];
jrn1 = rpt1[Outline Box( "Plot" )] << get journal;
obj2 = dt << Nonlinear(
Y( :pop ),
Model( Parameter( {A0 = 45000, k = 0.085, C = 0}, (C + A0 * Exp( k * (:year - Col Minimum( :year )) )) ) ),
Finish,
Accept Current Estimates
);
rpt2 = obj2 << report;
est2 = (rpt2[Outline Box( "Solution" )][Table Box( 2 )] << get as matrix)[0, 1 :: 2];
jrn2 = rpt2[Outline Box( "Plot" )] << get journal;
Code Explanation:
- Open data_table data
- Run nonlinear model on population.
- Set initial parameter estimates.
- Define model equation.
- Finish nonlinear analysis.
- Accept current estimates.
- Retrieve report object.
- Extract solution estimates.
- Get plot journal.
- Repeat steps 2-9 with modified model.
Example 21
Summary: Process of extracting checkbox text from a Nonlinear window in JMP, iterating through windows to find the desired one.
Code:
dt = Open("data_table.jmp");
obj = dt << Nonlinear();
For( i = 1, i <= N Items( Window() ), i++,
If( Window()[i] << get window title == "Nonlinear",
rpt = Window()[i];
cBox1 = Trim( rpt[CheckBoxBox( 1 )] << get text );
cBox2 = Trim( rpt[CheckBoxBox( 2 )] << get text );
)
);
Code Explanation:
- Open table.
- Access Nonlinear platform.
- Iterate through windows.
- Find Nonlinear window.
- Get first checkbox text.
- Get second checkbox text.
Example 22
Summary: Fits a nonlinear model to predict population growth using a custom equation with parameters A0, k, and C.
Code:
dt = Open("data_table.jmp");
obj = dt << Nonlinear(
Y( :pop ),
Model( Parameter( {A0 = 45000, k = 0.085, C = 0}, (C + A0 * Exp( k * (:year - Col Minimum( :year )) )) ) ),
Finish
);
Code Explanation:
- Open data table;
- Launch Nonlinear platform.
- Set response variable.
- Define model parameters.
- Specify model equation.
- Apply model constraints.
- Complete analysis setup.
Example 23
Summary: Fits a nonlinear model with multiple predictors to predict population values, utilizing the Nonlinear platform in JMP.
Code:
dt = Open("data_table.jmp");
obj = dt << Nonlinear( Y( :pop ), X( :Name( "X-formula" ) ), Finish );
rpt = obj << report;
popu = 200 + 100;
obj << Save Specific Solving Formula( :year, {:pop = 200 + 100}, Save Formula for Std Error Mean );
yr2 = Column( dt, N Col( dt ) - 1 ) << get formula;
obj << Profiler;
scptObj = rpt[Outline Box( "Prediction Profiler" )] << get scriptable object;
scptObj << Term Value( :year( yr2 ) );
popVal = Num( rpt[Outline Box( "Prediction Profiler" )][Text Box( 2 )] << get text );
Code Explanation:
- Open table.
- Fit nonlinear model.
- Retrieve report object.
- Define population value.
- Save solving formula.
- Get year column formula.
- Launch profiler.
- Get scriptable object.
- Set term value.
- Extract prediction value.
Example 24
Summary: Fits a nonlinear model with multiple predictors to a population response variable, generating a report and extracting standard error, correlation, and covariance matrices.
Code:
dt = Open("data_table.jmp");
obj = dt << Nonlinear( Y( :pop ), X( :Name( "X-formula" ) ), Finish );
rpt = obj << report;
stdErr = rpt[Number Col Box( "ApproxStdErr" )] << get as matrix;
correlation = obj << Get Corr;
covariance = obj << Get Cov;
Code Explanation:
- Open data table;
- Perform nonlinear analysis.
- Set population as response variable.
- Use X-formula as predictor.
- Finalize nonlinear model.
- Retrieve analysis report.
- Extract standard error matrix.
- Obtain correlation matrix.
- Fetch covariance matrix.
Example 25
Summary: Fits a nominal logistic regression model with multiple predictors using JMP's Nonlinear platform, saving estimates and prediction formulas.
Code:
dt = Open("data_table.jmp");
obj = Nonlinear( y( pop ), x( Name( "X-formula" ) ), Finish, );
obj << Save Estimates;
obj << Save Prediction Formula;
_xmat = dt << get as matrix;
Code Explanation:
- Open data table.
- Fit nonlinear model.
- Save parameter estimates.
- Save prediction formula.
- Extract data matrix.
Example 26
Summary: Fits a nonlinear model to predict population based on a formula, utilizing parameter profiling for independent and dependent resampling.
Code:
dt = Open("data_table.jmp");
obj = dt << Nonlinear( Y( :pop ), X( :Name( "X-formula" ) ), Go );
obj << Parameter Profiler( 1, Independent Uniform Inputs( 1 ), Independent Resampled Inputs( 1 ), Dependent Resampled Inputs( 1 ) );
Code Explanation:
- Open data table.
- Perform nonlinear fit.
- Launch parameter profiler.
- Set independent uniform inputs.
- Enable independent resampling.
- Enable dependent resampling.
Nonlinear using New Column
Example 1
Summary: Estimates Crow AMSAA loss and reliability growth analysis using nonlinear models with fixed parameters, generating reports for loss values and estimated parameters.
Code:
dt = Open("data_table.jmp");
dt << New Column( "Crow AMSAA Loss",
Formula(
Parameter(
{lambda = 0.012, beta = 0.75},
-(:Fixes * Log( lambda * beta )) - (:Fixes * (beta - 1) * Log( :Hours )) + If( Row() < 13, 0, lambda * (:Hours) ^ beta )
)
)
);
obj1 = dt << Nonlinear( Loss( :Crow AMSAA Loss ), Loss is Neg LogLikelihood( 1 ), Newton );
obj1 << Set Parameter( lambda = 0.012 );
obj1 << Lock Parameter( lambda );
obj1 << Finish;
rpt1 = obj1 << report;
loss1 = rpt1[Number Col Box( "Loss" )][1];
param1 = Matrix( rpt1[Number Col Box( "Estimate" )] << Get );
relg1 = dt << Reliability Growth( Input Format( Time to Event ), Time to Event( :Hours ), Fixed Parameter Crow AMSAA( lambda( 0.012 ) ) );
rgt1 = relg1 << report;
n2llk1 = rgt1[Number Col Box( "-2Loglikelihood" )][2];
est1 = Matrix( rgt1[Number Col Edit Box( 1 )] << get );
obj2 = dt << Nonlinear( Loss( :Crow AMSAA Loss ), Loss is Neg LogLikelihood( 1 ), Newton );
obj2 << Set Parameter( beta = 0.75 );
obj2 << Lock Parameter( beta );
obj2 << Finish;
rpt2 = obj2 << report;
loss2 = rpt2[Number Col Box( "Loss" )][1];
param2 = Matrix( rpt2[Number Col Box( "Estimate" )] << get );
relg2 = dt << Reliability Growth( Input Format( Time to Event ), Time to Event( :Hours ), Fixed Parameter Crow AMSAA( Beta( 0.75 ) ) );
rgt2 = relg2 << report;
n2llk2 = rgt2[Number Col Box( "-2Loglikelihood" )][2];
est2 = Matrix( rgt2[Number Col Edit Box( 1 )] << get );
Code Explanation:
- Open data table.
- Create new column "Crow AMSAA Loss".
- Define formula for "Crow AMSAA Loss".
- Run nonlinear model with initial parameters.
- Set lambda parameter.
- Lock lambda parameter.
- Finish nonlinear model run.
- Extract loss value from report.
- Extract parameter estimates from report.
- Run reliability growth analysis with fixed lambda.
- Extract report from reliability growth analysis.
- Extract -2Loglikelihood value.
- Extract estimated parameters.
- Run nonlinear model with initial parameters.
- Set beta parameter.
- Lock beta parameter.
- Finish nonlinear model run.
- Extract loss value from report.
- Extract parameter estimates from report.
- Run reliability growth analysis with fixed beta.
- Extract report from reliability growth analysis.
- Extract -2Loglikelihood value.
- Extract estimated parameters.
Example 2
Summary: Estimates Crow AMSAA loss and reliability growth analysis using a nonlinear model with fixed parameters, generating reports on loss values and parameter estimates.
Code:
dt = Open("data_table.jmp");
dt << New Column( "Crow AMSAA Loss",
Formula(
Parameter(
{lambda = 0.012, beta = 0.75},
-(:Fixes * Log( lambda * beta )) - (:Fixes * (beta - 1) * Log( :Hours )) + If( Row() < N Rows( Current Data Table() ),
0,
lambda * (:Hours) ^ beta
)
)
)
);
obj1 = dt << Nonlinear( Loss( :Crow AMSAA Loss ), Loss is Neg LogLikelihood( 1 ), Newton );
obj1 << Set Parameter( lambda = 0.012 );
obj1 << Lock Parameter( lambda );
obj1 << Finish;
rpt1 = obj1 << report;
loss1 = rpt1[Number Col Box( "Loss" )][1];
param1 = Matrix( rpt1[Number Col Box( "Estimate" )] << Get );
relg1 = dt << Reliability Growth( Input Format( Time to Event ), Time to Event( :Hours ), Fixed Parameter Crow AMSAA( lambda( 0.012 ) ) );
rgt1 = relg1 << report;
n2llk1 = rgt1[Number Col Box( "-2Loglikelihood" )][2];
est1 = Matrix( rgt1[Number Col Edit Box( 1 )] << get );
obj2 = dt << Nonlinear( Loss( :Crow AMSAA Loss ), Loss is Neg LogLikelihood( 1 ), Newton );
obj2 << Set Parameter( beta = 0.75 );
obj2 << Lock Parameter( beta );
obj2 << Finish;
rpt2 = obj2 << report;
loss2 = rpt2[Number Col Box( "Loss" )][1];
param2 = Matrix( rpt2[Number Col Box( "Estimate" )] << get );
relg2 = dt << Reliability Growth( Input Format( Time to Event ), Time to Event( :Hours ), Fixed Parameter Crow AMSAA( Beta( 0.75 ) ) );
rgt2 = relg2 << report;
n2llk2 = rgt2[Number Col Box( "-2Loglikelihood" )][2];
est2 = Matrix( rgt2[Number Col Edit Box( 1 )] << get );
Code Explanation:
- Open data table.
- Create new column.
- Define formula for new column.
- Run nonlinear model.
- Set lambda parameter.
- Lock lambda parameter.
- Finish nonlinear model.
- Extract loss value.
- Extract parameter estimates.
- Run reliability growth analysis.
Nonlinear using Column
Example 1
Summary: Runs the estimation and analysis of Crow AMSAA Loss using nonlinear regression, reliability growth modeling, and reporting in JMP.
Code:
dt = Open("data_table.jmp");
Column( dt, 2 )[N Rows( dt )] = 0;
dt << New Column( "Crow AMSAA Loss",
Formula(
Parameter(
{lambda = 0.012, beta = 0.75},
-(:Fixes * Log( lambda * beta )) - :Fixes * (beta - 1) * Log( :Hours ) + If( Row() < N Rows( Current Data Table() ),
0,
lambda * (:Hours) ^ beta
)
)
)
);
obj = dt << Nonlinear( Loss( :Crow AMSAA Loss ), Loss is Neg LogLikelihood( 1 ), Newton, Finish );
rpt = obj << report;
loss = (rpt[Number Col Box( "Loss" )] << get)[1];
param = (rpt[Outline Box( "Solution" )][Table Box( 2 )] << get as matrix)[0, 1 :: 2];
relg = dt << Reliability Growth( Input Format( Time to Event ), Time to Event( :Hours ), Event Count( :Fixes ), Crow AMSAA );
rgt = relg << report;
n2llk = (rgt[Number Col Box( "-2Loglikelihood" )] << get)[1];
est = (rgt[Outline Box( "Estimates" )][Table Box( 1 )] << get as matrix)[0, 1 :: 2];
Code Explanation:
- Open data table.
- Set last row's second column to 0.
- Create new column "Crow AMSAA Loss".
- Define formula for "Crow AMSAA Loss".
- Run nonlinear analysis.
- Extract loss value from report.
- Extract parameter estimates from report.
- Perform reliability growth analysis.
- Extract -2Loglikelihood from report.
- Extract estimated parameters from report.
Example 2
Summary: Estimates Crow AMSAA loss and reliability growth analysis using nonlinear regression and fixed parameter Crow AMSAA models.
Code:
dt = Open("data_table.jmp");
Column( dt, 2 )[N Rows( dt )] = 0;
dt << New Column( "Crow AMSAA Loss",
Formula(
Parameter(
{lambda = 0.012, beta = 0.75},
-(:Fixes * Log( lambda * beta )) - (:Fixes * (beta - 1) * Log( :Hours )) + If( Row() < N Rows( Current Data Table() ),
0,
lambda * (:Hours) ^ beta
)
)
)
);
obj1 = dt << Nonlinear( Loss( :Crow AMSAA Loss ), Loss is Neg LogLikelihood( 1 ), Newton );
obj1 << Set Parameter( lambda = 0.012 );
obj1 << Lock Parameter( lambda );
obj1 << Finish;
rpt1 = obj1 << report;
loss1 = rpt1[Number Col Box( "Loss" )][1];
param1 = Matrix( rpt1[Number Col Box( "Estimate" )] << Get );
relg1 = dt << Reliability Growth(
Input Format( Time to Event ),
Time to Event( :Hours ),
Event Count( :Fixes ),
Fixed Parameter Crow AMSAA( lambda( 0.012 ) )
);
rgt1 = relg1 << report;
n2llk1 = rgt1[Number Col Box( "-2Loglikelihood" )][2];
est1 = Matrix( rgt1[Number Col Edit Box( 1 )] << get );
obj2 = dt << Nonlinear( Loss( :Crow AMSAA Loss ), Loss is Neg LogLikelihood( 1 ), Newton );
obj2 << Set Parameter( beta = 0.75 );
obj2 << Lock Parameter( beta );
obj2 << Finish;
rpt2 = obj2 << report;
loss2 = rpt2[Number Col Box( "Loss" )][1];
param2 = Matrix( rpt2[Number Col Box( "Estimate" )] << get );
relg2 = dt << Reliability Growth(
Input Format( Time to Event ),
Time to Event( :Hours ),
Event Count( :Fixes ),
Fixed Parameter Crow AMSAA( Beta( 0.75 ) )
);
rgt2 = relg2 << report;
n2llk2 = rgt2[Number Col Box( "-2Loglikelihood" )][2];
est2 = Matrix( rgt2[Number Col Edit Box( 1 )] << get );
Code Explanation:
- Open data table.
- Set last row's Fixes to 0.
- Add new column "Crow AMSAA Loss".
- Define formula for "Crow AMSAA Loss".
- Run nonlinear analysis with initial parameters.
- Set lambda parameter.
- Lock lambda parameter.
- Finish nonlinear analysis.
- Extract loss value from report.
- Extract parameter estimates from report.
Nonlinear using Expr
Summary: Fits a nonlinear model to a dataset, retrieving fit messages and estimates, and handling missing values.
Code:
dt = Open("data_table.jmp");
nlfit = Expr(
dt << Nonlinear( Y( :pop ), X( :Name( "X-formula" ) ), Newton, Finish )
);
dt:year << Set Property( "Missing Value Codes", {1890} );
obj1 = Eval( Name Expr( nlfit ) );
mes1 = Report( obj1 )[String Col Box( 1 )] << get;
dt:year[dt << get rows where( :year == 1890 )] = .;
obj2 = Eval( Name Expr( nlfit ) );
mes2 = Report( obj2 )[String Col Box( 1 )] << get;
dt = dt << revert;
dt:pop << Set Property( "Missing Value Codes", {62.947} );
obj1 = Eval( Name Expr( nlfit ) );
est1 = Matrix( Report( obj1 )[Number Col Box( "Estimate" )] << get );
mes1 = Report( obj1 )[String Col Box( 1 )] << get;
dt:pop[dt << get rows where( :pop == 62.947 )] = .;
obj2 = Eval( Name Expr( nlfit ) );
est2 = Matrix( Report( obj2 )[Number Col Box( "Estimate" )] << get );
mes2 = Report( obj2 )[String Col Box( 1 )] << get;
Code Explanation:
- Open data table;
- Define nonlinear fitting expression.
- Set missing value code for year 1890.
- Execute nonlinear fit.
- Retrieve fit message.
- Replace year 1890 with missing value.
- Re-execute nonlinear fit.
- Retrieve new fit message.
- Revert dataset changes.
- Set missing value code for population 62.947.
- Execute nonlinear fit.
- Retrieve estimates.
- Retrieve fit message.
- Replace population 62.947 with missing value.
- Re-execute nonlinear fit.
- Retrieve new estimates.
- Retrieve new fit message.
Nonlinear using For
Summary: Generates distribution analysis for continuous variables in a specified data table using the Distribution platform, including calculation of median and IQR values, one-way ANOVA with Cauchy fit, and nonlinear regression on Cauchy loss.
Code:
dt = Open("data_table.jmp");
heightF = {};
heightM = {};
For( i = 1, i <= N Rows( dt ), i++,
If( Column( dt, 3 )[i] == "F",
heightF = heightF |/ Column( dt, 4 )[i],
heightM = heightM |/ Column( dt, 4 )[i]
)
);
htF = Sort Ascending( heightF );
htM = Sort Ascending( heightM );
medianF = (htF[N Rows( htF ) / 2] + htF[N Rows( htF ) / 2 + 1]) / 2;
medianM = (htM[N Rows( htM ) / 2] + htM[N Rows( htM ) / 2 + 1]) / 2;
IQR_F = Quantile( 0.75, htF ) - Quantile( 0.25, htF );
IQR_M = Quantile( 0.75, htM ) - Quantile( 0.25, htM );
obj = dt << Oneway( Y( :Height ), X( :Sex ) );
obj << Cauchy Fit;
rpt = obj << report;
cauchy_sig = (rpt[Outline Box( "Cauchy Fit" )][Number Col Box( "Sigma" )] << get as matrix)[1];
cauchy_CS = rpt[Outline Box( "Cauchy Fit" )][Number Col Box( "ChiSquare" )] << get as matrix;
cauchy_pVal = rpt[Outline Box( "Cauchy Fit" )][Number Col Box( "PValue" )] << get as matrix;
cauchy_LW = rpt[Outline Box( "Cauchy Fit" )][Number Col Box( "LogWorth" )] << get as matrix;
cauchy_est = rpt[Outline Box( "Cauchy Fit" )][Number Col Box( "Robust Mean" )] << get as matrix;
cauchy_std = rpt[Outline Box( "Cauchy Fit" )][Number Col Box( "Std Error" )] << get as matrix;
dt << New Column( "Cauchy Loss",
Formula(
Parameter(
{muF = Mean( htF ), muM = Mean( htM ), sigma = (IQR_F + IQR_M) / 2},
mu = Match( :sex, "F", muF, "M", muM, . );
Log( sigma + ((:height - mu) ^ 2 / sigma) );
)
)
);
obj1 = dt << Nonlinear( Loss( :Cauchy Loss ), Loss is Neg LogLikelihood( 1 ), Iteration Limit( 50 ), Finish );
rpt1 = obj1 << report;
est1 = (rpt1[Number Col Box( "Estimate" )] << get as matrix);
std1 = (rpt1[Number Col Box( "ApproxStdErr" )] << get as matrix);
Code Explanation:
- Open data table;
- Initialize empty lists for heights.
- Loop through rows of data.
- Separate female and male heights.
- Sort female heights.
- Sort male heights.
- Calculate median height for females.
- Calculate median height for males.
- Calculate IQR for females.
- Calculate IQR for males.
- Perform one-way ANOVA with Cauchy fit.
- Extract Cauchy fit parameters.
- Create new column for Cauchy loss formula.
- Perform nonlinear regression on Cauchy loss.
- Extract nonlinear regression estimates.