cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
%3CLINGO-SUB%20id%3D%22lingo-sub-600498%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ENonlinear%20Fit%20-%20How%20to%20check%20for%20success%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-600498%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%3CSTRONG%3EOverview%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3EHow%20can%20I%20check%20to%20see%20a%20Nonlinear%20fit%20succeeded%3F%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E(Real-data%20doesn't%20always%20converge%20and%20may%20need%20manual%20review%20for%20automation%2Ftest%2Fproduct%20issues.)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EDetail%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EI%20would%20like%20to%20script%20a%20response%20after%20a%20nonlinear%20fit%20fails%20to%20converge.%26nbsp%3B%20If%20the%20fit%20fails%2C%20I%20need%20to%20process%20another%20way%2C%20and%2For%20eventually%20label%20for%20manual%20review.%20(I'm%20sampling%20a%20population%2C%20then%20for%20each%20part%2C%20doing%20a%20non-linear%20fit.%26nbsp%3B%20Generally%20if%20I%20fail%20convergence%2C%20there%20was%20a%20test%20issue%20somewhere%3B%20I%20don't%20actually%20want%20to%20loosen%20the%20convergence%20criteria.)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E('Failed'%20message%3A%20%22Failed%3A%20Cannot%20Decrease%20Objective%20Function%22)%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F50091i16B5465CA55A7137%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Nonlinear%20Fail%20Screenshot.png%22%20alt%3D%22Nonlinear%20Fail%20Screenshot.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EModified%20script%20from%20Numeric%20Derivatives%20Only%20(Help%20%26gt%3B%20Scripting%20Index%20%26gt%3B%20%22%26lt%3B%3CNONLINEAR%3E%3C%2FNONLINEAR%3E%3C%2FP%3E%3CP%3E(Currently%20running%20JMP%2015.2.1)%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Adt%20%3D%20Open(%0A%20%22%24SAMPLE_DATA%2FNonlinear%20Examples%2FUS%20Population.jmp%22%0A)%3B%0A%0A%2F%2F%20Random%2C%20intentionally%20divergent%2C%20formula%20on%20this%20dataset%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%20%22Random%22%2C%20Numeric%2C%20Formula(%20Random%20LogLogistic(5)%20)%20)%3B%0A%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%20%22FancyPredictionFormula%22%2C%0A%20Numeric%2C%0A%20Continuous%2C%0A%20Formula(%0A%20%20Parameter(%0A%20%20%20%7BRth0%20%3D%20735%2C%20n%20%3D%200.5%7D%2C%0A%20%20%20(%3Ayear%20%2F%20%3Apop)%20*%20((1%20-%20((n%20-%201)%20*%20%3Apop%20*%20Rth0)%20%2F%20(%3Ayear%0A%20%20%20%20*%20(300%20%2F%20%3Ayear)%20%5E%20n))%20%5E%20(-1%20%2F%20(n%20-%201))%20-%201)%0A%20%20)%0A%20)%0A)%3B%0A%0Anonlinear%20%3D%20dt%20%26lt%3B%26lt%3B%20Nonlinear(%0A%20Y(%20%20%3AName(%20%22Random%22%20)%20)%2C%0A%20X(%20%3AName(%22FancyPredictionFormula%22)%20)%2C%0A%20Expand%20Intermediate%20Formulas(%201%20)%2C%0A%20Numeric%20Derivatives%20Only(%201%20)%2C%0A%20QuasiNewton%20SR1%2C%0A%20Interation%20Limit(50)%2C%0A%20Finish%2C%0A%20Plot(%200%20)%2C%0A%20Confidence%20Limits%2C%0A%20Save%20Estimates%0A)%3B%0A%0A%2F%2F%20How%20to%20check%20if%20nonlinear%20fit%20succeeded%3F%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CU%3EIdeal.%3C%2FU%3E%3C%2FP%3E%3CP%3EIf%20there%20is%20a%20bool%20status%20variable%20returned%20by%20the%20Nonlinear%20fit%20platform%20somewhere%20indicating%20success%20or%20failure%2C%20that%20would%20be%20the%20ideal%20method%20to%20verify%20success%2C%20I%20think.%3C%2FP%3E%3CP%3E%3CU%3EAlternative%201.%3C%2FU%3E%3C%2FP%3E%3CP%3EI%20can%20also%20tabulate%20or%20take%20a%20summary%20of%20the%20data%20to%20see%20if%20all%20the%26nbsp%3B%3CFONT%20face%3D%22verdana%2Cgeneva%22%3E%3A%3CFONT%20color%3D%22%230000FF%22%3EName%3C%2FFONT%3E(%3CFONT%20color%3D%22%23993366%22%3E%22FancyPredictionFormula%22%3C%2FFONT%3E)%3C%2FFONT%3E%20values%20are%20zero.%26nbsp%3B%20(Values%20seem%20to%20be%200%20if%20the%20fit%20fails).%26nbsp%3B%3C%2FP%3E%3CP%3E%3CU%3EAlternative%202.%20%3C%2FU%3E%3C%2FP%3E%3CP%3EThere's%20probably%20a%20way%20to%20check%20the%20XML%20and%20read%20the%20'failed'%20message.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20time%20and%20consideration.%3C%2FP%3E%3CP%3E-Aubrey%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-600498%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3EScripting%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-600622%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Nonlinear%20Fit%20-%20How%20to%20check%20for%20success%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-600622%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHere's%20an%20approach%20using%20Alternative%202a%20(scraping%20the%20words%20from%20the%20report).%20The%20first%202%20lines%20do%20the%20actual%20work%2C%20and%20the%20third%20line%20is%20just%20a%20simple%20example%20of%20what%20to%20do%20with%20the%20information%3B%20you%20likely%20have%20something%20else%20in%20mind%20for%20this%20part.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%2F%2F%20How%20to%20check%20if%20nonlinear%20fit%20succeeded%3F%0Ar%20%3D%20nonlinear%20%26lt%3B%26lt%3B%20report%3B%0Aalltext%20%3D%20r%5BOutline%20Box(%22Control%20Panel%22)%5D%20%26lt%3B%26lt%3B%20get%20text%3B%0Aif%20(contains(alltext%2C%20%22Cannot%20Decrease%22)%2C%20caption%20(%22Failed%3A%20Cannot%20Decrease%20...%22))%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-600846%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Nonlinear%20Fit%20-%20How%20to%20check%20for%20success%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-600846%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EThat'll%20do%20it.%26nbsp%3B%20Thanks%20Jed!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-601016%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Nonlinear%20Fit%20-%20How%20to%20check%20for%20success%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-601016%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EI%20wonder%20if%20a%20better%20check%20is%20if%20the%20text%20is%20anything%20other%20than%20success%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EIf(%20Not(%20Contains(%20alltext%2C%20%22Converged%22%20)%20)%2C%0A%20%2F%2F%20trap%20failure%0A%20%2C%0A%20%2F%2F%20proceed%20after%20success%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-601121%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Nonlinear%20Fit%20-%20How%20to%20check%20for%20success%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-601121%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EYou%20are%20closer%20to%20where%20I%20am%20heading%20with%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20been%20working%20with%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Eif%20(contains(alltext%2C%20%22Failed%22)%2C%20caption%20(%22Failed%3A%20Do%20additional%20action%20now%20...%22))%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EAs%20a%20catch%20all%2C%20but%20I'm%20considering%20adding%20more%20of%20a%20case%20statement%20(or%20I%20guess%20multiple%20'ifs')%2C%20to%20specifically%20handle%20the%20fail%20reason.%3CCODE%20class%3D%22%20language-jsl%22%3E%3C%2FCODE%3E%3C%2FP%3E%3CP%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%3C%2FCODE%3E%3C%2FP%3E%3CP%3Ee.g.%20I%20can%20run%20again%20with%20a%20higher%20iteration%20count%20if%20I%20catch%20this%20fail-reason%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Econtains(alltext%2C%20%22Maximum%20Iteration%20Exceeded%22)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20real%20motivation%20is%2C%20'most'%20parts%20will%20converge%20with%20a%20numerical%20approach%2C%20but%20some%20seem%20to%20require%20analytical.%26nbsp%3B%20I'm%20not%20sure%20what's%20happening%20to%20cause%20this.%26nbsp%3B%20Convergence%20criteria%3F%26nbsp%3B%20But%20the%20'fix'%20is%20to%20run%20again%20without%20numerical%20derivatives%2C%20something%20like%3A%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Enonlinear%20%3D%20dt%20%26lt%3B%26lt%3B%20Nonlinear(%0A%20Y(%20%20%3AName(%20%22Random%22%20)%20)%2C%0A%20X(%20%3AName(%22FancyPredictionFormula%22)%20)%2C%0A%20Expand%20Intermediate%20Formulas(%201%20)%2C%0A%20Newton%2C%0A%20Finish%2C%0A%20Plot(%200%20)%2C%0A%20Confidence%20Limits%2C%0A%20Save%20Estimates%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EAfter%20catching%20with%3A%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Econtains(alltext%2C%20%22Cannot%20Decrease%20Objective%20Function%22)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-601522%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Nonlinear%20Fit%20-%20How%20to%20check%20for%20success%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-601522%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EThe%20usual%20culprit%20behind%20failing%20to%20converge%20is%20the%20starting%20parameter%20values.%20It%20is%20often%20sufficient%20to%20use%20domain-specific%20heuristics%20to%20initialize%20them%20when%20available.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
AApperson
Level II

Nonlinear Fit - How to check for success?

Overview:

How can I check to see a Nonlinear fit succeeded?

(Real-data doesn't always converge and may need manual review for automation/test/product issues.)

 

Detail:

I would like to script a response after a nonlinear fit fails to converge.  If the fit fails, I need to process another way, and/or eventually label for manual review. (I'm sampling a population, then for each part, doing a non-linear fit.  Generally if I fail convergence, there was a test issue somewhere; I don't actually want to loosen the convergence criteria.)

 

('Failed' message: "Failed: Cannot Decrease Objective Function")

Nonlinear Fail Screenshot.png

 

Modified script from Numeric Derivatives Only (Help > Scripting Index > "<<Nonlinear")

(Currently running JMP 15.2.1)

Names Default To Here( 1 );
dt = Open(
	"$SAMPLE_DATA/Nonlinear Examples/US Population.jmp"
);

// Random, intentionally divergent, formula on this dataset
dt << New Column( "Random", Numeric, Formula( Random LogLogistic(5) ) );

dt << New Column( "FancyPredictionFormula",
	Numeric,
	Continuous,
	Formula(
		Parameter(
			{Rth0 = 735, n = 0.5},
			(:year / :pop) * ((1 - ((n - 1) * :pop * Rth0) / (:year
			 * (300 / :year) ^ n)) ^ (-1 / (n - 1)) - 1)
		)
	)
);

nonlinear = dt << Nonlinear(
	Y(  :Name( "Random" ) ),
	X( :Name("FancyPredictionFormula") ),
	Expand Intermediate Formulas( 1 ),
	Numeric Derivatives Only( 1 ),
	QuasiNewton SR1,
	Interation Limit(50),
	Finish,
	Plot( 0 ),
	Confidence Limits,
	Save Estimates
);

// How to check if nonlinear fit succeeded?

 

 

 

Ideal.

If there is a bool status variable returned by the Nonlinear fit platform somewhere indicating success or failure, that would be the ideal method to verify success, I think.

Alternative 1.

I can also tabulate or take a summary of the data to see if all the :Name("FancyPredictionFormula") values are zero.  (Values seem to be 0 if the fit fails). 

Alternative 2.

There's probably a way to check the XML and read the 'failed' message. 

 

Thank you for your time and consideration.

-Aubrey

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Nonlinear Fit - How to check for success?

Here's an approach using Alternative 2a (scraping the words from the report). The first 2 lines do the actual work, and the third line is just a simple example of what to do with the information; you likely have something else in mind for this part.

 

// How to check if nonlinear fit succeeded?
r = nonlinear << report;
alltext = r[Outline Box("Control Panel")] << get text;
if (contains(alltext, "Cannot Decrease"), caption ("Failed: Cannot Decrease ..."));

View solution in original post

5 REPLIES 5

Re: Nonlinear Fit - How to check for success?

Here's an approach using Alternative 2a (scraping the words from the report). The first 2 lines do the actual work, and the third line is just a simple example of what to do with the information; you likely have something else in mind for this part.

 

// How to check if nonlinear fit succeeded?
r = nonlinear << report;
alltext = r[Outline Box("Control Panel")] << get text;
if (contains(alltext, "Cannot Decrease"), caption ("Failed: Cannot Decrease ..."));
AApperson
Level II

Re: Nonlinear Fit - How to check for success?

That'll do it.  Thanks Jed!

Re: Nonlinear Fit - How to check for success?

I wonder if a better check is if the text is anything other than success:

 

If( Not( Contains( alltext, "Converged" ) ),
	// trap failure
	,
	// proceed after success
);
AApperson
Level II

Re: Nonlinear Fit - How to check for success?

You are closer to where I am heading with it.

 

I've been working with:

 

if (contains(alltext, "Failed"), caption ("Failed: Do additional action now ..."));

As a catch all, but I'm considering adding more of a case statement (or I guess multiple 'ifs'), to specifically handle the fail reason.

e.g. I can run again with a higher iteration count if I catch this fail-reason:

 

contains(alltext, "Maximum Iteration Exceeded");

 

The real motivation is, 'most' parts will converge with a numerical approach, but some seem to require analytical.  I'm not sure what's happening to cause this.  Convergence criteria?  But the 'fix' is to run again without numerical derivatives, something like:

nonlinear = dt << Nonlinear(
	Y(  :Name( "Random" ) ),
	X( :Name("FancyPredictionFormula") ),
	Expand Intermediate Formulas( 1 ),
	Newton,
	Finish,
	Plot( 0 ),
	Confidence Limits,
	Save Estimates
);

After catching with:

contains(alltext, "Cannot Decrease Objective Function");

Re: Nonlinear Fit - How to check for success?

The usual culprit behind failing to converge is the starting parameter values. It is often sufficient to use domain-specific heuristics to initialize them when available.