cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
%3CLINGO-SUB%20id%3D%22lingo-sub-418487%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%3Ehow%20to%20get%20the%20x-value%20which%20gives%20me%2050%25%20of%20area%20under%20a%20curve%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-418487%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%3E%3CP%3EI%20have%20some%20continuous%20data%20and%20I%20fit%20a%20curve%20using%20%22Fit%20Model%22%20and%20used%20attributes%20%22Knotted%20Spline%20Effect%22%20and%2050%20knots.%20Then%20I%20save%20the%20prediction%20formula%20to%20the%20table.%20What%20I%20want%20to%20do%20next%20is%20to%20find%20the%20fragment%20size%20(x-value)%20which%20gives%20me%205%25%2C%2010%25%2C%2025%25%2C%2050%25%2C%2075%25%2C%2090%25%20and%2095%25%20of%20area.%20I%20have%2010%20samples%20and%20so%20I%20have%2010%20very%20complicated%20equations.%3C%2FP%3E%3CP%3EHow%20do%20I%20get%20the%20fragment%20size%20(x-value)%20with%20different%20area%20under%20the%20curve%3F%20I%20am%20not%20familiar%20with%20scripts%20so%20I%20prefer%20learning%20the%20mouse%20clicking%20way%20if%20possible.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screenshot%202021-09-15%20161811.png%22%20style%3D%22width%3A%20414px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Screenshot%202021-09-15%20161811.png%22%20style%3D%22width%3A%20414px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F35837iAEE33E38FA310F7E%2Fimage-dimensions%2F414x636%3Fv%3Dv2%22%20width%3D%22414%22%20height%3D%22636%22%20role%3D%22button%22%20title%3D%22Screenshot%202021-09-15%20161811.png%22%20alt%3D%22Screenshot%202021-09-15%20161811.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-418487%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%3E%3CLINGO-LABEL%3EAdvanced%20Statistical%20Modeling%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-418567%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20how%20to%20get%20the%20x-value%20which%20gives%20me%2050%25%20of%20area%20under%20a%20curve%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-418567%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EI%20use%20this%20%3CA%20href%3D%22https%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2Fen%2F16.1%2Findex.shtml%23page%2Fjmp%2Fknotted-spline-effect-example.shtml%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Eexample%3C%2FA%3E%20to%20illustrate%20one%20approach.%20I%20follow%20the%20instructions%20up%20to%20step%207.%20Then%20from%20the%20red%20triangle%20menu%20of%20the%20report%2C%20I%20choose%20%22Save%20Columns%22%20%26gt%3B%20%22Prediction%20Formula%22.%20Now%20I%20get%20a%20new%20column%2C%20and%20the%20formula%20is%20the%20function%20of%20the%20curve.%20Copy%20the%20formula%20from%20the%20column.%3C%2FP%3E%0A%3CP%3ENow%20go%20to%20Scripting%20Index%2C%20and%20find%20%22Integrate%22%20function.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22peng_liu_1-1631762883318.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22peng_liu_1-1631762883318.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22peng_liu_1-1631762883318.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22peng_liu_1-1631762883318.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F35852i2FE6BCA02301B5C4%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22peng_liu_1-1631762883318.png%22%20alt%3D%22peng_liu_1-1631762883318.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ENow%20paste%20the%20formula%20and%20replace%20the%20highlighted%20part%2C%20get%20this%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22peng_liu_2-1631762981590.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22peng_liu_2-1631762981590.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22peng_liu_2-1631762981590.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22peng_liu_2-1631762981590.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F35853i981E93B8AA9A7454%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22peng_liu_2-1631762981590.png%22%20alt%3D%22peng_liu_2-1631762981590.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ENow%20remove%20all%20the%20colon%20symbols%2C%20by%20replacing%20colon%20by%20empty%20string.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22peng_liu_3-1631763183428.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22peng_liu_3-1631763183428.png%22%20style%3D%22width%3A%20365px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22peng_liu_3-1631763183428.png%22%20style%3D%22width%3A%20365px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22peng_liu_3-1631763183428.png%22%20style%3D%22width%3A%20365px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F35854i8FCD7A8DDEBB9C46%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22peng_liu_3-1631763183428.png%22%20alt%3D%22peng_liu_3-1631763183428.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EAlso%20replace%20%22x%22%20by%20%22age%22%2C%20my%20x%20variable%20name.%3C%2FP%3E%0A%3CP%3ENow%20decide%20where%20the%20upper%20limit%20of%20the%20integration%20(100%25)%2C%20say%2080.%20And%20the%20result%20is%2069.783%20for%20100%25.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22peng_liu_5-1631763270010.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22peng_liu_5-1631763270010.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22peng_liu_5-1631763270010.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22peng_liu_5-1631763270010.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F35856i9285E4DB7A646E5D%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22peng_liu_5-1631763270010.png%22%20alt%3D%22peng_liu_5-1631763270010.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ENow%20the%20task%20is%20to%20find%20a%20number%20to%20replace%2080%2C%20and%20give%20me%2050%25%3A%2069.783%2F2%3D34.8915.%20I%20got%2044.228%20after%20maybe%20a%20dozen%20try%20and%20error.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22peng_liu_6-1631763432932.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22peng_liu_6-1631763432932.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22peng_liu_6-1631763432932.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22peng_liu_6-1631763432932.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F35857iED72FE1B7223CAE5%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22peng_liu_6-1631763432932.png%22%20alt%3D%22peng_liu_6-1631763432932.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIt%20requires%20JSL%20programming%2C%20but%20not%20much%2C%20to%20get%20more%20precise%20result%20quickly.%20Mostly%20still%20copy%20and%20paste.%20See%20the%20following%20screenshot.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22peng_liu_9-1631764338721.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22peng_liu_9-1631764338721.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22peng_liu_9-1631764338721.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22peng_liu_9-1631764338721.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F35860i35CEB26C3BD53D54%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22peng_liu_9-1631764338721.png%22%20alt%3D%22peng_liu_9-1631764338721.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThe%20key%20is%20to%20find%20the%20value%20that%20minimize%20the%20squared%20difference%20between%20integral%20and%20the%20target%20value%2034.8919.%20So%20I%20wrap%20the%20difference%20between%20integral%20and%20the%20target%20inside%20of%20a%20square%2C%20then%20call%20minimize%20function.%20Check%20out%20the%20function%20documentation%20for%20the%20syntax.%20The%20result%20for%2050%25%20is%2044.226900491921.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
dtsang
Level I

