I’d like to work with person-level versus aggregated data as input to a graphing project. I used this bit of syntax to make paired spaghetti plots (Thank you, Bruce). I expect I’ll need to delete everything I’ve bolded. What I want to do
is to read in person-level data, plot the means as points, and fit both linear and quadratic lines through the points. Because I’m reading in raw data, I assume I need to do something to compute the means. In the index, I see two functions, smooth.mean and
summary.mean that both appear to compute the mean. I don’t understand the difference between them (but I’m sure there is a difference). I tried out putting either of the xxx.mean functions in where I’ve typed ‘?????’ below. The result was an error about gpl
algebra. Could someone help me with this? Thanks, Gene Maguin GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=wave mtxm1 txgroup
rid /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: wave=col(source(s), name("wave")) DATA: mtxm1=col(source(s), name("mtxm1")) DATA: txgroup=col(source(s), name("txgroup"), unit.category())
DATA: rid=col( source(s), name( "rid" ), unit.category() ) GUIDE: text.title(label("2017 Matrix.Motivate 1")) GUIDE: axis(dim(1), delta(3), label("Wave")) GUIDE: axis(dim(2), label("mtxm1")) GUIDE: axis(dim(3), label(" "), opposite()) GUIDE: legend(aesthetic(aesthetic.shape), null()) SCALE: linear(dim(1), min(0), max(16)) SCALE: linear(dim(2), min(0), max(5)) ELEMENT: point(position(???????? (wave*mtxm1*txgroup)), shape(rid)) ELEMENT: line(position(smooth.linear(???????(wave*mtxm1*txgroup)), shape(rid))) ELEMENT: line(position(smooth.quadratic(?????????(wave*mtxm1*txgroup)), shape(rid))) END GPL. |
I think you can just delete the ?????? (and the extra parenthesis) and your
code will work. The "smooth." functions fit a regression equation. Here the reg equations are something like: mtxm1 ~ intercept + B1*wave mtxm1 ~ intercept + B1*wave + B2*(wave**2) (Ignoring that you are also grouping, so it does a regression fit within each txgroup.) The "summary." functions are for use with categories. So straight from the GPL reference manual, ELEMENT: interval(position(summary.mean(jobcat*salary))) would give you a bar chart of the mean salary per each jobcat. ----- Andy W [hidden email] http://andrewpwheeler.wordpress.com/ -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Thank you for the recommendation about smooth.mean in
ELEMENT: line(position(smooth.linear(time*mtxm2))) ELEMENT: line(position(smooth.quadratic(time*mtxm2))) However, ELEMENT: point(position( (time*mtxm2))) Plots each value of mtxm2 at each time point. Informative, yes, but I want a single point representing the mean of mtxm2 at each time point. Thus this ELEMENT: point(position(smooth.mean(time*mtxm2))) But this doesn't work either because what it looks like I'm seeing is the mean of means plotted at each time point and those values are covered by what looks to be a horizontal line. Can you offer some advice? Thanks, Gene Maguin -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Andy W Sent: Tuesday, October 22, 2019 9:18 AM To: [hidden email] Subject: Re: gpl question I think you can just delete the ?????? (and the extra parenthesis) and your code will work. The "smooth." functions fit a regression equation. Here the reg equations are something like: mtxm1 ~ intercept + B1*wave mtxm1 ~ intercept + B1*wave + B2*(wave**2) (Ignoring that you are also grouping, so it does a regression fit within each txgroup.) The "summary." functions are for use with categories. So straight from the GPL reference manual, ELEMENT: interval(position(summary.mean(jobcat*salary))) would give you a bar chart of the mean salary per each jobcat. ----- Andy W [hidden email] http://andrewpwheeler.wordpress.com/ -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
If you post an example dataset I could give better advice, but one approach
would be to add in the mean you want into the current dataset as a new variable (via AGGREGATE), and then plot that new mean variable using a normal ELEMENT: line(). (Probably a way to do what you want all inline GPL, but I am not sure what the issue is with your current code offhand.) ----- Andy W [hidden email] http://andrewpwheeler.wordpress.com/ -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Ok, here's an example data set. When I run this what I get is three lines. One line the smooth.linear, another is the smooth.quadratic, and the third is what looks to be a thick horizontal line at what I think is the grand mean. Instead of that thick horizontal line, I want to see points/dots at the wave means, which are 2.34, 2.66, 2.96, 2.98.
data list free / rid wave y. begin data 1 0 2.5 1 1 2.3 1 2 3.4 1 3 3.0 2 0 2.5 2 1 3.2 2 2 2.7 2 3 2.9 3 0 2.8 3 1 2.2 3 2 2.8 3 3 3.5 4 0 1.9 4 1 2.5 4 2 2.5 4 3 2.9 5 0 2.0 5 1 3.1 5 2 3.4 5 3 2.6 end data. execute. format rid wave(f1.0) y(f3.1). means y by wave/cells=mean stddev. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=wave y /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: wave=col(source(s), name("wave")) DATA: y=col(source(s), name("y")) GUIDE: text.title(label("example")) GUIDE: axis(dim(1), delta(1), label("Wave")) GUIDE: axis(dim(2), label("y")) GUIDE: legend(aesthetic(aesthetic.shape), null()) SCALE: linear(dim(1), min(0), max(3)) SCALE: linear(dim(2), min(1), max(4)) ELEMENT: point(position(smooth.mean(wave*y))) ELEMENT: line(position(smooth.linear(wave*y))) ELEMENT: line(position(smooth.quadratic(wave*y))) END GPL. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Andy W Sent: Wednesday, October 23, 2019 8:52 AM To: [hidden email] Subject: Re: gpl question If you post an example dataset I could give better advice, but one approach would be to add in the mean you want into the current dataset as a new variable (via AGGREGATE), and then plot that new mean variable using a normal ELEMENT: line(). (Probably a way to do what you want all inline GPL, but I am not sure what the issue is with your current code offhand.) ----- Andy W [hidden email] http://andrewpwheeler.wordpress.com/ -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
This example is pretty ugly with all the different lines superimposed, but
here you go. Also included individual trajectories (which you could also do smooths to as well). ***************************. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=wave y rid /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: wave=col(source(s), name("wave")) DATA: y=col(source(s), name("y")) DATA: rid=col(source(s), name("rid"), unit.category()) GUIDE: text.title(label("example")) GUIDE: axis(dim(1), delta(1), label("Wave")) GUIDE: axis(dim(2), label("y")) GUIDE: legend(aesthetic(aesthetic.shape), null()) SCALE: linear(dim(1), min(0), max(3)) SCALE: linear(dim(2), min(1), max(4)) ELEMENT: point(position(summary.mean(wave*y)), size(size."12"), color.interior(color.blue)) ELEMENT: line(position(smooth.linear(wave*y))) ELEMENT: line(position(smooth.quadratic(wave*y)), color(color.red)) ELEMENT: line(position(wave*y), split(rid), size(size."0.5"), transparency(transparency."0.5")) END GPL. ***************************. ----- Andy W [hidden email] http://andrewpwheeler.wordpress.com/ -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Andy,
Thank you for your help. You're a GPL Master. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Andy W Sent: Wednesday, October 23, 2019 10:50 AM To: [hidden email] Subject: Re: gpl question This example is pretty ugly with all the different lines superimposed, but here you go. Also included individual trajectories (which you could also do smooths to as well). ***************************. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=wave y rid /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: wave=col(source(s), name("wave")) DATA: y=col(source(s), name("y")) DATA: rid=col(source(s), name("rid"), unit.category()) GUIDE: text.title(label("example")) GUIDE: axis(dim(1), delta(1), label("Wave")) GUIDE: axis(dim(2), label("y")) GUIDE: legend(aesthetic(aesthetic.shape), null()) SCALE: linear(dim(1), min(0), max(3)) SCALE: linear(dim(2), min(1), max(4)) ELEMENT: point(position(summary.mean(wave*y)), size(size."12"), color.interior(color.blue)) ELEMENT: line(position(smooth.linear(wave*y))) ELEMENT: line(position(smooth.quadratic(wave*y)), color(color.red)) ELEMENT: line(position(wave*y), split(rid), size(size."0.5"), transparency(transparency."0.5")) END GPL. ***************************. ----- Andy W [hidden email] http://andrewpwheeler.wordpress.com/ -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Free forum by Nabble | Edit this page |