Error with TRANS/ELEMENT functions when plotting curve

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

Posts: 1
Joined: Mon Feb 13, 2017 1:55 pm

Error with TRANS/ELEMENT functions when plotting curve

Postby Semanticore » Mon Feb 13, 2017 2:16 pm

Hi all, I am trying to plot a curve on top of my chart, with the variable "interval" on the x axis and the mean of variable "BinaryType" on the y-axis (both continuous).

The equation I'm trying to plot is y=(e^(0.764412 -0.017356x + 0.000040x^2))/(1+e^(0.764412 -0.017356x + 0.000040x^2)) and so I estimated e as 2.71828 and used the "pow" function for exponentials.

To do this I attempted to modify the syntax for the chart by adding the DATA, TRANS and ELEMENT lines at the end, i.e.:

* Encoding: UTF-8.
* Chart Builder.
/GRAPHDATASET NAME="graphdataset" VARIABLES=Interval MEANCI(BinaryType,
95)[name="MEAN_BinaryType" LOW="MEAN_BinaryType_LOW" HIGH="MEAN_BinaryType_HIGH"] MISSING=LISTWISE
SOURCE: s=userSource(id("graphdataset"))
DATA: Interval=col(source(s), name("Interval"))
DATA: MEAN_BinaryType=col(source(s), name("MEAN_BinaryType"))
DATA: LOW=col(source(s), name("MEAN_BinaryType_LOW"))
DATA: HIGH=col(source(s), name("MEAN_BinaryType_HIGH"))
GUIDE: axis(dim(1), label("Interval"))
GUIDE: axis(dim(2), label("Mean BinaryType"))
GUIDE: text.footnote(label("Error Bars: 95% CI"))
ELEMENT: point(position(Interval*MEAN_BinaryType))
ELEMENT: interval(position(region.spread.range(Interval*(LOW+HIGH))), shape.interior(shape.ibeam))
DATA: x = iter(0,300,1)
TRANS: a = eval (0.764412-0.017356(x)+0.000040*pow ((x),2))
TRANS: b = eval (pow(2.71828, (a)))
TRANS: y = eval ((b)/(1+(b)))

ELEMENT: line(position(x*y))

However I keep getting a "derived exception error" for y. This occurs if the code is above or if I substitute (a) and (b) back into the equation so y is defined in terms of x (I haven't done that here as it makes it far longer and harder to read) The output states "Error in derived variable y defined as: (b)/(b+1)" (or the equivalent in terms of a or x, it doesn't seem to matter which term I use). I'm sure the problem is in the definition of y (or of a or b) and not elsewhere, as if I define y as e.g. "TRANS: y = eval ((x)+1) it works fine.

I've used the SPSS GUI for several years but have very limited experience using the syntax so I'm really struggling to fix this. Can anyone spot what went wrong and advise on how to fix it?

Thanks so much in advance!

Who is online

Users browsing this forum: No registered users and 3 guests