Hi,
Does anyone know how to find the best fit in "Fit Y by X" platform?
sometimes, you did a liner fit, obviously Polynomial fit of degree 2 did a better fit. instead of comparing which one if better and trying
how do I quickly fit the best fit curve ? thanks
Pin
Here's a way that I don't like (to help give the discussion a bump).
This script fits up to 8th order polynomial, then uses the Adjusted RSquare as an evaluation tool. Adjusted RSquare isn't a very good method, though.
//open table
dt = open ("$SAMPLE_DATA/Big Class.jmp");
//run 1-8 poly
biv = dt << Bivariate( Y( :weight ), X( :height ) );
for each ({i}, 1::8,
biv << Fit Polynomial (i)
);
//export fits table
dtfits = Report(biv)["Linear Fit","Summary of Fit",TableBox(1)] << Make Combined Data Table;
//find best adjusted RSquare
dtfits << Select where (:Column 1 != "RSquare Adj") << Delete Rows;
dtfits << New Column ("Degree", formula (row())); //might be bad to assume here
dtfits << Select where (:Column 2 == col max(:Column 2)) << Markers ("X");
dtfits << Graph Builder(
Size( 528, 454 ),
Show Control Panel( 0 ),
Variables( X( :Degree ), Y( :Column 2 ) ),
Elements( Line( X, Y, Legend( 4 ) ), Points( X, Y, Legend( 5 ) ) )
);
Have you considered the Fit Curve platform? It gives AICc and BIC values, which could work better.
You could use Fit Curve to get a better summary table, but I think your script works better for automating looking through different polynomials for best fit. Fit Curve calls out the polynomials by name instead of by number.
Thank you Jed and Chris. Yup, I managed to find it using both the scripts and "Fit Curve" Platform which seems easier for my customer