I have a script that fits a custom formula for a Nonlinear model (not available on Nonlib) that gets the estimates for the model parameters. I can Save the formula under the red triangule menu and select save prediction formula which will create a new column for the new results. I can do this for every category.

```
New Column( "Fitted Model By Sample",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Property( "By ID", 207957763 ),
Formula(
If( :Sample == "Barley 2710",
If( :Days > 0,
0.171070850115799 * Exp( -Exp( ((0.00826868962267886 * Exp()) / 0.171070850115799) * (8.5626914275992 - :Days) ) )
+0.189197655815188 * Exp( -Exp( ((0.0822175769423173 * Exp()) / 0.189197655815188) * (1.00952608535815 - :Days) ) ),
0
),
.
)
),
Set Property( "Predicting", {:Average, Creator( "Nonlinear" )} ),
Set Selected
);
Set Label Columns( :Label );
```

However, I am trying to get it to run for all the categories in the data table to avoid having to do it manually. Any suggestion on how to do this?

I have tried to just publish the new formula but no column is created as when doing it manually such as:

```
obj = Nonlinear( Y( :Average ), X( :Model ), Loss( :Err ), Iteration Limit( 5000 ), By( :Sample ) );
obj << go;
obj << Publish prediction formula;
obj << Set name( "Fitted Model by sample" );
```

I have also tried modifying the JSL recorded script as below, unfortunately the formula does not work. Any help is much appreciated.

```
obj = Nonlinear( Y( :Average ), X( :Model ), Loss( :Err ), Iteration Limit( 5000 ), By( :Sample ) );
obj << go;
//returns a list of vectors where each vector, contains the parameters estimates
obj << get estimates;
obj << get prediction formula;
col11 = New Column( "Fitted Model By Sample",
set formula(
If( :Days > 0,
(Y1_Y1_0 * Exp( -Exp( ((K1_K1_0 * Exp()) / Y1_Y1_0) * (P1_P1_0 - :Days) ) ) + Y2_Y2_0 * Exp(
-Exp( ((K2_K2_0 * Exp()) / Y2_Y2_0) * (P2_P2_0 - :Days) )
)),
0
),
By( :Sample ),
Set Property( "Predicting", {:Average, Creator( "Nonlinear" )} ),
Set Selected
),
Set Label Columns( :Label )
);
```