# Graphing nonlinear results

#### saratogacoach

##### New Member
Not sure as newbie where to best post this question. A graph in a psychology article has a graph for survey scores. Would like to figure out formula of nonlinear (curving) line based on X,Y values displayed so that I could create a graph, place new scores on that line based on only having X, not Y. So formula would need to be Y = ? Plug in new X values and get new Y values. Have researched quadratic regression formulas since they look most like graph in article, but so far no joy. My statistical analysis skills are limited.

Would appreciate any suggestions on how to derive a formula from the data points given in the graph that can be used to get Y when a new X (score) is known.

Thank you.

Best Wishes,

#### rogojel

##### TS Contributor
hi,
there are several ways to solve this: most statistics SW have curve fitting possibilities, or you could generate a curve by using line segments or splines etc., or you could guess the marhematical form if the curve (looks like an exponential or power curve to me) and try the regression directly.

regards

#### saratogacoach

##### New Member
Hi Rogojel,

Thank you for these suggestions. When I plot the data in Excel, and use trend line, the closest fit is exponential. The equation is:

y= 73.128e^-0.831x
R^2= 0.9997

My Excel and my math skills are limited. All I have are X values to enter into any equation, so I am not sure how to use this curve equation? Not sure what value to enter for e or how to use R^2 equation (maybe no need to use R^2 equation; maybe it is only how close the curve fits?). But still would need e.

(I am trying to get an equation that I can use in an eLearning lesson. The eLearning lesson cannot use Excel. So the equation would need any equation components like e to be specified in non-Excel terms. Cannot use Excel functions in the lesson. Only can use standard math equations.)

Again, thank you for your help.

Best Wishes,

Last edited:

#### hlsmith

##### Less is more. Stay pure. Stay poor.
I am confused in that the article did something very different.

One thing to look out for if you want to be able to interpolate is using a regression approach that isn't too fitted like splines or general additive models. Issues can be related to interpreting what a sigmoidal line means when then increase sporadically. Though using transformations and polynomials can help in making sure you get interpretable coefficients.

It is all about trying to understand the underlying data generating process that you are try to fit a function to. So, why is it the shape it is.

#### saratogacoach

##### New Member
Hi,

Thank you for writing back. I was confused by the graph's Axis Y values, which are 1-3, 3-4, 4-5, 5-6, yet the illustration (Figure 1) shows equidistant marks. The only data available is in the article (was not able to find any online supplemental data, haven't yet heard back from author for my inquiry asking for additional data/information.)

My goal for the eLearning lesson is to display new results if a survey is done by the lesson taker. Using JavaScript and hopefully the curve's equation, I would try to automate placing a indicator over the new score's X,Y coordinates. The score only produces an X coordinate, so I need a way (equation?) to approximate the score's Y value in order to have the JavaScript move the indicator to that X,Y location.

So far, no joy. I haven't been able to extrapolate an equation from the article's graph or data to get this working. I can place the indicator using an X on one axis but need the associated Y to place it on the other axis.

Maybe not possible without more data (or better math skills )?

Best Wishes,

#### saratogacoach

##### New Member
One item that I would like to try but don't know how is to try the above equation:

y= 73.128e^-0.831x

The equation would need to be put into a plain math language so I could use it in JavaScript.

I don't know how to write out y= 73.128e^-0.831x, especially the exponent part to use in a formula? Is the exponent -0.831x mean -0.831*-0.831/x or something else with square roots?

Any help re-writing this equation so I can try it would be appreciated.

Thank you.

#### rogojel

##### TS Contributor
hi,
y= 73.128e^-0.831x means 73.228*exp(-0.841*x) - that should be easy program. This will predict the mean value of the y for the given x. To generate individual values you would need to add a small normal random variable to this mean, such that the mean of the random variable is 0 and the std dev a small number. You could work out the real stddev based on the R squared, but for just showing it in a teaching session I would try a few small numbers and take what looks reasonably similar to the original.

#### saratogacoach

##### New Member
Thank you, rogojel.

I have been trying this formula and several other variations, but so far I am not able to get new Y values to position at their correct location on the line. Not even close. The X location works OK but the Y is off by a lot.

I think that I will need to find another way to display score results in the lesson. Maybe at some point I will hear back from the article author and receive some additional data which could help me create the graph?

Thank you again for your kind help.

Best Wishes,