Forgive me if I’m using the wrong terms or not describing this well… I’m trying to prepare an example dataset for teaching purposes to demonstrate dispersion and to print simple histograms with the frequency command. The SPSS output seems to automatically scale the horizontal axis for these charts so no matter what the standard deviation is for my example variables (normally distributed), the resulting histogram chart looks essentially identical with the exception of the labelling of the horizontal axis. Is there any way to force SPSS to use a specific scale/metric for the horizontal axis so that the resulting curve looks wider for a larger SD and narrower for a smaller SD? …again, sorry if I’m not describing the issue well. Best, Jeff |
Administrator
|
Hi Jeff. If you use the Chart Builder, you can set the starting point and
bin width. See the binStart() and binWidth() functions in the ELEMENT line below. This should work for you if you know in advance the values you want to plug in. HTH. * Change path to show where you store the sample datasets. GET FILE = "C:\SPSSdata\survey_sample.sav". * Chart Builder. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=educ MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: educ=col(source(s), name("educ")) GUIDE: axis(dim(1), label("Highest year of school completed")) GUIDE: axis(dim(2), label("Frequency")) GUIDE: text.title(label("Simple Histogram of Highest year of school completed")) ELEMENT: interval(position(summary.count(bin.rect(educ, binStart(0), binWidth(5)))), shape.interior(shape.square)) END GPL. Jeff-2 wrote > Forgive me if I'm using the wrong terms or not describing this well. > > > > I'm trying to prepare an example dataset for teaching purposes to > demonstrate dispersion and to print simple histograms with the frequency > command. The SPSS output seems to automatically scale the horizontal axis > for these charts so no matter what the standard deviation is for my > example > variables (normally distributed), the resulting histogram chart looks > essentially identical with the exception of the labelling of the > horizontal > axis. Is there any way to force SPSS to use a specific scale/metric for > the > horizontal axis so that the resulting curve looks wider for a larger SD > and > narrower for a smaller SD? > > > > .again, sorry if I'm not describing the issue well. > > > > Best, > > > > Jeff > > > > > > > > > > > > > > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- 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
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
In reply to this post by Jeff A
Here are a few examples.
*******************************************************************************************. SET SEED 10. INPUT PROGRAM. LOOP ID = 1 TO 200. END CASE. END LOOP. END FILE. END INPUT PROGRAM. DATASET NAME Sim. COMPUTE X1 = RV.NORMAL(50,10). COMPUTE X2 = RV.NORMAL(50,5). COMPUTE X3 = RV.NORMAL(50,1). FORMATS X1 X2 X3 (F3.0). FREQ X1 TO X3 /FORMAT = NOTABLE /STATISTICS = MIN MAX MEAN STDDEV. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=X1 /GRAPHSPEC SOURCE=INLINE /FRAME INNER=YES. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: X1=col(source(s), name("X1")) GUIDE: axis(dim(1), label("X1")) GUIDE: axis(dim(2), label("Frequency")) SCALE: linear(dim(1), min(15), max(80)) ELEMENT: interval(position(summary.count(bin.rect(X1, binStart(15), binWidth(1)))), shape.interior(shape.square)) END GPL. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=X2 /GRAPHSPEC SOURCE=INLINE /FRAME INNER=YES. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: X2=col(source(s), name("X2")) GUIDE: axis(dim(1), label("X2")) GUIDE: axis(dim(2), label("Frequency")) SCALE: linear(dim(1), min(15), max(80)) ELEMENT: interval(position(summary.count(bin.rect(X2, binStart(15), binWidth(1)))), shape.interior(shape.square)) END GPL. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=X3 /GRAPHSPEC SOURCE=INLINE /FRAME INNER=YES. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: X3=col(source(s), name("X3")) GUIDE: axis(dim(1), label("X3")) GUIDE: axis(dim(2), label("Frequency")) SCALE: linear(dim(1), min(15), max(80)) ELEMENT: interval(position(summary.count(bin.rect(X3, binStart(15), binWidth(1)))), shape.interior(shape.square)) END GPL. *All three in one, easier to reshape. VARSTOCASES /MAKE X FROM X1 X2 X3 /INDEX Num. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=X Num /GRAPHSPEC SOURCE=INLINE /FRAME INNER=YES. BEGIN GPL PAGE: begin(scale(500px,800px)) SOURCE: s=userSource(id("graphdataset")) DATA: X=col(source(s), name("X")) DATA: Num=col(source(s), name("Num"), unit.category()) GUIDE: axis(dim(1)) GUIDE: axis(dim(2), label("Frequency")) GUIDE: axis(dim(4), opposite()) ELEMENT: interval(position(summary.count(bin.rect(X*1*1*Num, binStart(15), binWidth(1)))), shape.interior(shape.square)) PAGE: end() END GPL. *Tough to do all three in the same plot, easier with just the curves. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=X Num /GRAPHSPEC SOURCE=INLINE /FRAME INNER=YES. BEGIN GPL PAGE: begin(scale(600px,500px)) SOURCE: s=userSource(id("graphdataset")) DATA: X=col(source(s), name("X")) DATA: Num=col(source(s), name("Num"), unit.category()) GUIDE: axis(dim(1)) GUIDE: axis(dim(2), label("Frequency")) GUIDE: axis(dim(4), opposite()) ELEMENT: interval(position(summary.count(bin.rect(X, binStart(15), binWidth(1)))), shape.interior(shape.square), color.interior(Num), transparency.interior(transparency."0.5")) PAGE: end() 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 |
This is great Andy. ...Bruce also.
Thanks much. Jeff -----Original Message----- From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Andy W Sent: Tuesday, 12 February 2019 12:35 AM To: [hidden email] Subject: Re: Holding the scale constant with histograms Here are a few examples. **************************************************************************** ***************. SET SEED 10. INPUT PROGRAM. LOOP ID = 1 TO 200. END CASE. END LOOP. END FILE. END INPUT PROGRAM. DATASET NAME Sim. COMPUTE X1 = RV.NORMAL(50,10). COMPUTE X2 = RV.NORMAL(50,5). COMPUTE X3 = RV.NORMAL(50,1). FORMATS X1 X2 X3 (F3.0). FREQ X1 TO X3 /FORMAT = NOTABLE /STATISTICS = MIN MAX MEAN STDDEV. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=X1 /GRAPHSPEC SOURCE=INLINE /FRAME INNER=YES. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: X1=col(source(s), name("X1")) GUIDE: axis(dim(1), label("X1")) GUIDE: axis(dim(2), label("Frequency")) SCALE: linear(dim(1), min(15), max(80)) ELEMENT: interval(position(summary.count(bin.rect(X1, binStart(15), binWidth(1)))), shape.interior(shape.square)) END GPL. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=X2 /GRAPHSPEC SOURCE=INLINE /FRAME INNER=YES. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: X2=col(source(s), name("X2")) GUIDE: axis(dim(1), label("X2")) GUIDE: axis(dim(2), label("Frequency")) SCALE: linear(dim(1), min(15), max(80)) ELEMENT: interval(position(summary.count(bin.rect(X2, binStart(15), binWidth(1)))), shape.interior(shape.square)) END GPL. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=X3 /GRAPHSPEC SOURCE=INLINE /FRAME INNER=YES. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: X3=col(source(s), name("X3")) GUIDE: axis(dim(1), label("X3")) GUIDE: axis(dim(2), label("Frequency")) SCALE: linear(dim(1), min(15), max(80)) ELEMENT: interval(position(summary.count(bin.rect(X3, binStart(15), binWidth(1)))), shape.interior(shape.square)) END GPL. *All three in one, easier to reshape. VARSTOCASES /MAKE X FROM X1 X2 X3 /INDEX Num. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=X Num /GRAPHSPEC SOURCE=INLINE /FRAME INNER=YES. BEGIN GPL PAGE: begin(scale(500px,800px)) SOURCE: s=userSource(id("graphdataset")) DATA: X=col(source(s), name("X")) DATA: Num=col(source(s), name("Num"), unit.category()) GUIDE: axis(dim(1)) GUIDE: axis(dim(2), label("Frequency")) GUIDE: axis(dim(4), opposite()) ELEMENT: interval(position(summary.count(bin.rect(X*1*1*Num, binStart(15), binWidth(1)))), shape.interior(shape.square)) PAGE: end() END GPL. *Tough to do all three in the same plot, easier with just the curves. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=X Num /GRAPHSPEC SOURCE=INLINE /FRAME INNER=YES. BEGIN GPL PAGE: begin(scale(600px,500px)) SOURCE: s=userSource(id("graphdataset")) DATA: X=col(source(s), name("X")) DATA: Num=col(source(s), name("Num"), unit.category()) GUIDE: axis(dim(1)) GUIDE: axis(dim(2), label("Frequency")) GUIDE: axis(dim(4), opposite()) ELEMENT: interval(position(summary.count(bin.rect(X, binStart(15), binWidth(1)))), shape.interior(shape.square), color.interior(Num), transparency.interior(transparency."0.5")) PAGE: end() 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 |