Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Applying Curve Estimation Repeatedly

6 views
Skip to first unread message

Allen

unread,
Nov 29, 2009, 4:08:25 PM11/29/09
to
Any help would be appreciated. I want to use the curve estimation
function below and have approxiamately 154 variables to apply it to
but I don't want to have to manually change var1 to var2 to var3,
etc. I know it can be done using a repeat, loop and\or macro or some
combination thereof, but I am at a loss. Any help would be
appreciated.

Thanks.

* Curve Estimation.
TSET MXNEWVAR=1.
PREDICT THRU 30.
CURVEFIT
/VARIABLES=VAR1
/CONSTANT
/MODEL=LINEAR
/PLOT FIT
/SAVE=PRED .

Bruce Weaver

unread,
Nov 29, 2009, 6:18:10 PM11/29/09
to

I don't have SPSS on this machine, so the following is untested.

* Put the syntax inside a macro that takes a list of variables .

DEFINE !MYFIT (VLIST = !CMDEND )
!DO !V !IN (!VLIST)


* Curve Estimation.
TSET MXNEWVAR=1.
PREDICT THRU 30.
CURVEFIT

/VARIABLES=!V


/CONSTANT
/MODEL=LINEAR
/PLOT FIT
/SAVE=PRED .

!DOEND
!ENDDEFINE.

* Now call the macro .

set mprint on . /* at least while testing the macro .
!MYFIT v = var1 var2 var3 .
set mprint off.


There may be a limit on the number of variables that you can hand
to the macro in one go. If there is, just split up the variables
into a few lists, and call it more than once.

--
Bruce Weaver
bwe...@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."

Allen

unread,
Nov 29, 2009, 8:03:03 PM11/29/09
to
> bwea...@lakeheadu.cahttp://sites.google.com/a/lakeheadu.ca/bweaver/
> "When all else fails, RTFM."- Hide quoted text -
>
> - Show quoted text -

I am just not getting this, where do I define my list of variables or
more importantly how do I define them "var1 to var154"? Evidently the
"To" is a no no.

Thanks,
AH

Bruce Weaver

unread,
Nov 29, 2009, 8:38:58 PM11/29/09
to

In that version of the macro, you have to hand the macro the
variables. But if you want "var1 to var154", a different approach
would be better. Something like the following should work. But
again, bear in mind I don't have SPSS on this machine to test it.


DEFINE !MYFIT ()
!DO !I = 1 !TO 154


* Curve Estimation.
TSET MXNEWVAR=1.
PREDICT THRU 30.
CURVEFIT

/VARIABLES= !CONCAT("Var",!I)


/CONSTANT
/MODEL=LINEAR
/PLOT FIT
/SAVE=PRED .
!DOEND
!ENDDEFINE.

* Call the macro.

!MYFIT.

--
Bruce Weaver
bwe...@lakeheadu.ca

vab

unread,
Nov 30, 2009, 9:41:20 AM11/30/09
to

I don't think a macro here--just specify the variables on the CURVEFIT
command where one can use the TO command. Note that there may be a
limit on the number of variables allowed. In that case, just use more
than one CURVEFIT command.

Bruce Weaver

unread,
Nov 30, 2009, 4:18:26 PM11/30/09
to
On Nov 30, 9:41 am, vab <vab88...@gmail.com> wrote:

> I don't think a macro here--just specify the variables on the CURVEFIT
> command where one can use the TO command. Note that there may be a
> limit on the number of variables allowed. In that case, just use more
> than one CURVEFIT command.


I'm back on a machine that has SPSS, and can confirm that CURVEFIT
will take more than one variable using TO as a keyword. Thanks for
the heads-up ViAnn. I can't find anything in the syntax chart or the
examples that show this explicitly though, nor can I find anything
saying whether there is a limit on the number of variables. So I
guess it's an empirical question for the OP--try it and see what
happens. ;-)

--
Bruce Weaver
bwe...@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home

Allen

unread,
Dec 1, 2009, 10:51:41 PM12/1/09
to
On Nov 30, 4:18 pm, Bruce Weaver <bwea...@lakeheadu.ca> wrote:
> On Nov 30, 9:41 am, vab <vab88...@gmail.com> wrote:
>
> > I don't think a macro here--just specify the variables on the CURVEFIT
> > command where one can use the TO command. Note that there may be a
> > limit on the number of variables allowed. In that case, just use more
> > than one CURVEFIT command.
>
> I'm back on a machine that has SPSS, and can confirm that CURVEFIT
> will take more than one variable using TO as a keyword.  Thanks for
> the heads-up ViAnn.  I can't find anything in the syntax chart or the
> examples that show this explicitly though, nor can I find anything
> saying whether there is a limit on the number of variables.  So I
> guess it's an empirical question for the OP--try it and see what
> happens.  ;-)
>
> --
> Bruce Weaver
> bwea...@lakeheadu.cahttp://sites.google.com/a/lakeheadu.ca/bweaver/Home

> "When all else fails, RTFM."

Mr. Weaver's macro is still cool. But knowing that "TO" would have
worked would have saved much, in any event "props" to Mr. Weaver and
VAB. Although, the "TO" works, if you want a forecast a period or two
into the future, it appears you need to change the "TSET MXNEWVAR=1."
statement from 1 to however many variables you want to "Curvefit"
on.

0 new messages