graphing the prediction interval from a weighted regression model

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

graphing the prediction interval from a weighted regression model

Kylie

Hi all,

 

I’m using weighted least squares regression to estimate a simple regression model between two variables. I wish to plot the 95% (individual) prediction interval on a scatterplot. I had planned to create some dummy cases at regular intervals of the x variable (to cover the range of the axis that I wish to plot) but that are missing for the y variable (so they don’t get included in the regression estimation), then run the REGRESSION saving the upper/lower limits. REGRESSION saves the limits for all cases in the data file, even those not included in the model, so this was always a nice trick to get values for graphing.

 

However, REGRESSION doesn’t seem to save these prediction intervals back to the data file when the analysis is weighted (/REGWGT). Only the original cases receive saved values and my dummy cases do not. Does anyone know of another way to get a smooth plot of the prediction intervals for a weighted regression model?

 

Thanks,

Kylie.

 

===================== 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: graphing the prediction interval from a weighted regression model

Andy W
Works for me. You of course need both the weights and the right hand side variables non-missing.


*****************************************.
INPUT PROGRAM.
LOOP X = 1 TO 150.
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
DATASET NAME Sim.
COMPUTE Wgt = 1/X.
DO IF X < 101.
  COMPUTE Y = 5 + 3*X + RV.NORMAL(0,1)*(1/Wgt).
END IF.
EXECUTE.

REGRESSION
  /MISSING LISTWISE
  /REGWGT=Wgt
  /STATISTICS COEFF OUTS R ANOVA
  /CRITERIA=PIN(.05) POUT(.10) CIN(95)
  /NOORIGIN
  /DEPENDENT Y
  /METHOD=ENTER X
  /SAVE ICIN.

*Scatterplot with the prediction intervals extended outward.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=X Y LICI_1 UICI_1 MISSING=VARIABLEWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: X=col(source(s), name("X"))
  DATA: Y=col(source(s), name("Y"))
  DATA: LICI_1=col(source(s), name("LICI_1"))
  DATA: UICI_1=col(source(s), name("UICI_1"))
  GUIDE: axis(dim(1), label("X"))
  GUIDE: axis(dim(2), label("Y"))
  ELEMENT: point(position(X*Y))
  ELEMENT: line(position(X*LICI_1))
  ELEMENT: line(position(X*UICI_1))
END GPL.
*****************************************.
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: graphing the prediction interval from a weighted regression model

Kylie
Thanks for taking a look Andy. It is indeed working for me today. I'm not sure what I was doing wrong, but no doubt it was "user error"!

Kylie.


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Andy W
Sent: Tuesday, 20 October 2015 10:11 PM
To: [hidden email]
Subject: Re: graphing the prediction interval from a weighted regression model

Works for me. You of course need both the weights and the right hand side
variables non-missing.


*****************************************.
INPUT PROGRAM.
LOOP X = 1 TO 150.
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
DATASET NAME Sim.
COMPUTE Wgt = 1/X.
DO IF X < 101.
  COMPUTE Y = 5 + 3*X + RV.NORMAL(0,1)*(1/Wgt).
END IF.
EXECUTE.

REGRESSION
  /MISSING LISTWISE
  /REGWGT=Wgt
  /STATISTICS COEFF OUTS R ANOVA
  /CRITERIA=PIN(.05) POUT(.10) CIN(95)
  /NOORIGIN
  /DEPENDENT Y
  /METHOD=ENTER X
  /SAVE ICIN.

*Scatterplot with the prediction intervals extended outward.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=X Y LICI_1 UICI_1
MISSING=VARIABLEWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: X=col(source(s), name("X"))
  DATA: Y=col(source(s), name("Y"))
  DATA: LICI_1=col(source(s), name("LICI_1"))
  DATA: UICI_1=col(source(s), name("UICI_1"))
  GUIDE: axis(dim(1), label("X"))
  GUIDE: axis(dim(2), label("Y"))
  ELEMENT: point(position(X*Y))
  ELEMENT: line(position(X*LICI_1))
  ELEMENT: line(position(X*UICI_1))
END GPL.
*****************************************.



-----
Andy W
[hidden email]
http://andrewpwheeler.wordpress.com/
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/graphing-the-prediction-interval-from-a-weighted-regression-model-tp5730792p5730796.html
Sent from the SPSSX Discussion mailing list archive at 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