how to get the x-value which gives me 50% of area under a curve

I have some continuous data and I fit a curve using "Fit Model" and used attributes "Knotted Spline Effect" and 50 knots. Then I save the prediction formula to the table. What I want to do next is to find the fragment size (x-value) which gives me 5%, 10%, 25%, 50%, 75%, 90% and 95% of area. I have 10 samples and so I have 10 very complicated equations.

How do I get the fragment size (x-value) with different area under the curve? I am not familiar with scripts so I prefer learning the mouse clicking way if possible.

 

Screenshot 2021-09-15 161811.png

1 REPLY 1
peng_liu
Staff

Re: how to get the x-value which gives me 50% of area under a curve

I use this example to illustrate one approach. I follow the instructions up to step 7. Then from the red triangle menu of the report, I choose "Save Columns" > "Prediction Formula". Now I get a new column, and the formula is the function of the curve. Copy the formula from the column.

Now go to Scripting Index, and find "Integrate" function.

peng_liu_1-1631762883318.png

Now paste the formula and replace the highlighted part, get this:

peng_liu_2-1631762981590.png

Now remove all the colon symbols, by replacing colon by empty string.

peng_liu_3-1631763183428.png

Also replace "x" by "age", my x variable name.

Now decide where the upper limit of the integration (100%), say 80. And the result is 69.783 for 100%.

peng_liu_5-1631763270010.png

Now the task is to find a number to replace 80, and give me 50%: 69.783/2=34.8915. I got 44.228 after maybe a dozen try and error.

peng_liu_6-1631763432932.png

It requires JSL programming, but not much, to get more precise result quickly. Mostly still copy and paste. See the following screenshot.

peng_liu_9-1631764338721.png

The key is to find the value that minimize the squared difference between integral and the target value 34.8919. So I wrap the difference between integral and the target inside of a square, then call minimize function. Check out the function documentation for the syntax. The result for 50% is 44.226900491921.