actual line graph with fitted trend line

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

actual line graph with fitted trend line

s_pushparaj
Dear list
I am running a linear regression for a time series. I wish to draw graph of actual and fitted line graph for the same in one graph. i.e actual line graph with fitted trend line. Kindly help me draw the same.
with thanks
pushparaj

====================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
Reply | Threaded
Open this post in threaded view
|

Re: actual line graph with fitted trend line

ViAnn Beadle
If this is a simple linear regression with one predictor which is just
yourpredvar number, you can use CURVEFIT:

CURVEFIT
  /VARIABLES=yourdepvar
  /CONSTANT
  /MODEL=LINEAR
  /PLOT FIT.

Or you can use GGRAPH to compute and plot the regression:

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=yourpredvar yourdepvar
    MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: X=col(source(s), name("yourpredvar"))
  DATA: Y=col(source(s), name("yourdepvar"))
  GUIDE: axis(dim(1), label("yourpredvar"))
  GUIDE: axis(dim(2), label("yourdepvar"))
  ELEMENT: line(position(X*Y), missing.wings(), color("observed"))
  ELEMENT: line(position(smooth.linear(X*Y)), missing.wings(),
color("predicted"))
END GPL.

If you have already used regression and saved the predictor values, you can
also use the GGRAPH command.

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=yourpredvar yourdepvar
predictedvaluevar
    MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: yourpredvar=col(source(s), name("yourpredvar"))
  DATA: Y1=col(source(s), name("yourdepvar"))
  DATA: Y2=col(source(s), name("predictedvaluevar"))
  GUIDE: axis(dim(1), label("yourpredvar"))
  GUIDE: axis(dim(2), label("yourpredvar"))
  ELEMENT: line(position(yourpredvar*Y1), missing.wings(),
color("observed"))
  ELEMENT: line(position(yourpredvar*Y2), missing.wings(),
color("predicted"))
END GPL.


Change the variable names to match your variable names. Go to Help>Base
System>GPL Reference to understand what statements inside the BEGIN GPL--END
GPL block do.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
s_pushparaj
Sent: Saturday, April 12, 2008 8:18 PM
To: [hidden email]
Subject: actual line graph with fitted trend line

Dear list
I am running a linear regression for a time series. I wish to draw graph of
actual and fitted line graph for the same in one graph. i.e actual line
graph with fitted trend line. Kindly help me draw the same.
with thanks
pushparaj

=======
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