|
Dear SPSS-experts,
I would like to fit 2 linear regression curves into part of my scatter plots. y=(cont.variable) x=age then I have gender as categorial variable, i.e. 2 regression lines. How can I fit a regression line of part of the x-axis (e.g. from age... to age...), i.e. for an interval of x-values only. Is this possible with SPSS (15.0 for Windows) at all?? Can anyone help? Samuel ===================== 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 |
|
Quoting Samuel Groeschel <[hidden email]>:
> I would like to fit 2 linear regression curves into part of my > scatter plots. There are at least three possible approaches. The first is to introduce a weight variable, so that your cases that are to be fitted are weighted 1.0 and the others are weighted 0.0 (but occasionally zero weights are not treated by SPSS as you might wish, and in this case weights of 0.000001 may be more useful). The second approach is to use multiple regression, and to use dummy variables with values 1.0 and 0.0 to separate the different parts of your regression. This allows the two parts to have different constant terms. The third approach may create two new independent variables from one of your original ones. The first has the same values as your original variable for one set of cases, and zero for the other set. The second has zeroes and copies of the values of the original variable for the other set. This permits you to have two different regression slopes. Of course you can use approaches two and three together, so that your different sets of cases are fitted with different slope and constant terms. In order to get the required scatter plots you may choose to use overlay plots which include not only the original variables, but also the fitted values from the regression. Tricks of this kind allow you to create many kinds of plots of the kind that you have mentioned - with SPSS 15.0 for Windows, and virtually all other versions of SPSS. ===================== 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 |
|
In reply to this post by Samuel Groeschel
Can you not filter the x values going into the plot with either FILTER or
SELECT IF? Note that you can get scatterplots with regression lines using GGRAPH or add fitlines to a grouped scatterplot created from the GRAPH command within the chart editor. Here's a example using GGRAPH in which I've filtered out jobtime less than 70 and age greater than 80 using the Employee Data sample file. USE ALL. COMPUTE filter_$=(jobtime > 70 & jobtime <= 80). VARIABLE LABEL filter_$ 'jobtime > 70 & jobtime <= 80 (FILTER)'. VALUE LABELS filter_$ 0 'Not Selected' 1 'Selected'. FORMAT filter_$ (f1.0). FILTER BY filter_$. * Chart Builder. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=jobtime salary gender MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: jobtime=col(source(s), name("jobtime")) DATA: salary=col(source(s), name("salary")) DATA: gender=col(source(s), name("gender"), unit.category()) GUIDE: axis(dim(1), label("Months since Hire")) GUIDE: axis(dim(2), label("Current Salary")) GUIDE: legend(aesthetic(aesthetic.color.exterior), label("Gender")) SCALE: cat(aesthetic(aesthetic.color.exterior), include("f", "m")) ELEMENT: point(position(jobtime*salary), color(gender)) ELEMENT: line(position(smooth.linear(jobtime*salary)), color(gender)) END GPL. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Samuel Groeschel Sent: Friday, February 01, 2008 9:18 AM To: [hidden email] Subject: regression line in part of scatter plot?? Dear SPSS-experts, I would like to fit 2 linear regression curves into part of my scatter plots. y=(cont.variable) x=age then I have gender as categorial variable, i.e. 2 regression lines. How can I fit a regression line of part of the x-axis (e.g. from age... to age...), i.e. for an interval of x-values only. Is this possible with SPSS (15.0 for Windows) at all?? Can anyone help? Samuel ===================== 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 |
|
Thanks for your answers. I realised, however, that I was not clear enough
in describing my problem. I need a scatterplot from all the data with a fitted line from part of the data (age range) in the same graph within the scatterplot. I will try the tricky solution with the multiple regression approach but I do not know yet how to overlay the various scatterplots and plot a line within these scatters. While I am trying I still hope for an easier solution... Regards > Can you not filter the x values going into the plot with either FILTER or > SELECT IF? Note that you can get scatterplots with regression lines using > GGRAPH or add fitlines to a grouped scatterplot created from the GRAPH > command within the chart editor. Here's a example using GGRAPH in which > I've > filtered out jobtime less than 70 and age greater than 80 using the > Employee > Data sample file. > > USE ALL. > COMPUTE filter_$=(jobtime > 70 & jobtime <= 80). > VARIABLE LABEL filter_$ 'jobtime > 70 & jobtime <= 80 (FILTER)'. > VALUE LABELS filter_$ 0 'Not Selected' 1 'Selected'. > FORMAT filter_$ (f1.0). > FILTER BY filter_$. > > * Chart Builder. > GGRAPH > /GRAPHDATASET NAME="graphdataset" VARIABLES=jobtime salary gender > MISSING=LISTWISE > REPORTMISSING=NO > /GRAPHSPEC SOURCE=INLINE. > BEGIN GPL > SOURCE: s=userSource(id("graphdataset")) > DATA: jobtime=col(source(s), name("jobtime")) > DATA: salary=col(source(s), name("salary")) > DATA: gender=col(source(s), name("gender"), unit.category()) > GUIDE: axis(dim(1), label("Months since Hire")) > GUIDE: axis(dim(2), label("Current Salary")) > GUIDE: legend(aesthetic(aesthetic.color.exterior), label("Gender")) > SCALE: cat(aesthetic(aesthetic.color.exterior), include("f", "m")) > ELEMENT: point(position(jobtime*salary), color(gender)) > ELEMENT: line(position(smooth.linear(jobtime*salary)), color(gender)) > END GPL. > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > Samuel Groeschel > Sent: Friday, February 01, 2008 9:18 AM > To: [hidden email] > Subject: regression line in part of scatter plot?? > > Dear SPSS-experts, > > I would like to fit 2 linear regression curves into part of my scatter > plots. > > y=(cont.variable) > x=age > then I have gender as categorial variable, i.e. 2 regression lines. > > How can I fit a regression line of part of the x-axis (e.g. from age... to > age...), i.e. for an interval of x-values only. > > Is this possible with SPSS (15.0 for Windows) at all?? > > Can anyone help? > > Samuel > > ===================== > 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 > ===================== 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 |
|
In reply to this post by Samuel Groeschel
Samuel,
I can sympathize with your problem. There have been several times I've wanted a simple graph just to get a visual idea of what was happening with the data. I don't have the command syntax manual in front of me, but it seems there ought to be a fairly simple subcommand to get a scatterplot and line for both regression and correlations. REGRESSION VARIABLES age height weight/ DEPENDENT weight/ SCATTERPLOT ALL/ LINE. COMMENT produces three scatterplots and lines: age-weight, age-height, height-weight. CORRELATIONS VARIABLES age WITH weight height/ STATISTICS ALL/ SCATTERPLOT ALL/ LINE ALL. COMMENT produces two scatterplots and lines: age-weight, age-height. / Larry / LARRY L. BURRISS, Ph.D., J.D. Professor, School of Journalism Middle Tennessee State University Murfreesboro, TN 37132 615-898-2983 [hidden email] http://www.mtsu.edu/~lburriss ***** This page made of 100% recycled electrons ***** ---- Original message ---- >Date: Fri, 1 Feb 2008 21:23:52 -0000 >From: Samuel Groeschel <[hidden email]> >Subject: Re: regression line in part of scatter plot?? >To: [hidden email] > >Thanks for your answers. I realised, however, that I was not clear enough >in describing my problem. > >I need a scatterplot from all the data with a fitted line from part of the >data (age range) in the same graph within the scatterplot. > >I will try the tricky solution with the multiple regression approach but I >do not know yet how to overlay the various scatterplots and plot a line >within these scatters. While I am trying I still hope for an easier >solution... > >Regards > >> Can you not filter the x values going into the plot with either FILTER or >> SELECT IF? Note that you can get scatterplots with regression lines using >> GGRAPH or add fitlines to a grouped scatterplot created from the GRAPH >> command within the chart editor. Here's a example using GGRAPH in which >> I've >> filtered out jobtime less than 70 and age greater than 80 using the >> Employee >> Data sample file. >> >> USE ALL. >> COMPUTE filter_$=(jobtime > 70 & jobtime <= 80). >> VARIABLE LABEL filter_$ 'jobtime > 70 & jobtime <= 80 (FILTER)'. >> VALUE LABELS filter_$ 0 'Not Selected' 1 'Selected'. >> FORMAT filter_$ (f1.0). >> FILTER BY filter_$. >> >> * Chart Builder. >> GGRAPH >> /GRAPHDATASET NAME="graphdataset" VARIABLES=jobtime salary gender >> MISSING=LISTWISE >> REPORTMISSING=NO >> /GRAPHSPEC SOURCE=INLINE. >> BEGIN GPL >> SOURCE: s=userSource(id("graphdataset")) >> DATA: jobtime=col(source(s), name("jobtime")) >> DATA: salary=col(source(s), name("salary")) >> DATA: gender=col(source(s), name("gender"), unit.category()) >> GUIDE: axis(dim(1), label("Months since Hire")) >> GUIDE: axis(dim(2), label("Current Salary")) >> GUIDE: legend(aesthetic(aesthetic.color.exterior), label("Gender")) >> SCALE: cat(aesthetic(aesthetic.color.exterior), include("f", "m")) >> ELEMENT: point(position(jobtime*salary), color(gender)) >> ELEMENT: line(position(smooth.linear(jobtime*salary)), color(gender)) >> END GPL. >> >> -----Original Message----- >> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of >> Samuel Groeschel >> Sent: Friday, February 01, 2008 9:18 AM >> To: [hidden email] >> Subject: regression line in part of scatter plot?? >> >> Dear SPSS-experts, >> >> I would like to fit 2 linear regression curves into part of my scatter >> plots. >> >> y=(cont.variable) >> x=age >> then I have gender as categorial variable, i.e. 2 regression lines. >> >> How can I fit a regression line of part of the x-axis (e.g. from age... to >> age...), i.e. for an interval of x-values only. >> >> Is this possible with SPSS (15.0 for Windows) at all?? >> >> Can anyone help? >> >> Samuel >> >> ===================== >> 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 >> > >===================== >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 |
