Next: putascii() Up: MacAnova Help File Previous: prod()   Contents

pushmodel()

Usage:
pushmodel()
pushmodel(canpush:T)



Keywords: anova, glm, multivariate analysis, regression, residuals
All GLM commands except screen(), for example regress() and anova(),
retain information (GLM information) internally for use by certain
functions such as coefs() and modelinfo() that provide results from the
most recent GLM command.  When a GLM command is run, information from
the previous GLM command, if any, is replaced.  When the GLM command is
in a macro, this may confuse the user who may expect that coefs(), say,
gives the same answer after the macro is used as before.

Commands pushmodel() and popmodel() allow a macro to save and restore
the current GLM information.

pushmodel() saves the current GLM information so that it can
subsequently be restored by popmodel().  Until a new GLM command has
been run or GLM information has been restored by popmodel(), there is no
GLM information available to commands such as secoefs() and modelinfo().

After the next prompt following the use of pushmodel(), the active model
before the first use of pushmodel() is restored (equivalent to an
automatic execution of popmodel(all:T)).

pushmodel() and popmodel() are intended to be used in macros.  A macro
can run pushmodel() before a GLM command and then run popmodel() before
finishing to ensure that the current GLM information is not changed.  Of
course, if the purpose of the macro is to change the information, it
should not use pushmodel() and popmodel().

The default maximum number of sets of GLM information that can be saved
is 2 (0 in limited memory DOS version).  On versions allowing command
line arguments you can change the default by '-savemodels N' where N >=
0 is an integer.  See 'launching'.

pushmodel() saves the current GLM information from the most recent GLM
command.  Until a subsequent GLM command or popmodel() has been run, or
a new prompt is printed, no model information is available for retrieval
by functions like secoefs() and modelinfo().  You can use popmodel() to
restore the saved GLM information.

It is an error if there is no current model to save or you have already
saved the maximum number of models (default is 2).

pushmodel(canpush:T) returns True if there is current GLM information to
save and a place to put it and False otherwise.  No GLM information is
saved and the current GLM information, if any, is not changed.

Here is the text of a macro aov() which returns the SS and DF of an
analysis of variance without changing the current GLM information or
side effect variables, if any.

  if (pushmodel(canpush:T)){pushmodel()}
  anova($1, silent:T)
  @result <- structure(SS,DF)
  if (popmodel(canpop:T)){popmodel()}
  @result #will be returned as value of the macro

This might be used as follows"

  Cmd> aov("y=a") # this won't change GLM info or side effect variables
  component: SS
      CONSTANT           a      ERROR1
        3.8646    0.021371      4.8536
  component: DF
      CONSTANT           a      ERROR1
             1           2           7

See also popmodel(), modelinfo(), coefs(), secoefs(), contrast(),
'macros'.


Gary Oehlert 2003-01-15