Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Sigma Plot, Non-linear regression, fitting a line to a set of points

  1. Jan 29, 2013 #1
    I model arterial baroreflex data that I have collected in humans using the Kent equation which is:
    y=p1/(1+exp((x-p3)*p2))+p4; where Y=heart rate, X= estimated carotid sinus pressure, p1=range of Y, p2=slope coeff, p3=centerpoint on X, p4 = minimum Y.

    I use Sigma Plot to do a best fit line on the points I have collected. The points are actually in six groups of 3 with one point which is the operating point. out of all of those points, the only one i know the gain at for sure is the single operating point.

    What I would like to know is: Is there any way to force the best fit line through a point which I have the coordinates and a gain that the line should have while passing through that point.

    Attached is a test file graph that explains my problem. the line fits the points with r^2 =0.966 but it does not go through the point (95,70) at a gain of -0.54, which is the only point and gain which is constant. Anybody know how to force fit the line to the point in Sigma Plot?

    X Y
    175.0000 58.0000 p1= 21.6905
    179.0000 59.0000 p2= 0.1047
    174.0000 62.0000 p3= 91.5081
    155.0000 59.0000 p4= 59.9046
    150.0000 57.0000
    158.0000 62.0000
    135.0000 62.0000
    136.0000 63.0000
    137.0000 60.0000
    114.0000 63.0000
    115.0000 59.0000
    116.0000 60.0000
    95.0000 70.0000
    75.0000 78.0000
    75.0000 77.0000
    74.0000 79.0000
    55.0000 83.0000
    53.0000 80.0000
    59.0000 81.0000
     

    Attached Files:

  2. jcsd
  3. Jan 31, 2013 #2

    DrDu

    User Avatar
    Science Advisor

    I suppose with gain you mean the slope?
    First note that it is not possible to estimate p2 and p3 independently from the data but only the product p5= p2*exp(-p3).
    Then when you know dy/dx at some point you can solve this equation for e.g. p1 and eliminate it from the equation which relates y to x, p1, p4 and p5.
     
  4. Jan 31, 2013 #3
    DrDu,
    thank you for the reply, I guess what I am really asking is, "In SigmaPlot, Does anybody know how to force an inverse logistic function curve through a known point at a known slope, while fitting the the curve?" the reason I ask is that through manipulation of blood pressure, I get a heart rate response that falls along a curve identified by the equation above, but the only point for which i can calculate the slope is at steady state resting because i have hundreds of small interactions between BP and HR which allow for the dY/dX. the rest of the curve is built with 18 other data points. Just wish I could figure out the syntax for forcing a line through a point at a slope.
     
  5. Feb 1, 2013 #4

    DrDu

    User Avatar
    Science Advisor

    I think I understood your question, although I am not sure whether you understood the solution I was proposing.
    I don't know Sigmaplot, but I don't think that's relevant. What you want to do is to find a solution which obeys an auxiliary condition, namely that it's slope at a given point has a given value.
    I recommended to include this information explicitly in the equation by elimination of one of the parameters before doing the optimization.
    Another method would be to use the technique of Lagrangian multipliers. maybe something of this kind is implemented directly in Sigmaplot.
     
  6. Feb 1, 2013 #5
    DrDu,

    You are probably correct in the assumption that I cannot visualize the solution you have given in my mind. Mathematically you suggestions are probably spot on and I will search the SigmaPlot manuals for Lagrangian multipliers and I will also try to eliminate a variable in the equation. As you probably know, some of these statistics programs are touchy and without full knowledge of the syntax, even something as simple in the mind as "Hey, go through this point at this slope while fitting the line," becomes terribly difficult.

    If you happen to run across the syntax solution to force fit a line, let me know. Even if you find it in some other computer program, it can probably be translated to SigmaPlot.

    Again, thank you for all of your insight, it has given me tons to consider for future data analysis. If I use your suggestions, I will include you in the acknowledgements section of my dissertation and any other publications that come.
     
  7. Feb 1, 2013 #6

    rollingstein

    User Avatar
    Gold Member

    So far as I know, this cannot be done in Sigmaplot.
     
  8. Feb 1, 2013 #7

    rollingstein

    User Avatar
    Gold Member

    Add this as your constraint by setting RHS to -0.54 at x=95:

    St8vYzH.gif
     
  9. Feb 1, 2013 #8

    rollingstein

    User Avatar
    Gold Member

    Actually the slope and pass-through-point constraint give you two independant eq. in (p1, p2, p3, p4).

    Using algebra, can't you restate the model in just 2 variable and then use the fit function?

    Do you see what I mean?

    The algebra seems a bit messy for the slope constraint though.

    i.e.

    p4=70-p1/(1+exp((95-p3)*p2))

    and

    p1={ 0.54*[exp(p2*p3)+exp(p2*95)]^2 } / {p2 * exp(p2*(p3 + 95)) }

    So now fit in SigmaPlot the following fn but only for p2 and p3.

    y=[{ 0.54*[exp(p2*p3)+exp(p2*95)]^2 } / {p2 * exp(p2*(p3 + 95)) }]/(1+exp((x-p3)*p2))+70-p1/(1+exp((95-p3)*p2))

    Messy, but you put the constraints on and not me. :)
     
    Last edited: Feb 1, 2013
  10. Feb 1, 2013 #9
    rollingstein,

    thanks for the reply. I tried putting the solution that you gave as a constraint but i got an error message. I am assuming that it is a parenthetical problem so i put it into excel and the slope I get back while putting in the parameters 1.6*10^-74. It is probably something that I did wrong. you seem to have some experience with sigmaplot. how would you type the equation into the constraint section?
     
  11. Feb 1, 2013 #10

    rollingstein

    User Avatar
    Gold Member

    Its likely I did an algebra blunder. Verify my rearrangements.
     
  12. Feb 1, 2013 #11

    rollingstein

    User Avatar
    Gold Member

    The red line looks right?

    qoxSAo8l.jpg

    Larger image here:

    http://i.imgur.com/qoxSAo8.jpg

    Verification:

    predict(fit1,list(x=95))
    [1] 70

    (predict(fit1,list(x=96))-predict(fit1,list(x=94)))/(96-94)
    [1] -0.5395504

    PS. I used R instead; didn't have Sigmaplot handy.
     
    Last edited: Feb 1, 2013
  13. Feb 1, 2013 #12

    rollingstein

    User Avatar
    Gold Member


    It was a mistake. Left a p1 unsubstituted.

    Try fitting this in Sigmaplot for p2 and p3.:

    y=(( 0.54*(exp(p2*p3)+exp(p2*95))^2 ) / (p2 * exp(p2*(p3 + 95)) ))/(1+exp((x-p3)*p2))+70-(( 0.54*(exp(p2*p3)+exp(p2*95))^2 ) / (p2 * exp(p2*(p3 + 95)) ))/(1+exp((95-p3)*p2))
     
  14. Feb 1, 2013 #13
    Rollingstein,

    That's pretty awesome, still can't get sigmaplot to accept the equations as fitting constraints. also I have to make the equations dynamic because p1, p2, p3, p4, OP(x,y), m(OP) change for every subject. OP is the operating point for which I have the point and slope. I have sent in a request to systat for them to make "force fitting a line" a drop down option in the regression wizard. Thanks for all the work you have put in to this. I will keep trying to finesse the equations into existence but it may be a never-ending struggle with SigmaPlot.

    Thanks alot dude
     
  15. Feb 1, 2013 #14

    rollingstein

    User Avatar
    Gold Member

    Sure. It was an interesting problem; hence my motivation. :)


    Try R:

    Code (Text):
    fit<-nls(y~p1/(1+exp((x-p3)*p2))+p4,start=list(p1=20,p2=0.1,p3=90,p4=50))
     summary(fit)

      plot(x,y)
     
      tt<-seq(60,180,length=100)
     
      lines(tt, predict(fit,list(x=tt)))
     
     
    fit1<-nls(y~(( 0.54*(exp(p2*p3)+exp(p2*95))^2 ) / (p2 * exp(p2*(p3 + 95)) ))/(1+exp((x-p3)*p2))+70-(( 0.54*(exp(p2*p3)+exp(p2*95))^2 ) / (p2 * exp(p2*(p3 + 95)) ))/(1+exp((95-p3)*p2)),start=list(p2=0.1,p3=90))

    lines(tt, predict(fit1,list(x=tt)),col=34)

    predict(fit1,list(x=95))
    [1] 70

    (predict(fit1,list(x=96))-predict(fit1,list(x=94)))/(96-94)
    [1] -0.5395504
     
     
  16. Feb 1, 2013 #15

    rollingstein

    User Avatar
    Gold Member


    I think the current formulation is pretty dynamic. Just replace 95 by x_OP,70 by y_OP and -0.54 by s_OP

    The rest should be the same.

    I'm telling you, it'll be a breeze in R. :biggrin:

    PS. I'm no R loyalist. I believe in whatever works. Had tried Python on your problem at first but didn't get far.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Sigma Plot, Non-linear regression, fitting a line to a set of points
Loading...