home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 21 / CD_ASCQ_21_040595.iso / dos / educ / nlreg33 / nlreg.doc < prev    next >
Text File  |  1995-01-10  |  180KB  |  3,605 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.                                     N L R E G
  7.  
  8.  
  9.  
  10.                       Nonlinear Regression Analysis Program
  11.  
  12.  
  13.  
  14.                                Phillip H. Sherrod
  15.  
  16.               Member, Association of Shareware Professionals (ASP)
  17.  
  18.  
  19.  
  20.             NLREG  allows  you  to  perform  statistical   regression
  21.             analyses   to  estimate  the  values  of  parameters  for
  22.             linear, multivariate, polynomial, logistic,  exponential,
  23.             and   general   nonlinear   functions.    The  regression
  24.             analysis determines the values of  the  parameters  which
  25.             cause  the  function  to  best fit the observed data that
  26.             you  provide.   This  process  is  also   called   "curve
  27.             fitting."
  28.  
  29.             NLREG   allows   you   to   specify  the  function  whose
  30.             parameters are being estimated using  ordinary  algebraic
  31.             notation.   In  addition  to  determining  the  parameter
  32.             estimates, NLREG can be directed to  generate  an  output
  33.             file  with  predicted  values and residuals.  It can also
  34.             plot the data observations  and  the  computed  function.
  35.             Although  designed  for  regression  analysis,  NLREG can
  36.             also be used to find the root  (zero  point)  or  minimum
  37.             absolute  value  of  a nonlinear expression.  NLREG is in
  38.             use at many engineering and research centers  around  the
  39.             world.
  40.  
  41.  
  42.  
  43.  
  44.  
  45.                                 Table of Contents
  46.  
  47.  
  48.  
  49.        1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 1
  50.          1.1 Introduction to Regression Analysis . . . . . . . . . . . . 1
  51.          1.2 Introduction to NLREG . . . . . . . . . . . . . . . . . . . 2
  52.          1.3 Installing NLREG  . . . . . . . . . . . . . . . . . . . . . 4
  53.  
  54.        2. Using NLREG  . . . . . . . . . . . . . . . . . . . . . . . . . 5
  55.          2.1 Statement Syntax  . . . . . . . . . . . . . . . . . . . . . 6
  56.          2.2 Variables and Parameters  . . . . . . . . . . . . . . . . . 6
  57.          2.3 Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
  58.          2.4 Overview of Computation Process . . . . . . . . . . . . . . 8
  59.          2.5 Function Specification  . . . . . . . . . . . . . . . . . . 9
  60.            2.5.1 Arithmetic Operators  . . . . . . . . . . . . . . . . . 9
  61.            2.5.2 Numeric Constants . . . . . . . . . . . . . . . . . .  10
  62.            2.5.3 Symbolic Constants  . . . . . . . . . . . . . . . . .  11
  63.            2.5.4 Built-in Constant . . . . . . . . . . . . . . . . . .  11
  64.            2.5.5 Built-in Functions  . . . . . . . . . . . . . . . . .  11
  65.          2.6 NLREG Command Files . . . . . . . . . . . . . . . . . . .  15
  66.          2.7 Comments  . . . . . . . . . . . . . . . . . . . . . . . .  16
  67.          2.8 Include Files . . . . . . . . . . . . . . . . . . . . . .  16
  68.          2.9 Required Statements . . . . . . . . . . . . . . . . . . .  17
  69.  
  70.        3. NLREG Statements . . . . . . . . . . . . . . . . . . . . . .  18
  71.          3.1 TITLE . . . . . . . . . . . . . . . . . . . . . . . . . .  18
  72.          3.2 VARIABLES . . . . . . . . . . . . . . . . . . . . . . . .  18
  73.          3.3 PARAMETERS  . . . . . . . . . . . . . . . . . . . . . . .  18
  74.          3.4 DOUBLE  . . . . . . . . . . . . . . . . . . . . . . . . .  19
  75.          3.5 CONSTANT  . . . . . . . . . . . . . . . . . . . . . . . .  20
  76.          3.6 CONSTRAIN . . . . . . . . . . . . . . . . . . . . . . . .  20
  77.          3.7 SWEEP . . . . . . . . . . . . . . . . . . . . . . . . . .  21
  78.          3.8 FUNCTION  . . . . . . . . . . . . . . . . . . . . . . . .  21
  79.          3.9 CORRELATE . . . . . . . . . . . . . . . . . . . . . . . .  22
  80.          3.10 COVARIANCE . . . . . . . . . . . . . . . . . . . . . . .  22
  81.          3.11 CONFIDENCE . . . . . . . . . . . . . . . . . . . . . . .  22
  82.          3.12 TOLERANCE  . . . . . . . . . . . . . . . . . . . . . . .  23
  83.          3.13 ITERATIONS . . . . . . . . . . . . . . . . . . . . . . .  23
  84.          3.14 ANGLETYPE  . . . . . . . . . . . . . . . . . . . . . . .  23
  85.          3.15 OUTPUT . . . . . . . . . . . . . . . . . . . . . . . . .  24
  86.          3.16 POUTPUT  . . . . . . . . . . . . . . . . . . . . . . . .  24
  87.          3.17 PLOT . . . . . . . . . . . . . . . . . . . . . . . . . .  24
  88.          3.18 SPLOT  . . . . . . . . . . . . . . . . . . . . . . . . .  26
  89.          3.19 RPLOT  . . . . . . . . . . . . . . . . . . . . . . . . .  28
  90.          3.20 NPLOT  . . . . . . . . . . . . . . . . . . . . . . . . .  30
  91.          3.21 PRESOLUTION  . . . . . . . . . . . . . . . . . . . . . .  31
  92.          3.22 WIDTH  . . . . . . . . . . . . . . . . . . . . . . . . .  31
  93.          3.23 NOECHO . . . . . . . . . . . . . . . . . . . . . . . . .  32
  94.          3.24 Assignment Statement . . . . . . . . . . . . . . . . . .  32
  95.          3.25 IF Statement . . . . . . . . . . . . . . . . . . . . . .  32
  96.  
  97.  
  98.                                         i
  99.  
  100.        Contents                                                         ii
  101.  
  102.  
  103.          3.26 WHILE Statement  . . . . . . . . . . . . . . . . . . . .  33
  104.          3.27 DO Statement . . . . . . . . . . . . . . . . . . . . . .  33
  105.          3.28 FOR Statement  . . . . . . . . . . . . . . . . . . . . .  34
  106.          3.29 BREAK Statement  . . . . . . . . . . . . . . . . . . . .  34
  107.          3.30 CONTINUE Statement . . . . . . . . . . . . . . . . . . .  35
  108.          3.31 STOP Statement . . . . . . . . . . . . . . . . . . . . .  35
  109.          3.32 DATA . . . . . . . . . . . . . . . . . . . . . . . . . .  35
  110.  
  111.        4. Understanding The Results  . . . . . . . . . . . . . . . . .  37
  112.          4.1 Descriptive Statistics for Variables  . . . . . . . . . .  37
  113.          4.2 Parameter Estimates . . . . . . . . . . . . . . . . . . .  37
  114.          4.3 t Statistic . . . . . . . . . . . . . . . . . . . . . . .  37
  115.          4.4 Prob(t) . . . . . . . . . . . . . . . . . . . . . . . . .  38
  116.          4.5 Final Sum of Squared Deviations . . . . . . . . . . . . .  38
  117.          4.6 Average and Maximum Deviation . . . . . . . . . . . . . .  38
  118.          4.7 Proportion of Variance Explained  . . . . . . . . . . . .  39
  119.          4.8 Adjusted Coefficient of Multiple Determination  . . . . .  39
  120.          4.9 Durbin-Watson Statistic . . . . . . . . . . . . . . . . .  39
  121.          4.10 Analysis of Variance Table . . . . . . . . . . . . . . .  41
  122.            4.10.1 F Value and Prob(F)  . . . . . . . . . . . . . . . .  41
  123.          4.11 Correlation Matrix . . . . . . . . . . . . . . . . . . .  41
  124.  
  125.        5. Theory of Operation  . . . . . . . . . . . . . . . . . . . .  43
  126.          5.1 Minimization Algorithm  . . . . . . . . . . . . . . . . .  43
  127.          5.2 Convergence Criterion . . . . . . . . . . . . . . . . . .  43
  128.  
  129.        6. Hints for NLREG Use  . . . . . . . . . . . . . . . . . . . .  45
  130.          6.1 Convergence Failures  . . . . . . . . . . . . . . . . . .  45
  131.          6.2 Singular Matrix Problems  . . . . . . . . . . . . . . . .  46
  132.          6.3 Performance Issues  . . . . . . . . . . . . . . . . . . .  47
  133.          6.4 Program Limits  . . . . . . . . . . . . . . . . . . . . .  47
  134.  
  135.        7. Example Analyses . . . . . . . . . . . . . . . . . . . . . .  48
  136.  
  137.        8. Special Applications . . . . . . . . . . . . . . . . . . . .  52
  138.          8.1 Omitted Dependent Variable  . . . . . . . . . . . . . . .  52
  139.          8.2 Root Finding and Expression Minimization  . . . . . . . .  53
  140.            8.2.1 Function Minimization Examples  . . . . . . . . . . .  55
  141.  
  142.        9. Acknowledgement and Use of NLREG . . . . . . . . . . . . . .  56
  143.          9.1 Acknowledgement . . . . . . . . . . . . . . . . . . . . .  56
  144.          9.2 Use and Distribution of NLREG . . . . . . . . . . . . . .  56
  145.          9.3 Association of Shareware Professionals  . . . . . . . . .  57
  146.          9.4 Copyright Notice  . . . . . . . . . . . . . . . . . . . .  57
  147.          9.5 Disclaimer  . . . . . . . . . . . . . . . . . . . . . . .  57
  148.  
  149.        10. Other Software  . . . . . . . . . . . . . . . . . . . . . .  59
  150.          10.1 Mathplot -- Mathematical Function Plotting Program . . .  59
  151.          10.2 TSX-32 -- Multi-User Operating System  . . . . . . . . .  59
  152.          10.3 SIMSTAT -- Interactive Statistics Program  . . . . . . .  60
  153.  
  154.        11. Software Order Form . . . . . . . . . . . . . . . . . . . .  61
  155.  
  156.        Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  62
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.                                     Chapter 1
  164.  
  165.                                   Introduction
  166.  
  167.  
  168.  
  169.  
  170.        1.1 Introduction to Regression Analysis
  171.  
  172.        The  goal  of  regression  analysis  is  to determine the values of
  173.        parameters for a function that cause the function  to  best  fit  a
  174.        set  of  data observations that you provide.  In linear regression,
  175.        the function is a linear (straight line)  equation.   For  example,
  176.        if  we  assume  the  value of an automobile decreases by a constant
  177.        amount each year after its purchase, and for each mile driven,  the
  178.        following  linear  function  would predict its value (the dependent
  179.        variable on the left side of the equal sign) as a function  of  the
  180.        two independent variables which are age and miles:
  181.  
  182.             value = price + depage*age + depmiles*miles
  183.  
  184.        where  'value',  the  dependent  variable, is the value of the car,
  185.        'age' is the age of the car, and 'miles' is  the  number  of  miles
  186.        that the car has been driven.
  187.  
  188.        The  regression analysis performed by NLREG will determine the best
  189.        values of the three parameters, 'price', the estimated  value  when
  190.        age  is  0 (i.e., when the car was new), 'depage', the depreciation
  191.        that takes place each year, and 'depmiles',  the  depreciation  for
  192.        each  mile  driven.   The values of 'depage' and 'depmiles' will be
  193.        negative because the car loses value as age and miles increase.
  194.  
  195.        In a problem such  as  this  car  depreciation  example,  you  must
  196.        provide  a  data  file  containing  the values of the dependent and
  197.        independent variables for a set of observations.  In  this  example
  198.        each  observation  record  would contain three numbers: value, age,
  199.        and miles, collected from used car ads  for  the  same  model  car.
  200.        The  more  observations  you provide, the more accurate will be the
  201.        estimate of the parameters.  The NLREG statements to  perform  this
  202.        regression are shown below:
  203.  
  204.             Variables value,age,miles;
  205.             Parameters price,depage,depmiles;
  206.             Function value = price + depage*age + depmiles*miles;
  207.             Data;
  208.             (data values go here)
  209.  
  210.        Once  the values of the parameters are determined by NLREG, you can
  211.        use the formula to predict the value of a car based on its age  and
  212.  
  213.  
  214.  
  215.                                         1
  216.  
  217.        Chapter 1. Introduction                                           2
  218.  
  219.  
  220.        miles  driven.  For example, if NLREG computed a value of 16000 for
  221.        price, -1000 for depage, and -0.15 for depmiles, then the function
  222.  
  223.             value = 16000 - 1000*age - 0.15*miles
  224.  
  225.        could be used to estimate the value of a car with a known  age  and
  226.        number of miles.
  227.  
  228.        If  a perfect fit existed between the function and the actual data,
  229.        the actual value of each car in your data file would exactly  equal
  230.        the  predicted  value.   Typically,  however, this is not the case,
  231.        and the difference  between  the  actual  value  of  the  dependent
  232.        variable  and  its  predicted value for a particular observation is
  233.        the error of the estimate which is  known  as  the  "deviation"  or
  234.        "residual".   The  goal  of regression analysis is to determine the
  235.        values of the parameters which minimize  the  sum  of  the  squared
  236.        residual  values  for  the set of observations.  This is known as a
  237.        "least squares" regression fit.
  238.  
  239.        1.2 Introduction to NLREG
  240.  
  241.        NLREG is a very powerful regression  analysis  program.   Using  it
  242.        you  can  perform  multivariate,  linear,  polynomial, exponential,
  243.        logistic, and general nonlinear regression.   What  this  means  is
  244.        that  you  specify  the  form  of  the function to be fitted to the
  245.        data,  and  the  function  may  include  nonlinear  terms  such  as
  246.        variables  raised  to  powers  and  library  functions such as log,
  247.        exponential, sine, etc.  For complex analyses NLREG allows  you  to
  248.        specify  function  models  using conditional statements (IF, ELSE),
  249.        looping (FOR, DO, WHILE), work variables, and arrays.   NLREG  uses
  250.        a  state-of-the-art  regression  algorithm  that  works as well, or
  251.        better, than any you are likely to find in  commercial  statistical
  252.        packages.
  253.  
  254.        As   an   example   of   nonlinear   regression,  consider  another
  255.        depreciation problem.  The value of a used airplane  decreases  for
  256.        each  year  of its age.  Assuming the value of a plane falls by the
  257.        same amount each year, a linear function relating value to age is:
  258.  
  259.             value = p0 + p1*Age
  260.  
  261.        Where 'p0' and 'p1' are the  parameters  whose  values  are  to  be
  262.        determined.   However,  it  is  a  well known fact that planes (and
  263.        automobiles) lose more value the first year than  the  second,  and
  264.        more  the  second  than  the  third, etc.  This means that a linear
  265.        (straight line) function cannot accurately  model  this  situation.
  266.        A better, nonlinear, function is:
  267.  
  268.             value = p0 + p1*exp(-p2*Age)
  269.  
  270.        Where  the  'exp'  function is the value of e (2.7182818...) raised
  271.        to  a  power.   This  type  of  function  is  known  as   "negative
  272.        exponential"  and is appropriate for modeling a value whose rate of
  273.        decrease is proportional to the difference between  the  value  and
  274.        some  base  value.   The  F33YEAR.NLR  example  command file fits a
  275.  
  276.        Chapter 1. Introduction                                           3
  277.  
  278.  
  279.        linear function to the value of  used  airplanes.   The  F33EXP.NLR
  280.        example  fits  a  negative  exponential  function to the same data.
  281.        Run both examples and compare the fitted  functions.   See  F33.NLR
  282.        for  an  example  of  a multiple regression using three independent
  283.        variables.
  284.  
  285.        Much of the convenience of NLREG comes from the fact that  you  can
  286.        enter  complicated  functions  using  ordinary  algebraic notation.
  287.        Examples of functions that can be handled with NLREG include:
  288.  
  289.             Linear:        Y = p0 + p1*X
  290.  
  291.             Quadratic:     Y = p0 + p1*X + p2*X^2
  292.  
  293.             Multivariate:  Y = p0 + p1*X + p2*Z + p3*X*Z
  294.  
  295.             Exponential:   Y = p0 + p1*exp(X)
  296.  
  297.             Periodic:      Y = p0 + p1*sin(p2*X)
  298.  
  299.             Misc:          Y = p0 + p1*Y + p2*exp(Y) + p3*sin(Z)
  300.  
  301.        In other words, the function is a general expression involving  one
  302.        dependent  variable  (on  the  left of the equal sign), one or more
  303.        independent variables, and one or more parameters whose values  are
  304.        to be estimated.
  305.  
  306.        Because   of   its   generality,  NLREG  can  perform  all  of  the
  307.        regressions handled by ordinary linear or  multivariate  regression
  308.        programs  as  well  as  nonlinear regression.  However, in order to
  309.        handle  nonlinear  functions,  NLREG  uses  an  iterative  function
  310.        optimization  algorithm  which  is  slower  than  the simple linear
  311.        regression algorithm and has the potential for not converging to  a
  312.        solution.
  313.  
  314.        Note:  Some  other  regression  programs claim to perform nonlinear
  315.        regression but actually do it by transforming  the  values  of  the
  316.        variables  such  that  the  function  is  converted to linear form.
  317.        They then perform a linear regression on the transformed  function.
  318.        This  technique  has  a major flaw: it determines the values of the
  319.        parameters  that   minimize   the   squared   residuals   for   the
  320.        transformed,   linearized   function   rather   than  the  original
  321.        function.  This is different than minimizing the squared  residuals
  322.        for  the actual function and the estimated values of the parameters
  323.        may not produce the best fit of the original function to the  data.
  324.        NLREG  uses  a  true  nonlinear regression technique that minimizes
  325.        the squared residuals for the  actual  function.   NLREG  can  also
  326.        handle functions that cannot be transformed to a linear form.
  327.  
  328.        Chapter 1. Introduction                                           4
  329.  
  330.  
  331.        1.3 Installing NLREG
  332.  
  333.        The NLREG system consists of the following files:
  334.  
  335.               NLREG.EXE -- The executable program.
  336.               NLREG.DOC -- Documentation file.
  337.               NLREG.FON -- Font file used if you request a plot.
  338.               NLREG.LJF -- LaserJet font file (registered version only).
  339.                    *.NLR -- Example command files.
  340.             REGISTER.DOC -- Form used to register your use of NLREG.
  341.  
  342.        To  install  NLREG,  copy  the  files  into  the  directory of your
  343.        choice.  The registered version of  NLREG  includes  a  file  named
  344.        NLREG.LJF  with  the fonts needed for printing plots on HP LaserJet
  345.        printers.  If you do not plan to generated hard copy output  for  a
  346.        LaserJet  printer,  you  may  delete  the  NLREG.LJF  file.  If the
  347.        NLREG.FON and NLREG.LJF files are not in  your  current  directory,
  348.        you   must   place   a  command  of  the  following  form  in  your
  349.        AUTOEXEC.BAT file to tell NLREG where to look for its font files:
  350.  
  351.             SET NLREG=directory
  352.  
  353.        Where "directory" is the name of the  device  and  directory  where
  354.        the  files are located.  For example, if the files are located in a
  355.        directory named NLREG on the C disk, the  following  command  could
  356.        be used:
  357.  
  358.             SET NLREG=C:\NLREG
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.                                     Chapter 2
  366.  
  367.                                    Using NLREG
  368.  
  369.  
  370.  
  371.  
  372.        Once  NLREG  has  been  installed,  it  can  be started using a DOS
  373.        command of the form:
  374.  
  375.             NLREG command_file [listing_file]
  376.  
  377.        where "command_file"  is  the  name  of  a  file  containing  NLREG
  378.        commands  that  control  the  analysis.   The  sections that follow
  379.        describe these commands.   If  you  specify  a  command  file  name
  380.        without an extension, ".NLR" is used as the default extension.
  381.  
  382.        A  "listing_file"  parameter  may be specified on the command line.
  383.        If you specify a file name, the output (results) of the  regression
  384.        analysis  are  written to this file.  If no file name is specified,
  385.        the output is  written  to  a  file  with  the  same  name  as  the
  386.        command_file  but  with  the  extension  ".LST".   If you specify a
  387.        listing file name without an extension, ".LST" is provided  as  the
  388.        default  extension.  Specify NUL for the listing_file if you do not
  389.        want to generate an output file.
  390.  
  391.        For example, to process a command file named LINEAR.NLR,  directing
  392.        output to a file named LINEAR.LST, use the following command:
  393.  
  394.             NLREG LINEAR
  395.  
  396.        To  do  the  same  analysis,  directing  the output to a file named
  397.        MODEL1.LST, use the following command:
  398.  
  399.             NLREG LINEAR MODEL1
  400.  
  401.        Normally NLREG commands and computed results are displayed  on  the
  402.        screen  and  written  to  the listing file; however, if you place a
  403.        NOECHO  command  in  your  command  file  the  screen  display   is
  404.        suppressed but the output is still written to the listing file.
  405.  
  406.        At  this point, I suggest you pause in your reading and try running
  407.        a NLREG example to get a feel for how it  works.   Several  example
  408.        files   with   the   extension   ".NLR"   are   provided  with  the
  409.        distribution.  LINEAR.NLR is a good one to start with  followed  by
  410.        AIDS.NLR.   If  you  do  not  have  a  graphics  monitor,  edit the
  411.        LINEAR.NLR command file (and other example files)  and  remove  the
  412.        PLOT command.
  413.  
  414.  
  415.  
  416.  
  417.                                         5
  418.  
  419.        Chapter 2. Using NLREG                                            6
  420.  
  421.  
  422.        2.1 Statement Syntax
  423.  
  424.        The  syntax  for  NLREG  statements  follows  the  style  of  the C
  425.        programming language.  Each statement must  end  with  a  semicolon
  426.        character,  you  may  place  more than one statement on a line, and
  427.        text strings and file names are enclosed  in  quote  marks.   NLREG
  428.        has  the  same  arithmetic  and  logical  operators as C, and brace
  429.        characters ('{' and '}') are used to group statements.
  430.  
  431.        The following keywords are reserved by NLREG and may  not  be  used
  432.        as   the  names  of  variables  or  parameters:  angletype,  break,
  433.        confidence,  connect,  connect2,  constant,  constrain,   continue,
  434.        correlate,   covariance,  data,  do,  domain,  double,  else,  for,
  435.        function, grid, if, iteration, iterations, model,  noecho,  nogrid,
  436.        nopause,  notitle,  noxlabel,  noylabel,  nplot, output, parameter,
  437.        parameters, plot, poutput, presolution, print, register,  residual,
  438.        rplot,  splot,  stop,  sweep,  title,  to,  tolerance, values, var,
  439.        variable, variables, while, width,  xlabel,  xvar,  xvar2,  ylabel,
  440.        yvar, yvar2.
  441.  
  442.        2.2 Variables and Parameters
  443.  
  444.        NLREG  allows  you to use four types of variables: input, computed,
  445.        system, and constant.
  446.  
  447.        Input variables are variables whose values are set by  observations
  448.            read  from  your data file.  Input variables are declared using
  449.            the VARIABLES statement.  For each step of the  analysis  NLREG
  450.            cycles   through   each   data  observation  and  executes  the
  451.            statements in your NLREG command file.  Each  execution  begins
  452.            by  setting  the  input  variables to the values for a specific
  453.            observation.  If you want  to  transform  input  variables  you
  454.            should  assign  the  transformed  values  to computed variables
  455.            rather than modifying the values of input variables.
  456.  
  457.        Computed variables are variables  whose  values  are  computed  and
  458.            assigned  in  the  NLREG command file.  They are declared using
  459.            the DOUBLE statement.  You can use computed variables  to  hold
  460.            intermediate  results  of  calculations  or to hold transformed
  461.            values of input variables.  Computed variables may hold  single
  462.            values  (scalars),  lists  of  items  (vectors),  or  arrays of
  463.            values.  You may assign initial values  to  computed  variables
  464.            when  they  are  declared with the DOUBLE statement and you may
  465.            modify the values during the course of execution.
  466.  
  467.        System  variables  hold  values  calculated  by  NLREG  during  the
  468.            execution of your commands.  There are three system variables:
  469.  
  470.            PREDICTED  ---  the value of the dependent variable computed by
  471.                executing your function using  the  current  parameter  and
  472.                input variable values.
  473.  
  474.            RESIDUAL  --- the difference between predicted and actual value
  475.                of the dependent variable of the function.
  476.  
  477.        Chapter 2. Using NLREG                                            7
  478.  
  479.  
  480.            OBS --- the number of the observation  record  from  your  data
  481.                file  that is currently being executed, the first record is
  482.                number 1.
  483.  
  484.            The PREDICTED and RESIDUAL variables only have  defined  values
  485.            after  the  FUNCTION  statement  has  been  executed.  They are
  486.            primarily useful in SPLOT and OUTPUT statements.
  487.  
  488.        Symbolic constants are declared using the  CONSTANT  statement  and
  489.            assigned  values with their declaration.  The values may not be
  490.            altered after the  declaration.   Symbolic  constants  may  not
  491.            appear  on  the  left side of an equal sign, otherwise they may
  492.            be used wherever variables or constants may be used.
  493.  
  494.        There are two other  designations  for  variables  that  should  be
  495.        mentioned.   An  "independent"  variable is a variable that appears
  496.        in the FUNCTION statement on the right  side  of  the  equal  sign.
  497.        You  may have many independent variables.  The "dependent" variable
  498.        appears in the FUNCTION statement on the left  side  of  the  equal
  499.        sign.   There  will  be  only  one  dependent variable.  If you use
  500.        multiple FUNCTION statements, the same dependent variable  must  be
  501.        used  in  each  one.   Input  and computed variables may be used as
  502.        independent and dependent variables.
  503.  
  504.        In addition to variables you will use the PARAMETERS  statement  to
  505.        declare  parameters  whose  values  are  to be calculated by NLREG.
  506.        Parameters are used like variables but  there  values  are  neither
  507.        read  from  the  input  file  nor  computed  by  statements in your
  508.        program, rather their value is determined by NLREG so as  to  cause
  509.        the function to best fit your data observations.
  510.  
  511.        2.3 Plots
  512.  
  513.        NLREG  allows  you  to  generate four types of plots as part of the
  514.        analysis.  Any combination of these plot  types  may  be  requested
  515.        and  you can generate multiple scatter plots by including more than
  516.        one SPLOT statement.  With the registered version of NLREG you  can
  517.        cause  hard copy images of the plots to be generated on HP LaserJet
  518.        printers.  The plots are requested using the following statements:
  519.  
  520.        PLOT ---  Generate  a  plot  showing  the  computed  value  of  the
  521.            function  superimposed  on  a  scatter  plot  of the input data
  522.            values.   NLREG  evaluates  the  function  using  the  computed
  523.            values  of  the  parameters at many data points over the domain
  524.            and plots it as a smooth curve.  Because  NLREG  must  evaluate
  525.            the  function  at  points  between  the  observations  the PLOT
  526.            statement can only be  used  if  your  function  has  a  single
  527.            independent   variable  which  is  an  input  variable  (not  a
  528.            computed variable).  You may  use  symbolic  constants  in  the
  529.            function.
  530.  
  531.        SPLOT  ---  Generate a scatter plot with marks at (X,Y) coordinates
  532.            of data points.  You may plot two sets of points  on  the  same
  533.            graph  for  comparison  purposes.  Unlike the PLOT command, you
  534.            may use any type of variable with  the  SPLOT  command:  input,
  535.  
  536.        Chapter 2. Using NLREG                                            8
  537.  
  538.  
  539.            computed,  system,  and  constant.   Options  are  available to
  540.            cause the plots to be connected by straight line  segments  but
  541.            unlike  the  PLOT  statement  NLREG  will  not  compute  curved
  542.            segments between  the  points.   You  can  use  multiple  SPLOT
  543.            statements  in  your program to cause multiple scatter plots to
  544.            be generated.
  545.  
  546.        RPLOT --- Generate a  plot  showing  the  residual  values  of  the
  547.            function  on  the  vertical  (Y)  axis.  A "residual" value (or
  548.            error deviation) is the difference between an actual  value  of
  549.            the  dependent  variable of the function for an observation and
  550.            the predicted  value  based  on  the  function  fitted  by  the
  551.            regression   analysis.    A   residual   plot   is  useful  for
  552.            determining where, and by how much, the fitted  function  fails
  553.            to predict the actual observations.
  554.  
  555.        NPLOT  ---  Display  a  normal  probability  plot  of  the residual
  556.            values.  In this plot, the actual value  of  each  residual  is
  557.            plotted  on the vertical (Y) axis and the expected value of the
  558.            residual, assuming the residuals are normally  distributed,  is
  559.            plotted  on  the  horizontal  (X)  axis.   If the residuals are
  560.            normally distributed, the resulting plot  will  be  a  straight
  561.            line  passing  through  the origin with a slope of 1.  A normal
  562.            probability  plot  is  useful  for  determining   whether   the
  563.            residuals  are  normally distributed.  If they are not normally
  564.            distributed then the form of the function being fitted  may  be
  565.            inappropriate for the data.
  566.  
  567.        2.4 Overview of Computation Process
  568.  
  569.        Before  getting  into the details of how you present an analysis to
  570.        NLREG it is a good idea to review the  basic  computation  process.
  571.        You  prepare  a command file containing NLREG statements to declare
  572.        variables,  perform  computations,  and  compute  the  value  of  a
  573.        function  that  you  wish to have fitted to your data observations.
  574.        The function will have a dependent variable on  the  left  side  of
  575.        the   equal   sign  and  one  or  more  independent  variables  and
  576.        parameters on the right side of the equal sign.   Either  input  or
  577.        computed  variables  may  be  used  as  dependent  and  independent
  578.        variables.
  579.  
  580.        For each observation record in your data file NLREG  executes  your
  581.        statements  and  computes  the value of the function.  The computed
  582.        value  of  the  function  is  assigned  to  the  PREDICTED   system
  583.        variable.   The  predicted value is then subtracted from the actual
  584.        value of the dependent variable and this difference is assigned  to
  585.        the  RESIDUAL  system  variable.  This process is repeated for each
  586.        observation in the data file and the squared  residual  values  are
  587.        added  together.  After all of the observations have been processed
  588.        NLREG adjusts the values of the parameters whose values are  to  be
  589.        determined  and  repeats the process attempting to minimize the sum
  590.        of the squared residuals.
  591.  
  592.        It is important to understand what happens when  NLREG  executes  a
  593.        FUNCTION statement such as
  594.  
  595.        Chapter 2. Using NLREG                                            9
  596.  
  597.  
  598.             Function y = a + b*x;
  599.  
  600.        Unlike  an  assignment  statement, this FUNCTION statement does not
  601.        assign a new value to the  y  variable.   Rather  it  computes  the
  602.        value  of  the expression on the right side of the equal sign using
  603.        the current values of the 'a' and 'b' parameters and  assigns  this
  604.        value  to  the  PREDICTED  system variable.  It then subtracts this
  605.        from  the  current  value  of  the  y  variable  to  determine  the
  606.        residual.
  607.  
  608.        2.5 Function Specification
  609.  
  610.        Much  of  the power of NLREG comes from its ability to estimate the
  611.        value of parameters that are part  of  complicated  functions  that
  612.        you enter in ordinary algebraic form.
  613.  
  614.        NLREG  provides you with great power in defining the function.  Not
  615.        only can you use a complicated expression to specify the  function,
  616.        you  can  also  use  multiple statements complete with intermediate
  617.        work variables, conditional control (IF, ELSE), and  looping.   The
  618.        only  requirement  is that a FUNCTION statement must be executed to
  619.        define the estimated value of the dependent variable.
  620.  
  621.        The  following  section  explains  the  arithmetic  operators   and
  622.        built-in functions that are used to specify a function.
  623.  
  624.        2.5.1 Arithmetic Operators
  625.  
  626.        The following arithmetic operators may be used in expressions:
  627.  
  628.             ++       add 1 to a variable
  629.             --       subtract 1 from a variable
  630.             +        addition
  631.             -        subtraction or unary minus
  632.             *        multiplication
  633.             /        division
  634.             %        modulo
  635.             ** or ^  exponentiation
  636.  
  637.        The  "++"  and "--" operators may be used either immediately before
  638.        or after a variable name.  If they are used before  the  name,  the
  639.        increment  or  decrement  is  performed  before  the  value  of the
  640.        variable is used in the expression.  If they  are  used  after  the
  641.        name,  the  value  of the variable before being modified is used in
  642.        the expression and then the increment  or  decrement  takes  place.
  643.        For example, the sequence:
  644.  
  645.             a = 3;
  646.             b = 3;
  647.             x = ++a;
  648.             y = b++;
  649.  
  650.        assigns  the  value 4 to x and 3 to y.  At the end of the sequence,
  651.        both a and b have the value 4.
  652.  
  653.        Chapter 2. Using NLREG                                           10
  654.  
  655.  
  656.        The following assignment operators can be used in expressions:
  657.  
  658.             variable = expression;    // Assign expression to variable
  659.             variable += expression;   // Add expression to variable
  660.             variable -= expression;   // Subtract expression from variable
  661.             variable *= expression;   // Multiply variable by expression
  662.             variable /= expression;   // Divide variable by expression
  663.  
  664.        The following operators compare two values and produce a  value  of
  665.        1 if the comparison is true, or 0 if the comparison is false:
  666.  
  667.             ==   Equal
  668.             !=   Not equal
  669.             <=   Less than or equal
  670.             >=   Greater than or equal
  671.             <    Less than
  672.             >    Greater than
  673.  
  674.        The following logical operators may be used:
  675.  
  676.             !    Logical NOT (negates true and false)
  677.             &&   AND
  678.             ||   OR
  679.  
  680.        The conditional operator has the form:
  681.  
  682.        operand1 ?  operand2 : operand3
  683.  
  684.        The  value of operand1 is evaluated.  If it is true (not zero) then
  685.        the value of operand2 is the result  of  the  expression.   If  the
  686.        value  of  operand1  is false (zero) then operand3 is the result of
  687.        the expression.
  688.  
  689.        There are two other special operators:  "[...]"  (square  brackets)
  690.        which  enclose  subscripts  on  arrays  (see the description of the
  691.        DOUBLE statement for information about  arrays),  and  ","  (comma)
  692.        which  is used to specify left-to-right, sequential evaluation of a
  693.        list of expressions.
  694.  
  695.        Operator  precedence,  in  decreasing   order,   is   as   follows:
  696.        subscript,  unary  minus,  logical  NOT, ++ and --, exponentiation,
  697.        multiplication, division  and  modulo,  addition  and  subtraction,
  698.        relational  (comparison),  logical  AND,  logical  OR, conditional,
  699.        assignment, comma.  Parentheses may be used to group terms.
  700.  
  701.        2.5.2 Numeric Constants
  702.  
  703.        Numeric constants may be written in their natural form (1, 0,  1.5,
  704.        .0003,  etc.) or in exponential form, n.nnnEppp, where n.nnn is the
  705.        base value and ppp is the  power  of  ten  by  which  the  base  is
  706.        multiplied.   For example, the number 1.5E4 is equivalent to 15000.
  707.        All numbers are  treated  as  "floating  point"  values  (actually,
  708.        double  precision),  regardless  of  whether  a  decimal  point  is
  709.        specified or not.
  710.  
  711.        Chapter 2. Using NLREG                                           11
  712.  
  713.  
  714.        2.5.3 Symbolic Constants
  715.  
  716.        You can use the CONSTANT  statement  to  associate  symbolic  names
  717.        with  constant  numeric  values.  When you use the symbolic name in
  718.        the function the numeric value  is  substituted  for  the  symbolic
  719.        name.   See Section 3.5, page 20.  The PIECE.NLR example contains a
  720.        symbolic constant.
  721.  
  722.        2.5.4 Built-in Constant
  723.  
  724.        The  symbolic  name  "PI"  is  equivalent  to  the  value  of   pi,
  725.        3.14159...  You may write PI using either upper or lower case.
  726.  
  727.        2.5.5 Built-in Functions
  728.  
  729.        The  following  functions  are  built into NLREG and may be used in
  730.        expressions.    The   ANGLETYPE    statement    controls    whether
  731.        trigonometric  functions  operate  on angles in units of degrees or
  732.        radians (see Section 3.14, page 23).
  733.  
  734.        ABS(x) -- Absolute value of x.
  735.  
  736.        ACOS(x) -- Arc cosine of x.
  737.  
  738.        ASIN(x) -- Arc sine of x.
  739.  
  740.        ATAN(x) -- Arc tangent of x.
  741.  
  742.        BETAI(x,a,b) -- Incomplete beta function: Ix(a,b).  The  incomplete
  743.            beta  function  can be used to compute a variety of statistical
  744.            functions.  For example, the probability of  Student's  t  with
  745.            'df'    degrees    of    freedom    can    be   computed   with
  746.            BETAI(df/(df+t^2),.5*df,.5).   The   probability   of   the   F
  747.            statistic  with  df1 and df2 degrees of freedom can be computed
  748.            with 2*BETAI(df2/(df2+df1*f),.5*df2,.5*df1).
  749.  
  750.        CEIL(x) -- Ceiling of x (an equivalent name for  this  function  is
  751.            INT).   Returns  the smallest integer that is at least as large
  752.            as x.  For example, CEIL(1.5)=2; CEIL(4)=4; CEIL(-2.6)=-2.
  753.  
  754.        COS(x) -- Cosine of x.
  755.  
  756.        COSH(x) -- Hyperbolic cosine of x.
  757.  
  758.        COT(x) -- Cotangent of x.  (COT(x) = 1/TAN(x)).
  759.  
  760.        CSC(X) -- Cosecant of x.  (CSC(x) = 1/SIN(x)).
  761.  
  762.        CTOP(angle) -- Convert an angle in the  compass  coordinate  system
  763.            to  a  polar coordinate angle.  The polar coordinate system has
  764.            the origin of an angle along the positive X axis and the  angle
  765.            increases   in  a  counter-clockwise  direction.   The  compass
  766.            coordinate system has the positive Y axis as the origin  (i.e.,
  767.            north)  and  the angle increases in a clockwise direction.  The
  768.            PTOC function performs the reverse transformation.
  769.  
  770.        Chapter 2. Using NLREG                                           12
  771.  
  772.  
  773.        DEG(x) --  Converts  an  angle,  x,  measured  in  radians  to  the
  774.            equivalent  number of degrees.  See also the description of the
  775.            ANGLETYPE statement.
  776.  
  777.        EI1(alpha,phi) -- Elliptic integral of the  first  kind.   Computes
  778.            the  integral  from  0  to  phi  (degrees  or  radians)  of the
  779.            function d.phi/sqrt(1-k**2*sin(phi)**2), where k =  sin(alpha).
  780.            alpha  and  phi  must  be  in the range 0 to 90 degrees or pi/2
  781.            radians.   The  ANGLETYPE  statement  determines  whether   the
  782.            angles are in units of degrees or radians.
  783.  
  784.        EI2(alpha,phi)  --  Elliptic integral of the second kind.  Computes
  785.            the integral from 0 to phi degrees or radians of  the  function
  786.            sqrt(1-k**2*sin(phi)**2)*d.phi,  where  k  = sin(alpha).  alpha
  787.            and phi must be in the range 0 to 90 degrees  or  pi/2  radians
  788.            depending on the setting of ANGLETYPE.
  789.  
  790.        EIC1(alpha)  --  Complete  elliptic  integral  of  the  first kind.
  791.            Computes the integral from 0 to 90 degrees  (or  pi/2  radians)
  792.            of  the  function  d.phi/sqrt(1-k**2*sin(phi)**2),  where  k  =
  793.            sin(alpha).  alpha must be in the range 0  to  (less  than)  90
  794.            degrees   (or   pi/2  radians)  depending  on  the  setting  of
  795.            ANGLETYPE.
  796.  
  797.        EIC2(alpha) -- Complete  elliptic  integral  of  the  second  kind.
  798.            Computes  the  integral  from 0 to 90 degrees (or pi/2 radians)
  799.            of  the  function  sqrt(1-k**2*sin(phi)**2)*d.phi,  where  k  =
  800.            sin(alpha).   alpha  must  be  in  the range 0 to 90 degrees or
  801.            pi/2 radians depending on the setting of ANGLETYPE.
  802.  
  803.        ERF(x) -- Standard error function of x.
  804.  
  805.        EXP(x) -- e (base of natural logarithms) raised to the x power.
  806.  
  807.        FAC(x) -- x factorial (x!).  Note, the  FAC  function  is  computed
  808.            using  the  GAMMA  function  (FAC(x)=GAMMA(x+1)) so non-integer
  809.            argument values may be computed.
  810.  
  811.        FLOOR(x) -- Floor of x.  Returns the largest integer that  is  less
  812.            than  or  equal  to  x.  For example, FLOOR(2.5)=2; FLOOR(4)=4;
  813.            FLOOR(-3.6)=-4.
  814.  
  815.        GAMMA(x) -- Gamma function.  Note, GAMMA(x+1) = x!  (x factorial).
  816.  
  817.        GAMMAI(x)  --   Reciprocal   of   GAMMA   function   (GAMMAI(x)   =
  818.            1/GAMMA(x)).
  819.  
  820.        GAMMALN(x) -- Log (base e) of the GAMMA function.
  821.  
  822.        HAV(x) -- Haversine of x.  (HAV(x) = (1-COS(x))/2).
  823.  
  824.        INT(x)  --  Ceiling  of  x (an equivalent name for this function is
  825.            CEIL).  Returns the smallest integer that is at least as  large
  826.            as x.  For example, INT(1.5)=2; INT(4)=4; INT(-2.6)=-2.
  827.  
  828.        Chapter 2. Using NLREG                                           13
  829.  
  830.  
  831.        J0(x) -- Bessel function of the first kind, order zero.
  832.  
  833.        J1(x) -- Bessel function of the first kind, order one.
  834.  
  835.        JN(n,x) -- Bessel function of the first kind, order n.
  836.  
  837.        LOG(x) -- Natural logarithm of x.
  838.  
  839.        LOG10(x) -- Base 10 logarithm of x.
  840.  
  841.        LOG2(x) -- Base 2 logarithm of x.
  842.  
  843.        MAX(x1,x2) -- Maximum value of x1 or x2.
  844.  
  845.        MIN(x1,x2) -- Minimum value of x1 or x2.
  846.  
  847.        NORMAL(x)  --  Normal probability distribution of x.  X is in units
  848.            of standard  deviations  from  the  mean.   See  also  the  NPD
  849.            function.  NORMAL(x) = NPD(x,0,1);
  850.  
  851.        NPD(x,mean,std)  --  Normal  probability  distribution  of  x  with
  852.            specified mean and  standard  deviation.   X  is  in  units  of
  853.            standard deviations from the mean.
  854.  
  855.        PAREA(x)  --  Area  under the normal probability distribution curve
  856.            from -infinity to x.  (i.e., integral from -infinity  to  x  of
  857.            NORMAL(x)).
  858.  
  859.        PRINTF("format",value1,value2,...)  -- Format and print a series of
  860.            values.  The NLREG printf function  has  the  same  syntax  and
  861.            function  as  the printf function in the C language.  It causes
  862.            a string to be written to your terminal and  also  the  listing
  863.            file  for  the  analysis.   Printf  is  primarily  useful  as a
  864.            diagnostic tool to give you a way to observe what is  happening
  865.            during  an  analysis.   Note:  since your commands are executed
  866.            for each data observation and each iteration,  the  printf  may
  867.            generate a great deal of output.
  868.  
  869.            The  first  argument to printf is a quoted string that contains
  870.            characters to be printed, control codes, and (if values are  to
  871.            be  printed)  formatting  specifications.   If you are familiar
  872.            with the C programming language, the  NLREG  formatting  string
  873.            has the same form and control codes.
  874.  
  875.            Ordinary  characters  and  numbers  in  the  format  string are
  876.            printed just as they appear.  Use  the  control  code  '\n'  to
  877.            cause  a  carriage-return,  line-feed sequence to be printed to
  878.            terminate a line.  For example, the following command prints  a
  879.            line of text:
  880.  
  881.                 printf("Beginning of analysis\n");
  882.  
  883.            If  you  wish to insert formatted values in the string, specify
  884.            one or more expressions after the format string.  Place in  the
  885.            format  string  at  the  location  where you want to insert the
  886.  
  887.        Chapter 2. Using NLREG                                           14
  888.  
  889.  
  890.            formatted value the sequence '%lf' (percent  sign,  lower  case
  891.            L,  f)  if you want the number formatted in the style nnnn.nnnn
  892.            or  '%lE'  if  you  want  exponential  notation  (nnn.nnnEnnn).
  893.            Optionally,  you  may  specify the width of the formatted value
  894.            and the number of decimal places  between  '%'  and  'l'.   For
  895.            example,  the  following  sequence  produces  a formatted value
  896.            with 8 total characters and 4  decimal  places:  %8.4lf.   Here
  897.            are several examples:
  898.  
  899.                 printf("Processing observation %lf\n",obs);
  900.                 printf("X = %lf, Y = %lf\n",x,y);
  901.                 printf("Predicted = %14.6lE\n",predicted);
  902.  
  903.        PTOC(angle)  --  Convert an angle in the polar coordinate system to
  904.            a compass coordinate angle.  The polar  coordinate  system  has
  905.            the  origin of an angle along the positive X axis and the angle
  906.            increases  in  a  counter-clockwise  direction.   The   compass
  907.            coordinate  system has the positive Y axis as the origin (i.e.,
  908.            north) and the angle increases in a clockwise  direction.   The
  909.            CTOP function performs the reverse transformation.
  910.  
  911.        PTORX(angle,distance)  --  Convert  a position in polar coordinates
  912.            to the corresponding  rectangular  coordinate.   This  function
  913.            returns  the  X coordinate of the position; use PTORY to obtain
  914.            the Y coordinate.  Note: polar coordinates are  specified  with
  915.            the  positive  X  axis  being the origin for the angle and with
  916.            the angle increasing in the counter-clockwise direction.
  917.  
  918.        PTORY(angle,distance) -- Convert a position  in  polar  coordinates
  919.            to  the  corresponding  rectangular  coordinate.  This function
  920.            returns the Y coordinate of the position; use PTORX  to  obtain
  921.            the  X  coordinate.  Note: polar coordinates are specified with
  922.            the positive X axis being the origin for  the  angle  and  with
  923.            the angle increasing in the counter-clockwise direction.
  924.  
  925.        PULSE(a,x,b)  --  Pulse function.  If the value of x is less than a
  926.            or greater than b, the value of the function is  0.   If  x  is
  927.            greater  than  or  equal  to a and less than or equal to b, the
  928.            value of the function is 1.  In other words, it is  1  for  the
  929.            domain  (a,b)  and zero elsewhere.  If you need a function that
  930.            is  zero  in  the  domain  (a,b)  and  1  elsewhere,  use   the
  931.            expression (1-PULSE(a,x,b)).
  932.  
  933.        RAD(x)  --  Converts an angle measured in degrees to the equivalent
  934.            number of radians.  See also the description of  the  ANGLETYPE
  935.            statement.
  936.  
  937.        RANDOM()  --  Returns  a  random value uniformly distributed in the
  938.            range 0 to 1.
  939.  
  940.        ROUND(x)  --  Rounds  x  to  the  nearest  integer.   For  example,
  941.            ROUND(1.1)=1; ROUND(1.8)=2; ROUND(-2.8)=-3;
  942.  
  943.        RTOPA(x,y)  --  Convert  a  rectangular  coordinate  (x,y)  to  the
  944.            corresponding   polar   coordinate   (angle,distance).     This
  945.  
  946.        Chapter 2. Using NLREG                                           15
  947.  
  948.  
  949.            function  returns  the  angle,  use  RTOPD  to get the distance
  950.            coordinate.  Note: polar coordinates  are  specified  with  the
  951.            positive  X  axis  being  the origin for the angle and with the
  952.            angle increasing in the counter-clockwise direction.
  953.  
  954.        RTOPD(x,y)   --   Convert   a   rectangular   coordinate   to   the
  955.            corresponding  polar  coordinate.   This  function  returns the
  956.            distance from the origin, use RTOPA to get  the  angle.   Note:
  957.            polar  coordinates are specified with the positive X axis being
  958.            the origin for the angle and with the angle increasing  in  the
  959.            counter-clockwise direction.
  960.  
  961.        SEC(x) -- Secant of x.  (SEC(x) = 1/COS(x)).
  962.  
  963.        SEL(a1,a2,v1,v2)  --  If  a1  is less than a2 then the value of the
  964.            function is v1.  If a1 is greater than or  equal  to  a2,  then
  965.            the value of the function is v2.
  966.  
  967.        SIN(x)  --  Sine  of x.  See TREND.NLR for an example of a function
  968.            with  a  sin  term.   See  also  Section  4.9  for   additional
  969.            information about using sin terms in functions.
  970.  
  971.        SINH(x) -- Hyperbolic sine of x.
  972.  
  973.        SQRT(x) -- Square root of x.
  974.  
  975.        STEP(a,x)  -- Step function.  If x is less than a, the value of the
  976.            function is 0.  If x is greater than or equal to a,  the  value
  977.            of  the function is 1.  If you need a function which is 1 up to
  978.            a  certain  value  and  then  0  beyond  that  value,  use  the
  979.            expression  STEP(x,a).   See  PIECE.NLR  for an example of this
  980.            function.
  981.  
  982.        T(n,x) -- Chebyshev polynomial of order n.
  983.  
  984.        TAN(x) -- Tangent of x.
  985.  
  986.        TANH(x) -- Hyperbolic tangent of x.
  987.  
  988.        Y0(x) -- Bessel function of the second kind, order zero.
  989.  
  990.        Y1(x) -- Bessel function of the second kind, order one.
  991.  
  992.        YN(n,x) -- Bessel function of the second kind, order n.
  993.  
  994.        2.6 NLREG Command Files
  995.  
  996.        The commands described in this section  are  placed  in  a  command
  997.        file.   When  you  start NLREG, you specify the name of the command
  998.        file as a parameter on the  command  line.   For  example,  if  the
  999.        command  file  name  is  CAR.NLR, the following command would cause
  1000.        NLREG to execute the commands in the command file:
  1001.  
  1002.             NLREG CAR.NLR
  1003.  
  1004.        Chapter 2. Using NLREG                                           16
  1005.  
  1006.  
  1007.        If you do not specify a file name extension for the  command  file,
  1008.        ".NLR"  is  used by default.  The output of the regression for this
  1009.        example would be written to a file named  CAR.LST.   Command  files
  1010.        can  be created using a text editor such as EDIT-32, EDLIN, the DOS
  1011.        EDIT program, or  any  other  editor  or  word  processor  that  is
  1012.        capable of creating an ascii text file without formatting codes.
  1013.  
  1014.        2.7 Comments
  1015.  
  1016.        The  beginning  of  a comment is denoted with "//" (two consecutive
  1017.        slash characters).  Everything from the "//" sequence  to  the  end
  1018.        of  the  line is treated as a comment.  Comments may be on lines by
  1019.        themselves or on the  ends  of  other  statements.   You  can  also
  1020.        specify  a comment by beginning the comment with the "/*" character
  1021.        sequence.  All characters following this are  treated  as  comments
  1022.        up  to  the matching "*/" sequence.  The following lines illustrate
  1023.        both types of comments:
  1024.  
  1025.             //  Function to be fitted
  1026.             y = a + b*x;  //  Simple linear equation
  1027.             /*
  1028.              *  This is a comment.
  1029.              */
  1030.             z = y / 5;                  /* This is a comment too */
  1031.  
  1032.        2.8 Include Files
  1033.  
  1034.        NLREG provides a #INCLUDE statement that  you  may  place  in  your
  1035.        command  file  to  cause another file to be inserted in the command
  1036.        file at  the  point  where  the  #INCLUDE  statement  occurs.   The
  1037.        included  file  may contain any valid NLREG statements or data that
  1038.        would be appropriate at the specified point in  the  command  file.
  1039.        Processing  of  the  statements in the original command file resume
  1040.        when the end of  the  included  file  (and  any  nested  files)  is
  1041.        reached.  The form of the statement is:
  1042.  
  1043.             #include "file"
  1044.  
  1045.        where  'file'  is  the  name  of  the file whose contents are to be
  1046.        inserted.   If  no  extension  is  specified,  ".NLR"  is  used  by
  1047.        default.   Include  files  may be nested up to 10 levels deep.  The
  1048.        following is an example of a NLREG command file that  includes  the
  1049.        function specification:
  1050.  
  1051.             Title "Example of file inclusion";
  1052.             Variables X,Y;
  1053.             Parameters a,b;
  1054.             #include "fun1";       // Function statement is in "fun1.nlr"
  1055.             data;
  1056.             (data records follow)
  1057.  
  1058.        Chapter 2. Using NLREG                                           17
  1059.  
  1060.  
  1061.        2.9 Required Statements
  1062.  
  1063.        Every   command   file   must  contain  the  following  statements:
  1064.        VARIABLES, PARAMETERS, FUNCTION,  and  DATA.   The  DATA  statement
  1065.        introduces  the  data  for  the  analysis  and  must  be  the  last
  1066.        statement in  the  file  (data  records  may  follow  it).   Other,
  1067.        optional,  statements may be interspersed in the command file.  The
  1068.        following is an example of a complete command file:
  1069.  
  1070.             title "Depreciation Example";
  1071.             variables  value,age,miles;
  1072.             parameters base,depage,depmiles;
  1073.             function value = base + depage*age + depmiles*miles;
  1074.             data;
  1075.             (data records follow)
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.                                     Chapter 3
  1083.  
  1084.                                 NLREG Statements
  1085.  
  1086.  
  1087.  
  1088.  
  1089.        The following is a list of the valid NLREG statements that  can  be
  1090.        placed  in  a  NLREG  command  file.  NLREG statements are not case
  1091.        sensitive.  Remember to end each statement with a semicolon.
  1092.  
  1093.        3.1 TITLE
  1094.  
  1095.        TITLE "string"; (optional)  --  Specifies  a  title  line  that  is
  1096.        printed  with  the results of the analysis.  Note: the title string
  1097.        must be enclosed in quote signs.
  1098.  
  1099.        3.2 VARIABLES
  1100.  
  1101.        VARIABLES var1,var2,...; (required) -- Specifies the names  of  the
  1102.        input  variables  whose  values  will  be read from your data file.
  1103.        The order of the variable names must match the order  of  the  data
  1104.        values  on  each observation record.  You may define more variables
  1105.        than you actually use in the function specification.  A maximum  of
  1106.        25  variables  may  be specified.  The length of a variable name is
  1107.        limited to 10 characters.  Capitalize the  variable  names  as  you
  1108.        want  them displayed in the results.  The keyword "VARIABLE" may be
  1109.        used instead of "VARIABLES".
  1110.  
  1111.        You may specify all of the variables on a single statement  or  you
  1112.        may  use  multiple  VARIABLES  statements.   If  you  use  multiple
  1113.        statements, the order in which they  appear  in  the  command  file
  1114.        must  match  the  order  of the variable values on each observation
  1115.        record.   The  VARIABLES  statement  must  precede   the   FUNCTION
  1116.        statement.   See  F33.NLR  for  an example of a multiple regression
  1117.        using three independent variables.
  1118.  
  1119.        You can also use the DOUBLE statement  to  declare  variables  (see
  1120.        below).   The  difference  is that the VARIABLES statement declares
  1121.        variables that are read from the  input  file  whereas  the  DOUBLE
  1122.        statement  declares  variables  whose  values  will  be computed by
  1123.        statements in your command file.
  1124.  
  1125.        3.3 PARAMETERS
  1126.  
  1127.        PARAMETERS param1[=initial1],param2[=initial2],...;  (required)  --
  1128.        Specifies  the  names  of  the  parameters  whose  values are to be
  1129.        determined by NLREG.   NLREG  is  capable  of  handling  up  to  25
  1130.        parameters.   The  parameter  names may not exceed 10 characters in
  1131.        length.  Do not specify any parameters that are  not  used  in  the
  1132.  
  1133.  
  1134.                                        18
  1135.  
  1136.        Chapter 3. NLREG Statements                                      19
  1137.  
  1138.  
  1139.        analysis.   The  PARAMETERS  statement  must  precede  the FUNCTION
  1140.        statement.   The  keyword  "PARAMETER"  may  be  used  instead   of
  1141.        "PARAMETERS".
  1142.  
  1143.        Optionally,  an  initial  estimate  of  the  parameter value may be
  1144.        specified by following the parameter name with an  equal  sign  and
  1145.        the  value.   If  no  value  is  specified,  1  is used by default.
  1146.        Specifying an initial value that is near the actual  value  usually
  1147.        speeds  up the operation of NLREG and may enable it to successfully
  1148.        converge to a solution.  If  NLREG  is  unable  to  converge  to  a
  1149.        solution,   try   specifying  different  starting  values  for  the
  1150.        parameters.  Try to specify a value that at least has  the  correct
  1151.        sign as the expected final value.
  1152.  
  1153.        The  CONSTRAIN  statement  (see  page  20) can be used to limit the
  1154.        range of values for parameters.  The SWEEP statement (see page  21)
  1155.        can  be  used  to  perform  the regression analysis with a range of
  1156.        parameter initial values.
  1157.  
  1158.        3.4 DOUBLE
  1159.  
  1160.        DOUBLE var1[=value],var2[=value],...; (optional) --  Specifies  the
  1161.        names  of  computed variables that you may use subsequently to hold
  1162.        calculated values.  NLREG allows you to define up  to  30  computed
  1163.        variables.   All  variables hold double precision (64 bit) floating
  1164.        point values.  Optionally, the name of a variable may  be  followed
  1165.        by  an equal sign and a value to which the variable is initialized.
  1166.        If  you  do  not  specify  an  initial  value,  the   variable   is
  1167.        initialized   to   0.    The   following  are  examples  of  DOUBLE
  1168.        statements:
  1169.  
  1170.             double t1,t2;
  1171.             double roomtemp=73;
  1172.  
  1173.        It  is  convenient  to  use  computed  variables  for  intermediate
  1174.        calculations such as transformed values of input variables.
  1175.  
  1176.        NLREG  allows you to declare arrays with one or two dimensions.  To
  1177.        do this follow the name  of  the  variable  with  number  of  array
  1178.        elements  enclosed  in  square  brackets.   If  the  array  has two
  1179.        dimensions specify the number of rows, then the number of  columns,
  1180.        separated  by  a  comma.   (Note:  this  is  different  than  the C
  1181.        language  syntax  for  declaring  a  two-dimensional  array).   The
  1182.        following  statements  declare  a  one  dimensional  array (i.e., a
  1183.        vector) with 20 elements and a two dimensional array  with  5  rows
  1184.        and 10 columns:
  1185.  
  1186.             double xvec[20];
  1187.             double ya[5,10];
  1188.  
  1189.        You  may  assign initial values to arrays by following the variable
  1190.        declaration with an equal sign and a list  of  values  enclosed  in
  1191.        curly  braces.   In the case of a two dimensional array, the values
  1192.        should be specified by rows (i.e., the last subscript  varies  most
  1193.  
  1194.        Chapter 3. NLREG Statements                                      20
  1195.  
  1196.  
  1197.        rapidly).   The  following  are examples of array declarations with
  1198.        initializations:
  1199.  
  1200.             double xvec[5] = {2,5,7,1,0};
  1201.             double xa[2,3] = {2.3,7.5,1.2,4.4,2.6,7.3};
  1202.  
  1203.        When used in expressions the subscript values are  0  based.   That
  1204.        is,  the first element of the array is referenced using a subscript
  1205.        value of 0 and the last element is  referenced  using  a  subscript
  1206.        value  equal  to one less than the number of elements in the array.
  1207.        For example, the following statements would declare an  array  with
  1208.        100 elements and initialize it:
  1209.  
  1210.             double xsq[100],i;
  1211.             for (i=0; i<100; i++) {
  1212.                 xsq[i] = i;
  1213.             }
  1214.  
  1215.        3.5 CONSTANT
  1216.  
  1217.        CONSTANT  variable=value;  (optional)  --  Specifies  the name of a
  1218.        symbolic constant and associates a numeric  value.   You  can  then
  1219.        use  the  symbolic  name  where  you  would  use  a  number and the
  1220.        corresponding constant numeric value will be substituted.  This  is
  1221.        useful  when you are trying out different models and want to easily
  1222.        be able to change a constant value for each run.  The following  is
  1223.        an  example of a symbolic constant named "Roomtemp" that causes the
  1224.        value 73 to be substituted in the function:
  1225.  
  1226.             Variable Time;                 // Cooling time in seconds
  1227.             Variable Temp;                 // Temperature of object
  1228.             Constant Roomtemp = 73;        // Ambient temperature
  1229.             Parameter InitTemp;            // Initial temperature
  1230.             Parameter Coolrate;            // Cooling rate factor
  1231.             Function Temp = Roomtemp + InitTemp * exp(-Coolrate * Time);
  1232.  
  1233.        3.6 CONSTRAIN
  1234.  
  1235.        CONSTRAIN parameter=lowvalue,highvalue; (optional) --  Specifies  a
  1236.        lower  and  upper  limit on the range of a parameter value.  During
  1237.        the solution process,  NLREG  may  allow  a  parameter's  value  to
  1238.        temporarily  move  in  a direction away from its final value.  With
  1239.        some functions it may be necessary  to  constrain  the  parameter's
  1240.        value  so that it does not go negative (e.g., if the function takes
  1241.        the square root of the parameter), or zero (if the parameter is  in
  1242.        a  denominator).   If a parameter is tightly constrained, NLREG may
  1243.        report "singular convergence" because it is unable to  converge  to
  1244.        an  optimum  value  of the parameter; however, the estimated values
  1245.        of other parameters may be useful.
  1246.  
  1247.        Only a single parameter and its associated limits may be  specified
  1248.        on  each  CONSTRAIN  statement,  but you may use multiple CONSTRAIN
  1249.        statements.  The PARAMETERS statement must  precede  the  CONSTRAIN
  1250.        statement.   Use  the  CONSTANT  statement  if you wish to define a
  1251.        parameter with a fixed value.
  1252.  
  1253.        Chapter 3. NLREG Statements                                      21
  1254.  
  1255.  
  1256.        The  parameter  value  is  allowed  to  range  from  'lowvalue'  to
  1257.        'highvalue'.   If  you want to prevent a parameter value from going
  1258.        to zero, you must specify a value greater than  zero  for  the  low
  1259.        value  (specifying  zero would allow it to reach, but not go below,
  1260.        zero).  For example, the following statement constrains  the  value
  1261.        of 'age' to be greater than zero and less than or equal to 100:
  1262.  
  1263.             constrain age = .0001,100;
  1264.  
  1265.        See  the  COOLING.NLR, F33EXP.NLR, and POWER.NLR files for examples
  1266.        of the CONSTRAIN statement.
  1267.  
  1268.        3.7 SWEEP
  1269.  
  1270.        SWEEP    parameter=lowvalue,highvalue,stepsize;    (optional)    --
  1271.        Specifies   that   the  regression  analysis  is  to  be  performed
  1272.        repeatedly with a set of starting values for  the  parameter.   The
  1273.        first   analysis   is  performed  with  the  parameter  having  the
  1274.        'lowvalue';  the  value  of  'stepsize'  is  then  added   to   the
  1275.        parameter's  initial  value  and  the  analysis is performed again.
  1276.        The process is repeated until the value of  the  parameter  reaches
  1277.        'highvalue'.
  1278.  
  1279.        Each  time  the analysis is performed the value of the residual sum
  1280.        of  squares  is  compared  with  the  best  previous  result.   The
  1281.        estimated  values of the parameters for the best starting value are
  1282.        saved and used for the final analysis and report.
  1283.  
  1284.        Only one parameter may be specified on each  SWEEP  statement,  but
  1285.        you  may  have  as  many  SWEEP statements as there are parameters.
  1286.        The number of regression analyses performed will be  equal  to  the
  1287.        product   of   the  number  of  parameter  values  for  each  SWEEP
  1288.        statement.
  1289.  
  1290.        The SWEEP statement  is  useful  when  you  are  trying  to  fit  a
  1291.        complicated  function  that  may  have "local minimum" values other
  1292.        than the "global minimum".  Periodic  functions  (sin,  cos,  etc.)
  1293.        are especially troublesome.
  1294.  
  1295.        See  the  SINE.NLR  command  file  for  an  example  of  the  SWEEP
  1296.        statement.
  1297.  
  1298.        3.8 FUNCTION
  1299.  
  1300.        FUNCTION depvar = function; (required) --  Specifies  the  form  of
  1301.        the  function whose parameters are to be determined.  The dependent
  1302.        variable must be the only thing to the  left  of  the  equal  sign.
  1303.        The  expression  to  the  right  of  the  equal  sign  may  contain
  1304.        variables, parameters, constants, operators, and library  functions
  1305.        such  as  sqrt,  sin,  exp,  etc.   The  VARIABLES  and  PARAMETERS
  1306.        statements must appear in the  command  file  before  the  FUNCTION
  1307.        statement.   The  function may be specified using parameters, input
  1308.        variables,  computed   variables   (declared   using   the   DOUBLE
  1309.        statement),  constants,  and  library  functions.  You may use more
  1310.        than one FUNCTION statement if you  use  IF  or  other  conditional
  1311.  
  1312.        Chapter 3. NLREG Statements                                      22
  1313.  
  1314.  
  1315.        statements  to  select which one will be executed.  However, during
  1316.        each execution of your command file one,  and  only  one,  FUNCTION
  1317.        statement  must  be executed.  Some example FUNCTION statements are
  1318.        show below:
  1319.  
  1320.             Function  y = p0 + p1*x;
  1321.  
  1322.             Function  distance = .5 * accel * time^2;
  1323.  
  1324.             Function  value = price + yrdep*age + miledep*miles;
  1325.  
  1326.             Function  populatn = base * growrate * exp(time);
  1327.  
  1328.        3.9 CORRELATE
  1329.  
  1330.        CORRELATE [var1,var2,...]; (optional) -- Causes  NLREG  to  compute
  1331.        and  print  a  correlation matrix.  If you do not specify a list of
  1332.        variables the correlation matrix includes all input variables.   If
  1333.        you  wish  to  control  exactly which variables are included in the
  1334.        matrix or if you wish to include computed variables (declared  with
  1335.        a  DOUBLE  statement)  you  may  specify  a list of variables.  See
  1336.        Section 4.11 on page 41 for  more  information  about  correlation.
  1337.        The  F33.NLR example includes a CORRELATE statement.  The following
  1338.        are examples of the CORRELATE statement:
  1339.  
  1340.             correlate;
  1341.             correlate x1,x2,x3,y;
  1342.  
  1343.        3.10 COVARIANCE
  1344.  
  1345.        COVARIANCE; (optional) --  Causes  the  variance-covariance  matrix
  1346.        for the parameters to be printed.
  1347.  
  1348.        3.11 CONFIDENCE
  1349.  
  1350.        CONFIDENCE  [percent];  (optional)  --  Specifies that a confidence
  1351.        interval is to  be  printed  for  each  estimated  parameter.   The
  1352.        purpose  of  regression  analysis is to determine the best estimate
  1353.        of  parameter  values.    However,   as   with   most   statistical
  1354.        calculations,  the  values  determined  are  estimates  of the true
  1355.        values.  The CONFIDENCE statement causes NLREG  to  print  a  table
  1356.        showing  the  range  of  possible values for each parameter given a
  1357.        specified confidence value.  The "percent" parameter specifies  the
  1358.        probability  that  that the actual value of the parameter is within
  1359.        the  confidence  interval  to  be  computed.   For   example,   the
  1360.        statement
  1361.  
  1362.             Confidence 95;
  1363.  
  1364.        specifies  that  the confidence interval(s) are to be computed such
  1365.        that there is a 95 percent probability that the  actual  values  of
  1366.        the  parameters  are  within  the  intervals  (or that there is a 5
  1367.        percent chance that the  parameters  are  outside  the  intervals).
  1368.        The  "percent"  parameter  may  range  from  50  to 99.999.  If the
  1369.  
  1370.        Chapter 3. NLREG Statements                                      23
  1371.  
  1372.  
  1373.        CONFIDENCE statement is used without specifying  a  percent  value,
  1374.        90 is used by default.
  1375.  
  1376.        3.12 TOLERANCE
  1377.  
  1378.        TOLERANCE   value;   (optional,  default=1E-10)  --  Specifies  the
  1379.        tolerance factor that is used to determine when the  algorithm  has
  1380.        converged  to a solution.  Reducing the tolerance value may produce
  1381.        a slightly more accurate result but will  increase  the  number  of
  1382.        iterations  and  the  running time.  The tolerance value must be in
  1383.        the  range  1E-15  to  1E-1.   See  Section  5.2   for   additional
  1384.        information  about  how  the  tolerance  value is used to determine
  1385.        when the function has converged.
  1386.  
  1387.        3.13 ITERATIONS
  1388.  
  1389.        ITERATIONS value; (optional, default=50) -- Specifies  the  maximum
  1390.        number  of  iterations  that  should be attempted by the algorithm.
  1391.        If the solution does not converge to the  limit  specified  by  the
  1392.        TOLERANCE  statement  (or  to  the  default  tolerance)  before the
  1393.        maximum number of iterations is reached,  the  process  is  stopped
  1394.        and  the  results  are  printed.   Failure  to  converge before the
  1395.        specified number of iterations could be  caused  by  one  of  three
  1396.        things:
  1397.  
  1398.        1.  The  maximum  allowed  number  of  iterations may be too small.
  1399.            Try using an ITERATIONS statement with a larger value.
  1400.  
  1401.        2.  The tolerance  factor  may  be  too  small.   Even  a  properly
  1402.            converging  solution  will  eventually "level off" or oscillate
  1403.            around a good, but non-zero, sum of squares value.   Try  using
  1404.            the TOLERANCE statement to increase the tolerance value.
  1405.  
  1406.        3.  The  function may not be converging.  Try specifying better (or
  1407.            at least different) starting values for the parameters  on  the
  1408.            PARAMETERS  statement.   Consider  using the SWEEP statement to
  1409.            specify a range of parameter starting values.
  1410.  
  1411.        3.14 ANGLETYPE
  1412.  
  1413.        ANGLETYPE DEGREES  or  RADIANS;  (optional)  --  Specifies  whether
  1414.        trigonometric  library  functions  such as SIN, COS, TAN, etc.  are
  1415.        to operate in units of degrees or radians.  The default setting  is
  1416.        degrees.   You may only declare the angle type once in your program
  1417.        and the declaration must come before any statements that  use  trig
  1418.        functions.   You  can  also  use  the  DEG() and RAD() functions to
  1419.        convert between degrees and radians.   The  following  are  example
  1420.        ANGLETYPE statements:
  1421.  
  1422.             angletype degrees;
  1423.             angletype radians;
  1424.  
  1425.        Chapter 3. NLREG Statements                                      24
  1426.  
  1427.  
  1428.        3.15 OUTPUT
  1429.  
  1430.        OUTPUT  [TO  "file"]  var1,var2,...;  (optional)  -- Specifies that
  1431.        after the analysis is completed, data values are to be  written  to
  1432.        a  file.   One  record  is written for each data observation in the
  1433.        input  file.   If  the  TO  "file"  portion  of  the  statement  is
  1434.        specified,  the  output  is written to the specified file.  If this
  1435.        portion of the statement is omitted, the output values are  written
  1436.        to  the  listing file along with the results of the analysis.  If a
  1437.        file name is specified without an  extension,  ".OUT"  is  used  by
  1438.        default.
  1439.  
  1440.        The  list  of variable names determines which variables are written
  1441.        to the file and the order  in  which  the  values  appear  in  each
  1442.        output  record.   Any variable previously declared with a VARIABLES
  1443.        or DOUBLE statement may be specified.  In addition,  the  following
  1444.        system variable names may appear in the output list:
  1445.  
  1446.        OBS  -- The observation record number, starting at 1 and increasing
  1447.        by 1.
  1448.  
  1449.        PREDICTED -- The predicted value for  the  dependent  variable  for
  1450.        the  observation,  given  the  independent  variable values and the
  1451.        parameters as calculated by the analysis.
  1452.  
  1453.        RESIDUAL  --  The  difference  between  the  actual  value  of  the
  1454.        dependent variable and its predicted value.
  1455.  
  1456.        Examples of OUTPUT statements are shown below:
  1457.  
  1458.             output age,miles,value,predicted,residual;
  1459.             output to "growth.dat" obs,time,populatn,predicted;
  1460.  
  1461.        3.16 POUTPUT
  1462.  
  1463.        POUTPUT  "file"; (optional) -- The POUTPUT statement specifies that
  1464.        NLREG is to write the final estimated values of the  parameters  to
  1465.        a  file.  Each parameter value is written to a separate line of the
  1466.        file.  This statement is useful  to  create  a  file  of  estimated
  1467.        parameter  values  to  be  fed into another analysis program.  This
  1468.        statement can also be used to determine the parameter estimates  to
  1469.        more  significant  digits  than  displayed  in  the printed listing
  1470.        because the format used by the POUTPUT statement writes the  values
  1471.        with  18  significant  digits.   The  following  is an example of a
  1472.        POUTPUT statement:
  1473.  
  1474.             poutput "params.dat";
  1475.  
  1476.        3.17 PLOT
  1477.  
  1478.        PLOT [options]; (optional) -- Display  a  plot  of  the  calculated
  1479.        function  and  the data observations.  Each data point is displayed
  1480.        with a blue 'X'; the function  that  NLREG  fits  to  the  data  is
  1481.        superimposed as a yellow curve.
  1482.  
  1483.        Chapter 3. NLREG Statements                                      25
  1484.  
  1485.  
  1486.        The  PLOT  statement  can  only be used if the FUNCTION declaration
  1487.        meets the following requirements: (1) there is must only  a  single
  1488.        independent  variable;  (2)  the  independent  variable  must be an
  1489.        input variable (i.e., declared with a  VARIABLES  statement  not  a
  1490.        DECLARE  statement).   You may use symbolic constants declared with
  1491.        the CONSTANT statement.   If  the  function  does  not  meet  these
  1492.        requirements  you  may  produce  different types of plots using the
  1493.        SPLOT, RPLOT and NPLOT statements.
  1494.  
  1495.        You must  have  a  CGA,  EGA,  or  VGA  monitor  to  use  the  PLOT
  1496.        statement,  and  the  NLREG.FON  font  file  must be in the current
  1497.        directory or in a directory  specified  by  the  NLREG  environment
  1498.        variable.   Press  Return  to  proceed  with the analysis after you
  1499.        finish looking at the plot.
  1500.  
  1501.        The following options may be specified on the PLOT statement:
  1502.  
  1503.        NOGRID -- suppress the grid lines that are normally displayed  with
  1504.            the plot.
  1505.  
  1506.        TITLE="string"  --  specify  a title to be displayed with the plot.
  1507.            If no title  is  specified  the  title  defined  by  the  TITLE
  1508.            statement is used.
  1509.  
  1510.        NOTITLE  -- suppresses the title for the plot which, by default, is
  1511.            the title specified with the TITLE statement.
  1512.  
  1513.        XLABEL="string" -- specify a label to be printed along the X  axis.
  1514.            If  you  do  not use this qualifier, the name of variable whose
  1515.            values determine the X  coordinates  is  used  as  the  default
  1516.            label.
  1517.  
  1518.        NOXLABEL -- suppress printing any label along the X axis.
  1519.  
  1520.        YLABEL="string"  -- specify a label to be printed along the Y axis.
  1521.            If you do not use this qualifier, the name  of  variable  whose
  1522.            values  determine  the  Y  coordinates  is  used as the default
  1523.            label.
  1524.  
  1525.        NOYLABEL -- suppress printing any label along the Y axis.
  1526.  
  1527.        DOMAIN=lowvalue,hivalue -- specifies  the  domain  over  which  the
  1528.            plot  is  to  be  generated.   If no domain is specified, NLREG
  1529.            uses the range of the independent variable for the domain.
  1530.  
  1531.        RESIDUAL -- draw vertical lines from each observed  data  point  to
  1532.            the  corresponding  point  on  the  calculated  function  line.
  1533.            These lines  represent  the  "residual"  value  that  NLREG  is
  1534.            attempting  to  minimize.   See  also  the  descriptions of the
  1535.            RPLOT and NPLOT statements on pages 28 and 30.
  1536.  
  1537.        ITERATION -- draw a plot  for  each  iteration  of  the  regression
  1538.            analysis.   Normally,  the plot is drawn after the analysis has
  1539.            converged to a solution; you may use the  ITERATION  option  to
  1540.  
  1541.        Chapter 3. NLREG Statements                                      26
  1542.  
  1543.  
  1544.            observe  the  function during each iteration of the analysis as
  1545.            it converges to fit the data.
  1546.  
  1547.        VALUES -- use in conjunction with the  ITERATION  option  to  cause
  1548.            the  current  parameter  values to be displayed before the plot
  1549.            for the current iteration.
  1550.  
  1551.        PRINT -- print a copy of the plot on an HP LaserJet printer.   This
  1552.            option  is  only  available in the registered version of NLREG.
  1553.            NLREG writes the plot to the PRN device which much be  attached
  1554.            to  an  HP Series II or Series III printer.  The NLREG.LJF font
  1555.            file must be  in  the  current  directory  or  in  a  directory
  1556.            specified by the NLREG environment variable.
  1557.  
  1558.        NOPAUSE  --  do  not  pause after the plot is displayed.  Normally,
  1559.            NLREG pauses after displaying a  plot  to  allow  you  time  to
  1560.            examine  it;  you  press  Enter  to continue execution once you
  1561.            have finished looking at the plot.  The NOPAUSE  option  causes
  1562.            NLREG  to  continue  with  execution  without pausing after the
  1563.            plot is displayed.  This is  useful  in  conjunction  with  the
  1564.            PRINT  option when NLREG is run in a batch file and you want to
  1565.            generate a  hardcopy  plot  but  not  pause  after  the  screen
  1566.            display.
  1567.  
  1568.        If  more  than  one option is specified, separate them with commas.
  1569.        For example, to produce a plot with X  and  Y  axis  labels  use  a
  1570.        statement with the following form:
  1571.  
  1572.             PLOT XLABEL="Time",YLABEL="Blood concentration";
  1573.  
  1574.        3.18 SPLOT
  1575.  
  1576.        SPLOT  [options];  (optional)  --  Display  a scatter plot of (X,Y)
  1577.        data points.  Using the XVAR and YVAR options (see below)  you  can
  1578.        specify  which  variable is used for the vertical (Y) dimension and
  1579.        which is used for  the  horizontal  (X)  dimension.   Any  type  of
  1580.        variable  may  be  specified  including  input  variables, computed
  1581.        variables (declared  with  the  DOUBLE  statement),  the  dependent
  1582.        variable  of  the  function,  and  the  system variables PREDICTED,
  1583.        RESIDUAL, and OBS (see Section 2.2 on page 6).
  1584.  
  1585.        You may display two scatter plots  on  the  same  image.   This  is
  1586.        useful  for  comparing  computed  values  with input values.  To do
  1587.        this use the XVAR2 and YVAR2 options to specify the  variables  for
  1588.        the  X  and  Y dimensions for the second plot.  Each data point for
  1589.        the primary plot (specified by XVAR and  YVAR)  is  marked  with  a
  1590.        blue  'X'.  The data points for the second plot (specified by XVAR2
  1591.        and YVAR2) are marked with  yellow  triangles.   You  can  use  the
  1592.        CONNECT  and  CONNECT2  options  to  draw  straight  line  segments
  1593.        through the points.  The NOMARK and NOMARK2 options may be used  to
  1594.        suppress the data point markers.
  1595.  
  1596.        The following options may be specified on the SPLOT statement:
  1597.  
  1598.        Chapter 3. NLREG Statements                                      27
  1599.  
  1600.  
  1601.        XVAR=variable   --   specify  the  variable  to  be  used  for  the
  1602.            horizontal (X) dimension of the first set  of  plotted  points.
  1603.            This  can  be  any type of variable, input or computed.  If you
  1604.            do  not  specify  this  option  and  there  is  only  a  single
  1605.            independent variable in the function, it is used by default.
  1606.  
  1607.        YVAR=variable  --  specify the variable to be used for the vertical
  1608.            (Y) dimension.  This can be any  type  of  variable,  input  or
  1609.            computed.    If  you  do  not  specify  this  option  then  the
  1610.            dependent variable of the function (i.e., the one on  the  left
  1611.            of the equal sign) is used by default.
  1612.  
  1613.        XVAR2=variable   --  specify  the  variable  to  be  used  for  the
  1614.            horizontal (X) dimension of the second set of  plotted  points.
  1615.            This  can  be  any  type of variable.  If you specify YVAR2 but
  1616.            not XVAR2, the default is the same  variable  as  specified  by
  1617.            XVAR.
  1618.  
  1619.        CONNECT  --  Connect  the  first  set  of  points  by straight line
  1620.            segments.  The points are displayed and connected in  the  same
  1621.            order that they appear in the data file.
  1622.  
  1623.        CONNECT2  --  Connect  the  second  set  of points by straight line
  1624.            segments.
  1625.  
  1626.        NOMARK -- Suppress the display of the  'X'  symbols  that  normally
  1627.            mark  the  first  set  of  data  points.  This can be used with
  1628.            CONNECT to cause only the line to be drawn.
  1629.  
  1630.        NOMARK2 -- Suppress  the  display  of  the  triangle  symbols  that
  1631.            normally mark the second set of data points.
  1632.  
  1633.        NOGRID  -- suppress the grid lines that are normally displayed with
  1634.            the plot.
  1635.  
  1636.        TITLE="string" -- specify a title to be displayed  with  the  plot.
  1637.            If  no  title  is  specified  the  title  defined  by the TITLE
  1638.            statement is used.
  1639.  
  1640.        NOTITLE -- suppresses the title for the plot which, by default,  is
  1641.            the title specified with the TITLE statement.
  1642.  
  1643.        XLABEL="string"  -- specify a label to be printed along the X axis.
  1644.            If you do not use this qualifier, the name  of  variable  whose
  1645.            values  determine  the  X  coordinates  is  used as the default
  1646.            label.
  1647.  
  1648.        NOXLABEL -- suppress printing any label along the X axis.
  1649.  
  1650.        YLABEL="string" -- specify a label to be printed along the Y  axis.
  1651.            If  you  do  not use this qualifier, the name of variable whose
  1652.            values determine the Y  coordinates  is  used  as  the  default
  1653.            label.
  1654.  
  1655.        Chapter 3. NLREG Statements                                      28
  1656.  
  1657.  
  1658.        NOYLABEL -- suppress printing any label along the Y axis.
  1659.  
  1660.        DOMAIN=lowvalue,hivalue  --  specifies  the  domain  over which the
  1661.            plot is to be generated.  If  no  domain  is  specified,  NLREG
  1662.            uses the range of the horizontal variable(s) for the domain.
  1663.  
  1664.        PRINT  -- print a copy of the plot on an HP LaserJet printer.  This
  1665.            option is only available in the registered  version  of  NLREG.
  1666.            NLREG  writes the plot to the PRN device which much be attached
  1667.            to an HP Series II or Series III printer.  The  NLREG.LJF  font
  1668.            file  must  be  in  the  current  directory  or  in a directory
  1669.            specified by the NLREG environment variable.
  1670.  
  1671.        NOPAUSE -- do not pause after the  plot  is  displayed.   Normally,
  1672.            NLREG  pauses  after  displaying  a  plot  to allow you time to
  1673.            examine it; you press Enter  to  continue  execution  once  you
  1674.            have  finished  looking at the plot.  The NOPAUSE option causes
  1675.            NLREG to continue with  execution  without  pausing  after  the
  1676.            plot is displayed.
  1677.  
  1678.        If  there  is more than one option, separate them with commas.  The
  1679.        following is an example SPLOT statement:
  1680.  
  1681.             splot xvar=time,yvar=sodium,yvar2=potassium,connect,connect2,
  1682.                   title="Blood concentration over time",
  1683.                   xlabel="Time (hours)",ylabel="Sodium & Potassium";
  1684.  
  1685.        3.19 RPLOT
  1686.  
  1687.        RPLOT [options]; (optional) --  Display  a  plot  of  the  residual
  1688.        values.   A "residual" value (or error deviation) is the difference
  1689.        between  an  actual  value  of  the  dependent  variable   for   an
  1690.        observation  and  the  predicted value based on the function fitted
  1691.        by the regression analysis.  If  the  calculated  function  exactly
  1692.        predicted  the  actual  observation  values,  all  of  the residual
  1693.        values would be zero.  However, this is usually not  the  case  and
  1694.        the  residual  values  show  where,  and  by  how  much, the fitted
  1695.        function fails to predict the actual observations.
  1696.  
  1697.        The RPLOT statement causes NLREG to  display  a  plot  showing  the
  1698.        residual  values  on  the  vertical (Y) axis.  The variable plotted
  1699.        along the horizontal (X) axis  may  be  specified  using  the  XVAR
  1700.        option  (see  below).   You  may specify any variable including the
  1701.        dependent variable and computed variables declared with the  DOUBLE
  1702.        statement.   If you do not specify a variable and there is a single
  1703.        independent variable in the function it is used.  The X axis  label
  1704.        indicates which variable was used.
  1705.  
  1706.        A  residual  plot is very useful for determining if the form of the
  1707.        function being fitted is appropriate for the data values.   If  the
  1708.        residual  values  are randomly distributed in positive and negative
  1709.        directions  then  the  form  (shape)  of  the  fitted  function  is
  1710.        probably  appropriate  for  the  data and the deviations are due to
  1711.        random measurement errors.   If,  however,  the  residuals  show  a
  1712.        systematic  pattern such as a periodic cycle, then the function may
  1713.  
  1714.        Chapter 3. NLREG Statements                                      29
  1715.  
  1716.  
  1717.        not be appropriate for the data values.  See the discussion of  the
  1718.        Durbin-Watson  statistic  in  Section  4.9, page 39, for additional
  1719.        information  about  autocorrelated  residual  values.   The   PLOT,
  1720.        RPLOT,  SPLOT, and NPLOT statements may be used in the same command
  1721.        file.  Press Return to proceed with the  analysis  after  you  have
  1722.        finished looking at the plot.
  1723.  
  1724.        The following options may be specified on the RPLOT statement:
  1725.  
  1726.        XVAR=variable  --  specify  which  variable  is  to be used for the
  1727.            horizontal (X) dimension of the  plot.   You  may  specify  any
  1728.            variable  including  independent input variables, the dependent
  1729.            variable of the function (i.e., the one  on  the  left  of  the
  1730.            equal  sign),  and  computed  or transformed variables declared
  1731.            with  the  DOUBLE  statement.   If  there  is  only  a   single
  1732.            independent  variable  NLREG will use it by default.  The label
  1733.            along the X axis indicates which variable was used.
  1734.  
  1735.        NOGRID -- suppress the grid lines that are normally displayed  with
  1736.            the plot.
  1737.  
  1738.        TITLE="string"  --  specify  a title to be displayed with the plot.
  1739.            If this option is not specified, the default title is "Plot  of
  1740.            residuals".
  1741.  
  1742.        NOTITLE  -- suppresses the title for the plot which, by default, is
  1743.            "Plot of residuals".
  1744.  
  1745.        XLABEL="string" -- specify a label to be printed along the X  axis.
  1746.            If  you  do  not use this qualifier, the name of variable whose
  1747.            values determine the X  coordinates  is  used  as  the  default
  1748.            label.
  1749.  
  1750.        NOXLABEL -- suppress printing any label along the X axis.
  1751.  
  1752.        YLABEL="string"  -- specify a label to be printed along the Y axis.
  1753.            If you  do  not  use  this  qualifier,  the  default  label  is
  1754.            "Residual".
  1755.  
  1756.        NOYLABEL -- suppress printing any label along the Y axis.
  1757.  
  1758.        DOMAIN=lowvalue,hivalue  --  specifies  the  domain  over which the
  1759.            plot is to be generated.  If  no  domain  is  specified,  NLREG
  1760.            uses the range of the X dimension variable.
  1761.  
  1762.        ITERATION  --  draw  a  plot  for  each iteration of the regression
  1763.            analysis.  Normally, the plot is drawn after the  analysis  has
  1764.            converged  to  a  solution; you may use the ITERATION option to
  1765.            observe the function during each iteration of the  analysis  as
  1766.            it converges to fit the data.
  1767.  
  1768.        VALUES  --  use  in  conjunction with the ITERATION option to cause
  1769.            the current parameter values to be displayed  before  the  plot
  1770.            for the current iteration.
  1771.  
  1772.        Chapter 3. NLREG Statements                                      30
  1773.  
  1774.  
  1775.        PRINT  -- print a copy of the plot on an HP LaserJet printer.  This
  1776.            option is only available in the registered  version  of  NLREG.
  1777.            NLREG  writes the plot to the PRN device which much be attached
  1778.            to an HP Series II or Series III printer.  The  NLREG.LJF  font
  1779.            file  must  be  in  the  current  directory  or  in a directory
  1780.            specified by the NLREG environment variable.
  1781.  
  1782.        NOPAUSE -- do not pause after the  plot  is  displayed.   Normally,
  1783.            NLREG  pauses  after  displaying  a  plot  to allow you time to
  1784.            examine it; you press Enter  to  continue  execution  once  you
  1785.            have  finished  looking at the plot.  The NOPAUSE option causes
  1786.            NLREG to continue with  execution  without  pausing  after  the
  1787.            plot is displayed.
  1788.  
  1789.        If more than one option is specified, separate them with commas.
  1790.  
  1791.        3.20 NPLOT
  1792.  
  1793.        NPLOT  [options] (optional) -- Display a normal probability plot of
  1794.        the residual values.  In  this  plot,  the  actual  value  of  each
  1795.        residual  is  plotted  on  the  vertical  (Y) axis and the expected
  1796.        value  of  the  residual,  assuming  the  residuals  are   normally
  1797.        distributed,  is  plotted  on  the  horizontal  (X)  axis.   If the
  1798.        residuals are normally distributed, the resulting plot  will  be  a
  1799.        straight  line  passing through the origin with a slope of 1 (i.e.,
  1800.        the actual value of each residual should equal the  expected  value
  1801.        from  the  normal distribution).  If the residuals are not normally
  1802.        distributed, the plot will deviate from  a  straight  line.   NLREG
  1803.        displays  a red line along which the X marks should be displayed if
  1804.        the residuals are normally distributed.
  1805.  
  1806.        This  plot  also  computes  the  correlation  between  the   actual
  1807.        residual   values  and  their  expected  values  and  displays  the
  1808.        correlation coefficient in the  title  line  "(r=n.nnn)".   If  the
  1809.        residual  values  are  normally distributed, the correlation should
  1810.        be close to 1.000.  A correlation value less  than  0.940  suggests
  1811.        that the residuals are not normally distributed.
  1812.  
  1813.        The  PLOT,  RPLOT,  SPLOT,  and NPLOT statements may be used in the
  1814.        same command file.  Press  Return  to  proceed  with  the  analysis
  1815.        after you have finished looking at the plot.
  1816.  
  1817.        The following options may be specified on the NPLOT statement:
  1818.  
  1819.        GRID -- display grid lines to make it easier to estimate values.
  1820.  
  1821.        TITLE="string"  --  specify  a title to be displayed with the plot.
  1822.            If  no  title  is  specified  the  default  title  is   "Normal
  1823.            probability plot".
  1824.  
  1825.        NOTITLE -- suppresses the title for the plot.
  1826.  
  1827.        XLABEL="string"  -- specify a label to be printed along the X axis.
  1828.            If you do not use this qualifier, default  label  is  "Expected
  1829.            residuals".
  1830.  
  1831.        Chapter 3. NLREG Statements                                      31
  1832.  
  1833.  
  1834.        NOXLABEL -- suppress printing any label along the X axis.
  1835.  
  1836.        YLABEL="string"  -- specify a label to be printed along the Y axis.
  1837.            If you do not use this qualifier, the default label is  "Actual
  1838.            residuals".
  1839.  
  1840.        NOYLABEL -- suppress printing any label along the Y axis.
  1841.  
  1842.        ITERATION  --  draw  a  plot  for  each iteration of the regression
  1843.            analysis.  Normally, the plot is drawn after the  analysis  has
  1844.            converged  to  a  solution; you may use the ITERATION option to
  1845.            observe the function during each iteration of the  analysis  as
  1846.            it converges to fit the data.
  1847.  
  1848.        VALUES  --  use  in  conjunction with the ITERATION option to cause
  1849.            the current parameter values to be displayed  before  the  plot
  1850.            for the current iteration.
  1851.  
  1852.        PRINT  -- print a copy of the plot on an HP LaserJet printer.  This
  1853.            option is only available in the registered  version  of  NLREG.
  1854.            NLREG  writes the plot to the PRN device which much be attached
  1855.            to an HP Series II or Series III printer.
  1856.  
  1857.        NOPAUSE -- do not pause after the  plot  is  displayed.   Normally,
  1858.            NLREG  pauses  after  displaying  a  plot  to allow you time to
  1859.            examine it; you press Enter  to  continue  execution  once  you
  1860.            have  finished  looking at the plot.  The NOPAUSE option causes
  1861.            NLREG to continue with  execution  without  pausing  after  the
  1862.            plot is displayed.
  1863.  
  1864.        If more than one option is specified, separate them with commas.
  1865.  
  1866.        3.21 PRESOLUTION
  1867.  
  1868.        PRESOLUTION  value;  (optional)  -- Specifies whether plots sent to
  1869.        HP  LaserJet  printers  should  use   150   or   300   dot-per-inch
  1870.        resolution.   This  option  is  only  available  in  the registered
  1871.        version of NLREG.  The value parameter must be  150  or  300.   The
  1872.        default  value  is  150  causes  the  plots  to  use  most  of  the
  1873.        horizontal width of an 8.5x11 inch page.  These plots are  suitable
  1874.        for  direct  transfer  to  overhead transparencies.  Specifying 300
  1875.        for the resolution produces smaller plots  that  are  suitable  for
  1876.        inclusion in printed documents.
  1877.  
  1878.        3.22 WIDTH
  1879.  
  1880.        WIDTH  value;  (optional)  --  Specify  the  width,  in  inches, of
  1881.        printed plots.  This option is only  available  in  the  registered
  1882.        version  of NLREG.  Due to memory space considerations, the maximum
  1883.        width is limited to about 7.9 inches for  150  DPI  resolution  and
  1884.        4.5  inches  for  300  DPI  resolution.  If you have limited memory
  1885.        space, you may have to reduce the  width  to  be  able  to  produce
  1886.        printed  plots.   This statement is ignored unless you request that
  1887.        a plot be printed.
  1888.  
  1889.        Chapter 3. NLREG Statements                                      32
  1890.  
  1891.  
  1892.        3.23 NOECHO
  1893.  
  1894.        NOECHO; (optional) -- Specifies that the  statements  and  computed
  1895.        results  are  not  to be listed on the screen.  The output is still
  1896.        written to the listing file and any requested plots  are  displayed
  1897.        on the screen.
  1898.  
  1899.        3.24 Assignment Statement
  1900.  
  1901.        The  assignment statement is an executable statement that evaluates
  1902.        an expression and assigns its value to a variable.  The syntax  for
  1903.        an assignment statement is:
  1904.  
  1905.             variable = expression;   // Assign expression to variable
  1906.             variable += expression;  // Add expression to variable
  1907.             variable -= expression;  // Subtract expression from variable
  1908.             variable *= expression;  // Multiply variable by expression
  1909.             variable /= expression;  // Divide variable by expression
  1910.  
  1911.        where  "variable"  is a variable that was previously declared using
  1912.        a DOUBLE statement.  The variable may be subscripted if  it  is  an
  1913.        array.   "expression"  is  a valid arithmetic or logical expression
  1914.        following the rules explained earlier.  If the expression  involves
  1915.        a  relational  comparison  operator  (e.g.,  <,  >,  >=, etc.) or a
  1916.        logical operation (&&, ||, !), the value 1 is used for true  and  0
  1917.        for  false.   The  expression  may  contain  any  type  of variable
  1918.        (input, computed, or constant) along with  parameters  and  library
  1919.        functions.
  1920.  
  1921.        3.25 IF Statement
  1922.  
  1923.        The form of the IF statement is:
  1924.  
  1925.             IF (expression) statement1 [ELSE statement2]
  1926.  
  1927.        If  the  expression  is  true (not zero) statement1 is executed, if
  1928.        the expression is false (0)  and  the  ELSE  clause  is  specified,
  1929.        statement2  is  executed.   The  ELSE  clause and the second set of
  1930.        controlled statements are optional.   You  may  control  groups  of
  1931.        statements   by  enclosing  them  in  braces.   The  following  are
  1932.        examples of valid IF statements:
  1933.  
  1934.             if (x > bigx) bigx = x;
  1935.  
  1936.             if (x < Pivot) {
  1937.                 Function Y = B0+B1*(X-Pivot);
  1938.             } else {
  1939.                 Function Y = B0+B2*(X-Pivot);
  1940.             }
  1941.  
  1942.        The PIECE.NLR command file contains an example of an IF statement.
  1943.  
  1944.        Chapter 3. NLREG Statements                                      33
  1945.  
  1946.  
  1947.        3.26 WHILE Statement
  1948.  
  1949.        The WHILE statement loops until the controlling expression  becomes
  1950.        false  (0)  or  a BREAK statement is executed within the loop.  The
  1951.        form of the WHILE statement is:
  1952.  
  1953.             WHILE (expression) {
  1954.                 << controlled statements >>
  1955.             }
  1956.  
  1957.        Each time around the loop the expression is evaluated.   If  it  is
  1958.        true  (non  zero)  the  controlled statements are executed and then
  1959.        the process repeats until  the  expression  becomes  false.   If  a
  1960.        BREAK  statement is executed within the loop, execution of the loop
  1961.        terminates and  control  is  transferred  to  the  first  statement
  1962.        beyond  the  end  of the loop.  If a CONTINUE statement is executed
  1963.        in the loop, control is transferred to the conditional test at  the
  1964.        top  of  the  loop.   The  following  is  an  example  of  a  WHILE
  1965.        statement:
  1966.  
  1967.             while (x < 5) {
  1968.                 x = x + xmove;
  1969.                 y = y + ymove;
  1970.             }
  1971.  
  1972.        3.27 DO Statement
  1973.  
  1974.        The DO statement is very similar to the WHILE statement except  the
  1975.        control  expression is evaluated at the end of the loop rather than
  1976.        the beginning.  This causes the  loop  always  to  be  executed  at
  1977.        least once.  The form of the DO statement is:
  1978.  
  1979.             DO {
  1980.                 << controlled statements >>
  1981.             WHILE (expression);
  1982.  
  1983.        For  each  iteration  of  the  loop  the  controlled statements are
  1984.        executed and then the conditional expression is evaluated.   If  it
  1985.        is  true  (non-zero)  control  transfers  to  the  first controlled
  1986.        statement at the top of the loop.  A BREAK statement  may  be  used
  1987.        to   terminate  the  loop  before  the  conditional  expression  is
  1988.        evaluated.  A CONTINUE statement can be used to  cause  control  to
  1989.        be  transferred  from  within  the  loop  to  the  point  where the
  1990.        conditional expression is evaluated.  The following is  an  example
  1991.        of a DO statement:
  1992.  
  1993.             do {
  1994.               x += xstep;
  1995.               y += ystep;
  1996.             } while (x < limit);
  1997.  
  1998.        Chapter 3. NLREG Statements                                      34
  1999.  
  2000.  
  2001.        3.28 FOR Statement
  2002.  
  2003.        The  FOR  statement  is  a looping control statement similar to the
  2004.        WHILE statement; however, the FOR  statement  also  allows  you  to
  2005.        specify  initialization  expressions  that are executed once at the
  2006.        beginning of the loop, and loop-end expressions that  are  executed
  2007.        at the end of each loop cycle.  The form of the FOR statement is:
  2008.  
  2009.             FOR (expression1; expression2; expression3) statement;
  2010.  
  2011.        Execution of a FOR statement proceeds as follows:
  2012.  
  2013.        1.  Evaluate  expression1.   Typically this expression will include
  2014.            assignment operators ("=")  to  set  initial  values  for  loop
  2015.            variables.   If  you  need  more  than  one initial expression,
  2016.            specify them as a list separated by commas.
  2017.  
  2018.        2.  Evaluate expression2.  If its value is false (0) terminate  the
  2019.            FOR  statement  and  transfer  control  to  the  statement that
  2020.            follows the controlled  statement.   If  expression2  is  true,
  2021.            proceed to the next step.
  2022.  
  2023.        3.  Execute  the  controlled statement.  If more than one statement
  2024.            is to be controlled, enclose them with  brace  characters  ("{"
  2025.            "}").
  2026.  
  2027.        4.  Evaluate  expression3.   This expression will typically contain
  2028.            operators such as "++", "+=",  "--",  or  "-="  to  modify  the
  2029.            value of a loop variable.
  2030.  
  2031.        5.  Transfer  control  to  step  2, where expression2 is once again
  2032.            evaluated.
  2033.  
  2034.        The following is an example of a FOR statement:
  2035.  
  2036.             for (time=starttime; time<endtime; time+=timestep) {
  2037.                 << controlled statements >>
  2038.             }
  2039.  
  2040.        3.29 BREAK Statement
  2041.  
  2042.        The BREAK statement can be used in FOR,  WHILE,  and  DO  loops  to
  2043.        terminate  the  loop and cause control to transfer to the statement
  2044.        beyond the end of the loop.  The  following  is  an  example  of  a
  2045.        BREAK statement:
  2046.  
  2047.             time = 0;
  2048.             x = 0;
  2049.             while (time < endtime) {
  2050.                 x += delta * xspeed;
  2051.                 if (x > 10) break;
  2052.             }
  2053.  
  2054.        Chapter 3. NLREG Statements                                      35
  2055.  
  2056.  
  2057.        3.30 CONTINUE Statement
  2058.  
  2059.        The  CONTINUE  statement can be used in FOR, WHILE, and DO loops to
  2060.        terminate the current iteration  and  begin  the  next  one.   When
  2061.        CONTINUE  is  executed  in  a  WHILE  or  DO  statement, control is
  2062.        transferred to the  point  in  the  loop  where  the  loop  control
  2063.        expression  is  evaluated.   When  CONTINUE  is  executed  in a FOR
  2064.        statement, control is transferred to the bottom of the  loop  where
  2065.        expression3  is  evaluated  (which  normally augments the values of
  2066.        the loop variables for  the  next  iteration).   The  form  of  the
  2067.        CONTINUE statement is:
  2068.  
  2069.             continue;
  2070.  
  2071.        3.31 STOP Statement
  2072.  
  2073.        The  STOP  statement  terminates  the  calculations for the current
  2074.        iteration.   The  last  value  of  the  independent  variable   (as
  2075.        specified  with  a  FUNCTION  statement)  is used as the calculated
  2076.        value of the function.   An  implicit  stop  occurs  if  you  "fall
  2077.        through"  the  last  executable  statement.   The  form of the STOP
  2078.        statement is:
  2079.  
  2080.             stop;
  2081.  
  2082.        3.32 DATA
  2083.  
  2084.        DATA ["file"];  (required)  --  Specifies  the  name  of  the  file
  2085.        containing  the  data records, or introduces the data records which
  2086.        follow the statement.  If a file name  is  specified  on  the  DATA
  2087.        statement,  the  file is opened, its data records are read, and the
  2088.        regression analysis is performed.  If  a  file  name  is  specified
  2089.        without  an extension, ".DAT" is used by default.  Note that if you
  2090.        specify a file name it must be enclosed in quote marks.
  2091.  
  2092.        If no file name is  specified  on  the  DATA  statement,  the  data
  2093.        records  must  immediately follow the DATA statement in the command
  2094.        file.
  2095.  
  2096.        Each data record must contain at least as many data values  as  the
  2097.        number  of  variables specified on the VARIABLES statement(s).  The
  2098.        order of the variables as  specified  on  the  VARIABLES  statement
  2099.        must  match  the order of the values in each observation.  Any data
  2100.        values beyond  those  required  for  the  specified  variables  are
  2101.        ignored.  Each observation must begin on a new line.
  2102.  
  2103.        The  data  values  must be separated by one or more spaces and/or a
  2104.        comma.  You may place a comment on the end  of  a  data  record  by
  2105.        beginning  the  comment with "//".  Data values may contain decimal
  2106.        points  and  may  be  expressed  in  exponential  notation   (i.e.,
  2107.        n.nnnnEppp).
  2108.  
  2109.        The  DATA statement must be the last statement in the command file.
  2110.        If no file name is  specified  on  the  DATA  statement,  the  data
  2111.        records  must  immediately follow the DATA statement in the command
  2112.  
  2113.        Chapter 3. NLREG Statements                                      36
  2114.  
  2115.  
  2116.        file.  The following is an  example  of  a  complete  command  file
  2117.        including data records:
  2118.  
  2119.             Variables age,miles,value;
  2120.             Parameters base,depage,depmiles;
  2121.             Function value = base + depage*age + depmiles*miles;
  2122.             Data;
  2123.             2  10000  13000
  2124.             4  42000   9000
  2125.             1   7000  17000
  2126.             6  52000   6000
  2127.             5  48000   8000
  2128.  
  2129.        If  the  data  records  had  been  placed  in a separate file named
  2130.        CAR.DAT, the statements would read as follows:
  2131.  
  2132.             Variables age,miles,value;
  2133.             Parameters base,depage,depmiles;
  2134.             Function value = base + depage*age + depmiles*miles;
  2135.             Data "car.dat";
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.                                     Chapter 4
  2143.  
  2144.                             Understanding The Results
  2145.  
  2146.  
  2147.  
  2148.  
  2149.        4.1 Descriptive Statistics for Variables
  2150.  
  2151.        NLREG prints a variety of statistics at the end of  each  analysis.
  2152.        For  each  variable,  NLREG  lists  the  minimum value, the maximum
  2153.        value, the mean value, and  the  standard  deviation.   You  should
  2154.        confirm that these values are within the ranges you expect.
  2155.  
  2156.        4.2 Parameter Estimates
  2157.  
  2158.        For  each  parameter, NLREG displays the initial parameter estimate
  2159.        (which you specified on the PARAMETER statement, or 1 by  default),
  2160.        the  final (maximum likelihood) estimate, the standard error of the
  2161.        estimated  parameter  value,  the  "t"  statistic   comparing   the
  2162.        estimated  parameter value with zero, and the significance of the t
  2163.        statistic.   Nine  significant  digits  are   displayed   for   the
  2164.        parameter  estimates.   If  you need to determine the parameters to
  2165.        greater precision, use the POUTPUT statement.
  2166.  
  2167.        The  final  estimate  parameter  values  are  the  results  of  the
  2168.        analysis.   By  substituting  these  values  in  the  equation  you
  2169.        specified to be fitted to the data, you will have a  function  that
  2170.        can  be  used  to predict the value of the dependent variable based
  2171.        on a set of values for the independent variables.  For example,  if
  2172.        the equation being fitted is
  2173.  
  2174.             y = p0 + p1*x
  2175.  
  2176.        and  the  final  estimates  are  1.5  for p0 and 3 for p1, then the
  2177.        equation
  2178.  
  2179.             y = 1.5 + 3*x
  2180.  
  2181.        is the best equation of this form that will predict the value of  y
  2182.        based on the value of x.
  2183.  
  2184.        4.3 t Statistic
  2185.  
  2186.        The  "t"  statistic  is computed by dividing the estimated value of
  2187.        the parameter by its standard error.  This statistic is  a  measure
  2188.        of  the  likelihood  that  the actual value of the parameter is not
  2189.        zero.  The larger the absolute value of t,  the  less  likely  that
  2190.        the actual value of the parameter could be zero.
  2191.  
  2192.  
  2193.  
  2194.                                        37
  2195.  
  2196.        Chapter 4. Understanding The Results                             38
  2197.  
  2198.  
  2199.        4.4 Prob(t)
  2200.  
  2201.        The  "Prob(t)"  value is the probability of obtaining the estimated
  2202.        value of the parameter if the actual parameter value is zero.   The
  2203.        smaller  the  value  of Prob(t), the more significant the parameter
  2204.        and the less likely that the actual parameter value is  zero.   For
  2205.        example,  assume  the estimated value of a parameter is 1.0 and its
  2206.        standard error is 0.7.  Then the t value would be  1.43  (1.0/0.7).
  2207.        If  the  computed  Prob(t)  value was 0.05 then this indicates that
  2208.        there is only a 0.05 (5%) chance  that  the  actual  value  of  the
  2209.        parameter  could  be  zero.   If  Prob(t)  was 0.001 this indicates
  2210.        there is only 1 chance in 1000 that the parameter  could  be  zero.
  2211.        If  Prob(t) was 0.92 this indicates that there is a 92% probability
  2212.        that the actual value of the parameter could be zero; this  implies
  2213.        that  the  term of the regression equation containing the parameter
  2214.        can be eliminated without significantly affecting the  accuracy  of
  2215.        the regression.
  2216.  
  2217.        One  thing  that  can  cause  Prob(t)  to be 1.00 (or near 1.00) is
  2218.        having redundant parameters.  If at the end of an analysis  several
  2219.        parameters   have  Prob(t)  values  of  1.00,  check  the  function
  2220.        carefully to see if one or more of the parameters can  be  removed.
  2221.        Also  try  using  a  DOUBLE  statement  to  set  one or more of the
  2222.        parameters to a reasonable fixed value;  if  the  other  parameters
  2223.        suddenly  become  significant  (i.e.,  Prob(t) much less than 1.00)
  2224.        then the parameters are mutually dependent and one or  more  should
  2225.        be  removed.   See  Section 6.2 for more information about mutually
  2226.        dependent parameters.
  2227.  
  2228.        The t statistic probability is computed  using  a  two-sided  test.
  2229.        The  CONFIDENCE  statement  can  be  used  to  cause NLREG to print
  2230.        confidence intervals for parameter values.  The SQUARE.NLR  example
  2231.        regression  includes  an  extraneous parameter (p0) whose estimated
  2232.        value is much smaller than its standard error;  the  Prob(t)  value
  2233.        is  0.99982  indicating  that  there is a high probability that the
  2234.        value is zero.
  2235.  
  2236.        4.5 Final Sum of Squared Deviations
  2237.  
  2238.        In addition to the variable and parameter  values,  NLREG  displays
  2239.        several  statistics  that  indicate  how well the equation fits the
  2240.        data.  The "Final sum of squared deviations"  is  the  sum  of  the
  2241.        squared  differences  between  the  actual  value  of the dependent
  2242.        variable for each  observation  and  the  value  predicted  by  the
  2243.        function, using the final parameter estimates.
  2244.  
  2245.        4.6 Average and Maximum Deviation
  2246.  
  2247.        The  "Average  deviation"  is  the average over all observations of
  2248.        the absolute value of the difference between the  actual  value  of
  2249.        the dependent variable and its predicted value.
  2250.  
  2251.        The   "Maximum  deviation  for  any  observation"  is  the  maximum
  2252.        difference (ignoring sign) between the actual and  predicted  value
  2253.        of the dependent variable for any observation.
  2254.  
  2255.        Chapter 4. Understanding The Results                             39
  2256.  
  2257.  
  2258.        4.7 Proportion of Variance Explained
  2259.  
  2260.        The  "Proportion  of  variance  explained (R^2)" indicates how much
  2261.        better the function  predicts  the  dependent  variable  than  just
  2262.        using  the  mean  value  of  the  dependent variable.  This is also
  2263.        known  as  the  "coefficient  of  multiple  determination."  It  is
  2264.        computed  as  follows:  Suppose  that we did not fit an equation to
  2265.        the  data  and  ignored  all  information  about  the   independent
  2266.        variables  in  each observation.  Then, the best prediction for the
  2267.        dependent variable value for any  observation  would  be  the  mean
  2268.        value  of  the  dependent  variable  over  all  observations.   The
  2269.        "variance" is the sum of the squared differences between  the  mean
  2270.        value   and   the   value   of  the  dependent  variable  for  each
  2271.        observation.  Now, if we use our fitted  function  to  predict  the
  2272.        value  of the dependent variable, rather than using the mean value,
  2273.        a second kind of variance can be computed by taking the sum of  the
  2274.        squared  difference  between  the  value  of the dependent variable
  2275.        predicted by the function and the  actual  value.   Hopefully,  the
  2276.        variance  computed by using the values predicted by the function is
  2277.        better (i.e., a smaller value) than  the  variance  computed  using
  2278.        the   mean  value.   The  "Proportion  of  variance  explained"  is
  2279.        computed as 1 - (variance using predicted value  /  variance  using
  2280.        mean).   If  the function perfectly predicts the observed data, the
  2281.        value of this statistic will be 1.00 (100%).  If the function  does
  2282.        no  better  a  job  of predicting the dependent variable than using
  2283.        the mean, the value will be 0.00.
  2284.  
  2285.        4.8 Adjusted Coefficient of Multiple Determination
  2286.  
  2287.        The "adjusted coefficient of multiple determination (Ra^2)"  is  an
  2288.        R^2  statistic  adjusted  for  the  number  of  parameters  in  the
  2289.        equation and the  number  of  data  observations.   It  is  a  more
  2290.        conservative   estimate  of  the  percent  of  variance  explained,
  2291.        especially when the sample size is small compared to the number  of
  2292.        parameters.  It is computed using the formula:
  2293.  
  2294.             Ra^2 = 1 - (n-1)/(n-p) * (1-R^2)
  2295.  
  2296.        where  'n'  is  the  number  of  observations, 'p' is the number of
  2297.        parameters, and 'R^2' is the  unadjusted  coefficient  of  multiple
  2298.        determination.
  2299.  
  2300.        4.9 Durbin-Watson Statistic
  2301.  
  2302.        The  "Durbin-Watson  test  for autocorrelation" is a statistic that
  2303.        indicates the likelihood that the deviation (error) values for  the
  2304.        regression   have  a  first-order  autoregression  component.   The
  2305.        regression  models   assume   that   the   error   deviations   are
  2306.        uncorrelated.
  2307.  
  2308.        In  business  and  economics,  many regression applications involve
  2309.        time series data.  If a non-periodic function, such as  a  straight
  2310.        line,  is  fitted  to  periodic data the deviations have a periodic
  2311.        form and are positively correlated over time; these deviations  are
  2312.        said    to    be   "autocorrelated"   or   "serially   correlated."
  2313.  
  2314.        Chapter 4. Understanding The Results                             40
  2315.  
  2316.  
  2317.        Autocorrelated deviations may also indicate that the  form  (shape)
  2318.        of  the  function being fitted is inappropriate for the data values
  2319.        (e.g., a linear equation fitted to quadratic data).
  2320.  
  2321.        If the deviations are autocorrelated, there  may  be  a  number  of
  2322.        consequences  for the computed results: 1) The estimated regression
  2323.        coefficients no longer have the minimum variance property;  2)  the
  2324.        mean  square  error  (MSE) may seriously underestimate the variance
  2325.        of  the  error  terms;  3)  the  computed  standard  error  of  the
  2326.        estimated  parameter  values  may  underestimate  the true standard
  2327.        error, in which case the t values and confidence intervals  may  be
  2328.        incorrect.   Note  that  if  an  appropriate  periodic  function is
  2329.        fitted to periodic data, the deviations from  the  regression  will
  2330.        be  uncorrelated  because the cycle of the data values is accounted
  2331.        for by the fitted function.
  2332.  
  2333.        Small values of the Durbin-Watson statistic indicate  the  presence
  2334.        of   autocorrelation.    Consult  significance  tables  in  a  good
  2335.        statistics book for exact interpretations; however,  a  value  less
  2336.        than  0.80  usually  indicates  that autocorrelation is likely.  If
  2337.        the Durbin-Watson statistic indicates that the residual values  are
  2338.        autocorrelated,  it  is  recommended  that you use the RPLOT and/or
  2339.        NPLOT statements to display a plot of the residual values.
  2340.  
  2341.        If  the  data  has  a  regular,  periodic  component  you  can  try
  2342.        including  a sin term in your function.  The TREND.NLR example fits
  2343.        a function with a sin term to data that has a linear growth with  a
  2344.        superimposed  sin  component.  With the sin term the function has a
  2345.        residual value  of  29.39  and  a  Durbin-Watson  value  of  2.001;
  2346.        without  the  sin  term  (i.e., fitting only a linear function) the
  2347.        residual value is 119.16  and  the  Durbin-Watson  value  is  0.624
  2348.        indicating  strong autocorrelation.  The general form of a sin term
  2349.        is
  2350.  
  2351.             amplitude*sin(2*pi*(x-phase)/period)
  2352.  
  2353.        where 'amplitude' is a parameter that determines the  magnitude  of
  2354.        the   sin   component,   'period'  determines  the  period  of  the
  2355.        oscillation, and 'phase'  determines  the  phase  relative  to  the
  2356.        starting  value.  If you know the period (e.g., 12 for monthly data
  2357.        with an annual cycle) you should  specify  it  rather  than  having
  2358.        NLREG attempt to determine it.
  2359.  
  2360.        If  an NPLOT statement is used to produce a normal probability plot
  2361.        of the residuals, the correlation between the residuals  and  their
  2362.        expected   values  (assuming  they  are  normally  distributed)  is
  2363.        printed  in  the  listing.    If   the   residuals   are   normally
  2364.        distributed,   the   correlation   should  be  close  to  1.00.   A
  2365.        correlation less than 0.94 suggests  that  the  residuals  are  not
  2366.        normally distributed.
  2367.  
  2368.        Chapter 4. Understanding The Results                             41
  2369.  
  2370.  
  2371.        4.10 Analysis of Variance Table
  2372.  
  2373.        An  "Analysis  of  Variance"  table  provides  statistics about the
  2374.        overall significance of the model being fitted.
  2375.  
  2376.        4.10.1 F Value and Prob(F)
  2377.  
  2378.        The  "F  value"  and  "Prob(F)"   statistics   test   the   overall
  2379.        significance  of the regression model.  Specifically, they test the
  2380.        null hypothesis that all of the regression coefficients  are  equal
  2381.        to  zero.   This  tests  the  full  model  against  a model with no
  2382.        variables and with the estimate of  the  dependent  variable  being
  2383.        the  mean  of the values of the dependent variable.  The F value is
  2384.        the ratio of the mean regression sum  of  squares  divided  by  the
  2385.        mean  error  sum  of squares.  Its value will range from zero to an
  2386.        arbitrarily large number.
  2387.  
  2388.        The value of Prob(F) is the probability that  the  null  hypothesis
  2389.        for  the  full  model  is  true  (i.e.,  that all of the regression
  2390.        coefficients are zero).  For example, if Prob(F)  has  a  value  of
  2391.        0.01000  then  there  is 1 chance in 100 that all of the regression
  2392.        parameters are zero.  This low a value would imply  that  at  least
  2393.        some  of  the  regression  parameters  are  nonzero  and  that  the
  2394.        regression equation does have some validity  in  fitting  the  data
  2395.        (i.e.,  the  independent  variables  are  not  purely  random  with
  2396.        respect to the dependent variable).
  2397.  
  2398.        4.11 Correlation Matrix
  2399.  
  2400.        The CORRELATE statement can be used  to  cause  NLREG  to  print  a
  2401.        correlation  matrix.   A  "correlation coefficient" is a value that
  2402.        indicates whether  there  is  a  linear  relationship  between  two
  2403.        variables.   The absolute value of the correlation coeffecient will
  2404.        be in the range 0 to 1.  A value of 0 indicates that  there  is  no
  2405.        relationship  whereas  a  value  of  1  indicates  that  there is a
  2406.        perfect correlation and the two variables vary together.  The  sign
  2407.        of  the  correlation  coefficient  will  be negative if there is an
  2408.        inverse relationship between the variables (i.e., as one  increases
  2409.        the other decreases).
  2410.  
  2411.        For  example, consider a study measuring the height and weight of a
  2412.        group of individuals.  The correlation coefficient  between  height
  2413.        and  weight  will  likely  have a positive value somewhat less than
  2414.        one because tall people tend to weight more than short  people.   A
  2415.        study  comparing number of cigarettes smoked with age at death will
  2416.        probably have a negative correlation value.
  2417.  
  2418.        A correlation matrix shows the correlation  between  each  pair  of
  2419.        variables.   The  diagonal of the matrix has values of 1.00 because
  2420.        a variable always has  a  perfect  correlation  with  itself.   The
  2421.        matrix  is symmetric about the diagonal because X correlated with Y
  2422.        is the same as Y correlated with X.
  2423.  
  2424.        Problems occur in regression analysis when a function is  specified
  2425.        that   has   multiple   independent   variables   that  are  highly
  2426.  
  2427.        Chapter 4. Understanding The Results                             42
  2428.  
  2429.  
  2430.        correlated.  The common interpretation of the  computed  regression
  2431.        parameters  as  measuring  the  change in the expected value of the
  2432.        dependent variable when the corresponding independent  variable  is
  2433.        varied  while  all other independent variables are held constant is
  2434.        not fully applicable when a  high  degree  of  correlation  exists.
  2435.        This  is  due  to  the fact that with highly correlated independent
  2436.        variables it is difficult to attribute  changes  in  the  dependent
  2437.        variable  to  one of the independent variables rather than another.
  2438.        The  following  are  effects  of  fitting  a  function  with   high
  2439.        correlated independent variables:
  2440.  
  2441.        1.  Large  changes in the estimated regression parameters may occur
  2442.            when a variable is added or deleted, or when an observation  is
  2443.            added or deleted.
  2444.  
  2445.        2.  Individual  tests  on  the  regression  parameters may show the
  2446.            parameters to be nonsignificant.
  2447.  
  2448.        3.  Regression parameters may have the oppsite algebraic sign  than
  2449.            expected from theoretical or practical considerations.
  2450.  
  2451.        4.  The  conficence  intervals  for important regression parameters
  2452.            may be be much wider than would otherwise be the case.
  2453.  
  2454.        The  solution  to  these  problems  may  be  to  select  the   most
  2455.        significent  of  the  correlated  variables  and use only it in the
  2456.        function.
  2457.  
  2458.        Note: the correlation coefficients indicate the  degree  of  linear
  2459.        association  between variables.  Variables may be highly related in
  2460.        a nonlinear fashion and still have a  correlation  coefficent  near
  2461.        0.
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.                                     Chapter 5
  2469.  
  2470.                                Theory of Operation
  2471.  
  2472.  
  2473.  
  2474.  
  2475.        5.1 Minimization Algorithm
  2476.  
  2477.        NLREG  uses  a  model/trust-region technique along with an adaptive
  2478.        choice of the  model  Hessian.   The  algorithm  is  essentially  a
  2479.        combination   of   Gauss-Newton  and  Levenberg-Marquardt  methods;
  2480.        however, the  adaptive  algorithm  often  works  much  better  than
  2481.        either of these methods alone.
  2482.  
  2483.        The  basis  for  the  minimization  technique  used  by NLREG is to
  2484.        compute the sum of the squared residuals for one set  of  parameter
  2485.        values  and  then slightly alter each parameter value and recompute
  2486.        the sum of squared residuals to see how the parameter value  change
  2487.        affects  the  sum  of  the  squared  residuals.   By  dividing  the
  2488.        difference between the original and new  sum  of  squared  residual
  2489.        values  by  the  amount the parameter was altered, NLREG is able to
  2490.        determine the approximate partial derivative with  respect  to  the
  2491.        parameter.   This partial derivative is used by NLREG to decide how
  2492.        to alter the value of the parameter for the next iteration.
  2493.  
  2494.        If the function being modeled is well  behaved,  and  the  starting
  2495.        value  for the parameter is not too far from the optimum value, the
  2496.        procedure will eventually converge to the  best  estimate  for  the
  2497.        parameter.   This  procedure  is carried out simultaneously for all
  2498.        parameters  and  is,   in   fact,   a   minimization   problem   in
  2499.        n-dimensional space, where 'n' is the number of parameters.
  2500.  
  2501.        For  a  much  more detailed explanation of the regression algorithm
  2502.        used by NLREG see ACM Transactions  on  Mathematical  Software  7,3
  2503.        (Sept.   1981)  "Dennis,  J.E.,  Gay, D.M., and Welsch, R.E.  -- An
  2504.        adaptive nonlinear least-squares algorithm."
  2505.  
  2506.        5.2 Convergence Criterion
  2507.  
  2508.        NLREG has several convergence  criteria  that  stop  the  iterative
  2509.        minimization  procedure.   The  TOLERANCE  statement can be used to
  2510.        alter the convergence tolerance value.
  2511.  
  2512.        Two internal variables are used to determine when  convergence  has
  2513.        occurred.   RFCTOL  has a default value of 1E-10 and can be altered
  2514.        by use of the TOLERANCE statement.  AFCTOL has a default  value  of
  2515.        1E-20  and  is only altered by the TOLERANCE statement if the value
  2516.        specified is less than the default value.  In the discussion  which
  2517.  
  2518.  
  2519.  
  2520.                                        43
  2521.  
  2522.        Chapter 5. Theory of Operation                                   44
  2523.  
  2524.  
  2525.        follows  the  "function  value"  is  half  the  sum  of the squared
  2526.        residuals computed using the current parameter estimates.
  2527.  
  2528.        "Relative  function  convergence"  is  reported  if  the  predicted
  2529.        maximum  possible  function  reduction  is  at  most RFCTOL*ABS(F0)
  2530.        where F0 is  the  function  value  at  the  start  of  the  current
  2531.        iteration,  and  if  the  last step attempted achieved no more than
  2532.        twice the predicted function decrease.
  2533.  
  2534.        "Absolute function convergence" is reported if the  function  value
  2535.        is less than AFCTOL.
  2536.  
  2537.  
  2538.  
  2539.  
  2540.  
  2541.  
  2542.                                     Chapter 6
  2543.  
  2544.                                Hints for NLREG Use
  2545.  
  2546.  
  2547.  
  2548.  
  2549.        6.1 Convergence Failures
  2550.  
  2551.        One   of  the  potential  problems  that  confronts  any  nonlinear
  2552.        minimization  procedure  is  non-convergence.   Non-convergence  is
  2553.        usually  not  a  problem  for regressions using a linear model, but
  2554.        becomes  a  more  serious  consideration  when  using   complicated
  2555.        nonlinear   functions;   increasing   the   number   of  parameters
  2556.        aggravates the problem.
  2557.  
  2558.        Non-convergence can occur in two ways: the solution may diverge  or
  2559.        it  may  converge  to  the wrong solution -- a local minimum rather
  2560.        than the global minimum.  Periodic  functions,  such  as  sin,  and
  2561.        cos,  are particularly prone to convergence problems.  For example,
  2562.        consider a nonlinear regression performed with the function:
  2563.  
  2564.             y = offset + amplitude * sin(frequency * x)
  2565.  
  2566.        where x and y are variables, and offset, amplitude,  and  frequency
  2567.        are  the  parameters  whose  values  are  to be determined.  If the
  2568.        starting value  for  frequency  is  not  reasonably  close  to  the
  2569.        correct  value,  the solution may converge to a harmonic (multiple)
  2570.        or subharmonic (fundamental) value of  the  frequency.   A  command
  2571.        file  named  SINE.NLR  is  supplied with the statements and data to
  2572.        perform this analysis.
  2573.  
  2574.        If NLREG stops with the message "False convergence" this  indicates
  2575.        that  the  iterations  appear  to  be  converging  to a noncritical
  2576.        point.  This may mean  that  the  convergence  tolerances  are  too
  2577.        small  for  the  accuracy  to  which  the function and gradient are
  2578.        being computed, that there is an error in computing  the  gradient,
  2579.        or that the function or gradient is discontinuous near x.
  2580.  
  2581.        The  SWEEP  statement  can  be  very  useful in cases like the sine
  2582.        example.  In the SINE.NLR example analysis,  the  actual  value  of
  2583.        the  frequency is 3; the function converges to the correct solution
  2584.        if the starting value is in the range 2.6 to  3.3.   However,  this
  2585.        example   is  quite  insensitive  to  the  starting  value  of  the
  2586.        amplitude parameter.  With  an  actual  value  of  2,  the  correct
  2587.        solution  is  found  with  starting  values  from  1 through 10000.
  2588.        Similarly, the offset parameter, which had an actual value  of  10,
  2589.        was  successfully determined with starting values ranging from 1 to
  2590.        over 50000.
  2591.  
  2592.  
  2593.  
  2594.                                        45
  2595.  
  2596.        Chapter 6. Hints for NLREG Use                                   46
  2597.  
  2598.  
  2599.        Another example which is sensitive to a  parameter  starting  value
  2600.        is  POWER.NLR  which  attempts  to  determine  the  values  of  the
  2601.        parameters p0, p1, and p2 for the function
  2602.  
  2603.             y = p0 + p1*x^p2
  2604.  
  2605.        (where "x^p2" means x raised to the p2 power).   The  actual  value
  2606.        of  p2  in  the example data is 2; the solution converges correctly
  2607.        if the starting value of p2 is in the range 1.8 to  3.8.   As  with
  2608.        the  other  example,  the solution is relatively insensitive to the
  2609.        starting values of p0 and p1.
  2610.  
  2611.        6.2 Singular Matrix Problems
  2612.  
  2613.        Another possible problem is that the analysis  may  stop  with  the
  2614.        message  "Singular  convergence.   Mutually dependent parameters?".
  2615.        This is  usually  due  to  one  of  two  things:  (1)  a  redundant
  2616.        parameter  that  is  co-dependent  with another parameter, or (2) a
  2617.        situation where the value of one parameter "blocks" the  effect  of
  2618.        other   parameters.   As  an  example  of  a  redundant  parameter,
  2619.        consider the function
  2620.  
  2621.             y = p0 + p1*p2*x
  2622.  
  2623.        This is a simple linear equation except there are  two  parameters,
  2624.        p1,  and  p2,  which are both factors to the variable x.  It should
  2625.        be clear that there is no unique solution  to  this  problem  since
  2626.        any  value  of  p1  is possible if the right value of p2 is chosen.
  2627.        Similarly, the function
  2628.  
  2629.             y = p0 + p1 + p2*x
  2630.  
  2631.        has no  unique  solution  since  either  p0  or  p1  is  redundant.
  2632.        Similarly, in the equation
  2633.  
  2634.             y = p0 + p1*exp(x+p2)
  2635.  
  2636.        either p1 or p2 is redundant.
  2637.  
  2638.        The  second  type  of singular matrix problem can be illustrated by
  2639.        the function
  2640.  
  2641.             y = p0 + p1*x^p2
  2642.  
  2643.        If, during the solution process, p1 takes  on  the  value  0,  then
  2644.        varying  the  value  of  p2 has no effect on the equation and NLREG
  2645.        cannot figure out which way to change  the  value  of  p2  to  move
  2646.        toward  convergence.   The  solution to this problem is to assign a
  2647.        starting value that is not  zero  to  p1,  and  use  the  CONSTRAIN
  2648.        statement to force p1 to remain non-zero.
  2649.  
  2650.        Chapter 6. Hints for NLREG Use                                   47
  2651.  
  2652.  
  2653.        6.3 Performance Issues
  2654.  
  2655.        NLREG  is  carefully  programmed  and  compiled  with an optimizing
  2656.        compiler  for  maximum  performance.   However,  NLREG  is  a  real
  2657.        "number  cruncher,"  and  the  nonlinear  regression  algorithm  is
  2658.        mathematically  very  elaborate.   During  each  iteration,   NLREG
  2659.        computes  gradients,  Jacobians,  Hessians,  and  eigenvalues,  and
  2660.        performs QR and Cholesky matrix decompositions.   All  calculations
  2661.        are carried out using double precision (64 bit) floating point.
  2662.  
  2663.        NLREG  does  not  require  an  80x87  numeric  coprocessor, but its
  2664.        performance is greatly enhanced if one is  present.   In  fact,  an
  2665.        8088  CPU  with  an 8087 numeric coprocessor can perform regression
  2666.        analyses  faster  than  a  20  MHz  80386  that  does  not  have  a
  2667.        coprocessor.   If  you  have  an  8088  without  a  coprocessor, be
  2668.        patient -- NLREG is probably giving it the workout of its life.
  2669.  
  2670.        Very long running times can result if you use the  SWEEP  statement
  2671.        with  many  starting values.  The problem is compounded if you have
  2672.        multiple SWEEP statements.  If you use the SWEEP statement  to  try
  2673.        a  large  number of starting parameter values, you can save time by
  2674.        using the  ITERATIONS  statement  to  specify  a  small  number  of
  2675.        iterations  (such  as  5)  during  the  initial  attempt  to find a
  2676.        solution.  Once a feasible set of  starting  parameter  values  has
  2677.        been  determined,  remove the SWEEP statement, specify the starting
  2678.        values  on  the  PARAMETERS  statement,  increase  the  number   of
  2679.        iterations, and rerun the analysis to get the final result.
  2680.  
  2681.        6.4 Program Limits
  2682.  
  2683.        The following is a summary of the NLREG program limitations:
  2684.  
  2685.             Maximum number of variables = 25
  2686.             Maximum number of parameters = 25
  2687.             Maximum length of variable or parameter names = 10
  2688.  
  2689.        The  maximum  number  of  data  observations  that NLREG can handle
  2690.        depends on the number of parameters as  shown  by  the  table  that
  2691.        follows:
  2692.  
  2693.             # Parameters    Max Observations
  2694.                   1               2019
  2695.                   2               1611
  2696.                   3               1339
  2697.                   4               1144
  2698.                   5                997
  2699.                   6                883
  2700.                   7                791
  2701.                   8                715
  2702.                   9                652
  2703.                  10                599
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.                                     Chapter 7
  2711.  
  2712.                                 Example Analyses
  2713.  
  2714.  
  2715.  
  2716.  
  2717.        A  number  of  example  regression analysis files are provided with
  2718.        your NLREG distribution.  All of the  example  command  files  have
  2719.        the  extension  ".NLR".   Some  of the important ones are described
  2720.        below, others contain comment lines that explain what they do.
  2721.  
  2722.        LINEAR.NLR -- Simple linear regression with  plotted  function  and
  2723.            data.
  2724.  
  2725.        QUAD.NLR  --  Fit  a quadratic equation.  Plot the function and the
  2726.            data.
  2727.  
  2728.        ASYMPTOT.NLR -- Fit an asymptotic function Y = 12 - 10/X.
  2729.  
  2730.        AIDS.NLR -- A logistic curve  is  a  growth  curve  used  to  model
  2731.            functions  which  increase  gradually at first, more rapidly in
  2732.            the middle growth period, and slowly at the end,  leveling  off
  2733.            at  a  maximum  value  after some period of time.  This type of
  2734.            curve is frequently used to model  biological  growth  patterns
  2735.            where  there  is  an initial exponential growth period followed
  2736.            by a leveling off as more of the population is infected  or  as
  2737.            the  food  supply  or  some other factor limits further growth.
  2738.            The form of the symmetric logistic growth function is:
  2739.  
  2740.                 y = k / (1 + exp(a + b*x))
  2741.  
  2742.            where 'k', 'a', and 'b' are parameters  that  shape  and  scale
  2743.            the function.  The value of 'b' is negative.
  2744.  
  2745.            The  AIDS.NLR  example  fits  a logistic curve to the number of
  2746.            new cases of AIDS reported in  the  United  States  during  the
  2747.            period  1981 through 1992.  The computed function fits the data
  2748.            remarkably  well  showing  that  the  AIDS  infection  rate  is
  2749.            following  a  classic  logistic  curve  and should level off at
  2750.            about 47,500 new cases per year (in the  United  States).   The
  2751.            DOMAIN   option   on   the   PLOT  statement  causes  NLREG  to
  2752.            extrapolate the plot of the function through 1995.
  2753.  
  2754.        F33.NLR -- Multivariate linear  regression  (multiple  regression).
  2755.            Calculate  the value of a used Beech F33 Bonanza airplane using
  2756.            a linear model based on its age, the number  of  hours  on  its
  2757.            airframe,  and  the number of hours on its engine.  The t value
  2758.            and Prob(t) indicate that the number of  hours  on  the  engine
  2759.            ('Engdep'  parameter)  is  not  significant  to  the regression
  2760.  
  2761.  
  2762.                                        48
  2763.  
  2764.        Chapter 7. Example Analyses                                      49
  2765.  
  2766.  
  2767.            model; the other parameters are significant but airframe  hours
  2768.            is less significant than the base price and age of the plane.
  2769.  
  2770.        F33YEAR.NLR  --  Similar to F33.NLR except the price of the Bonanza
  2771.            is calculated based on a linear function of only the age.
  2772.  
  2773.        F33EXP.NLR -- Similar to F33YEAR.NLR except a negative  exponential
  2774.            function  is  used  rather than a linear function.  Compare the
  2775.            fit of this model with that of the F33YEAR.NLR example.
  2776.  
  2777.        SINE.NLR -- Fit an equation involving a sin  function.   The  SWEEP
  2778.            statement is used to find a starting point that will converge.
  2779.  
  2780.        TREND.NLR  --  Fit  a  function that has a linear growth term and a
  2781.            periodic component involving a sin term.  See Section  4.9  for
  2782.            additional information about this example.
  2783.  
  2784.        SQUARE.NLR  --  Fit  a  sine series to a square wave.  Note in this
  2785.            example that the 'p0' parameter, which represents the  constant
  2786.            term  of  the  equation, has an estimated value of 9.22715E-006
  2787.            (very nearly zero) and a standard  error  of  0.0398754.   This
  2788.            yields  a  t  value of nearly zero and Prob(t) of 0.99982 which
  2789.            means that there is a 99.982% chance that the actual  value  of
  2790.            p0  may be zero (it is in fact zero).  This illustrates how you
  2791.            can  use  the  t  value  and  Prob(t)  to  identify  extraneous
  2792.            parameters.
  2793.  
  2794.        COOLING.NLR  --  Fit an equation involving an exponential function.
  2795.            If a heated object is allowed to cool, the rate of  cooling  at
  2796.            any  instant  is  proportional  to  the  difference between the
  2797.            object's temperature and the ambient  (room)  temperature.   In
  2798.            other  words, an object cools faster at first, while it is hot,
  2799.            and the rate of cooling slows down as the  temperature  of  the
  2800.            object  approaches  the ambient temperature.  The function that
  2801.            relates the object's temperature to time is:
  2802.  
  2803.                 Temperature = Roomtemp+InitTemp*exp(-Coolrate*Time)
  2804.  
  2805.            Where InitTemp is the number of degrees above room  temperature
  2806.            at  time  0,  and Coolrate is a factor that depends on the mass
  2807.            of the  object,  how  well  it  is  insulated,  etc.   The  exp
  2808.            function  is  the  value of e (2.7182818...) raised to a power.
  2809.            The COOLING.NLR example determines the parameters InitTemp  and
  2810.            Coolrate  to  fit  an  equation  of  this form to some data the
  2811.            author collected.
  2812.  
  2813.        BOIL.NLR -- The boiling point of water decreases  as  the  pressure
  2814.            in  the  vessel  containing  the water decreases.  "Clapeyron's
  2815.            equation" shows that the boiling point is related  to  pressure
  2816.            according to the following function:
  2817.  
  2818.                 Temperature = b / log(Pressure/a) - 459.7
  2819.  
  2820.            Where   'Temperature'  is  in  degrees  Fahrenheit  (the  459.7
  2821.            constant converts degrees  Fahrenheit  to  degrees  Rankine  --
  2822.  
  2823.        Chapter 7. Example Analyses                                      50
  2824.  
  2825.  
  2826.            relative  to  absolute zero), 'Pressure' is the pressure in the
  2827.            vessel  in  pounds  per  square  inch,  and  'a'  and  'b'  are
  2828.            parameters  whose  values  are  to be determined.  The data for
  2829.            this example was collected by the author's son  for  a  science
  2830.            project.
  2831.  
  2832.        MAGNET.NLR  --  Fit  a  function  involving  an  arc  tangent and a
  2833.            variable to the third power.  This is  an  interesting  physics
  2834.            problem.   If  a  magnet  is  placed due east of a compass, the
  2835.            deflection of the compass needle from north  is  equal  to  the
  2836.            arc  tangent of the ratio of the strength of the magnet's field
  2837.            relative to the earth's magnetic field.  The  strength  of  the
  2838.            magnet's  field at the compass is inversely proportional to the
  2839.            cube of the distance from the magnet  to  the  compass.   Thus,
  2840.            the function relating these terms is
  2841.  
  2842.                 Deflection = deg(atan(Strength / Distance ^ 3))
  2843.  
  2844.            The  deg  function converts an angle in radians to degrees.  In
  2845.            the example, Deflection and Distance  are  the  variables,  and
  2846.            the value of the Strength parameter is determined.
  2847.  
  2848.        DIODE.NLR  --  The current through a diode increases sharply as the
  2849.            voltage across  the  diode  is  increased.   An  equation  that
  2850.            approximates the current flow as a function of the voltage is:
  2851.  
  2852.                 I = exp(b*(V-c))
  2853.  
  2854.            where  'I' is the current, 'V' is the voltage, and 'b', and 'c'
  2855.            are parameters that  are  to  be  estimated  by  the  nonlinear
  2856.            regression.
  2857.  
  2858.        AVLTIME.NLR  -- An AVL tree is a balanced binary tree used to store
  2859.            information in a computer's memory.  Because the entries in  an
  2860.            AVL  tree  are  kept in sorted order, and the tree is kept in a
  2861.            balanced form, it is possible to rapidly find any entry in  the
  2862.            tree.   The  time required to create an AVL tree with N entries
  2863.            is approximately equal to:
  2864.  
  2865.                 Time = a + b*N*log2(N)
  2866.  
  2867.            where 'a' is a constant term equal to the overhead involved  in
  2868.            starting  and  completing  a tree creation, and 'b' is a growth
  2869.            coefficient that depends on the speed  of  the  computer.   The
  2870.            log2(N)  function  is  the  log  base  2  of  N  (the number of
  2871.            entries).  The AVLTIME.NLR example fits an equation to  a  data
  2872.            set  that relates the time in seconds required to create an AVL
  2873.            tree with the number of entries in the tree.
  2874.  
  2875.        PIECE.NLR -- Piecewise linear function.  Fit a function  consisting
  2876.            of  two linear pieces that bend at X=5.  When X is less than 5,
  2877.            the slope of the function is B1.  When X  is  greater  than  or
  2878.            equal  to  5,  the  slope  is  B2.   B0  is  the Y value of the
  2879.            function at X=5 (i.e., at the pivot point).  The  IF  statement
  2880.            is  used  to  control which function model is used depending on
  2881.  
  2882.        Chapter 7. Example Analyses                                      51
  2883.  
  2884.  
  2885.            whether the value of the dependent variable is greater than  or
  2886.            less than the pivot point.
  2887.  
  2888.  
  2889.  
  2890.  
  2891.  
  2892.  
  2893.                                     Chapter 8
  2894.  
  2895.                               Special Applications
  2896.  
  2897.  
  2898.  
  2899.  
  2900.        8.1 Omitted Dependent Variable
  2901.  
  2902.        There  is a class of nonlinear regression problems that can be best
  2903.        expressed by omitting the dependent variable  (i.e.,  the  variable
  2904.        on  the  left  of  the  equal sign).  To understand what this means
  2905.        first  consider  the  normal  regression  case  with  a   dependent
  2906.        variable.   For  each observation the function is evaluated and the
  2907.        computed value is subtracted from the corresponding  value  of  the
  2908.        dependent  variable  for  that observation.  This residual value is
  2909.        then squared and added to the other squared residual  values.   The
  2910.        goal  is  to  minimize  the total sum of squared residuals.  In the
  2911.        case where the dependent  variable  is  omitted,  the  function  is
  2912.        computed  for  each  observation  and  the value of the function is
  2913.        squared (i.e., it is treated as the  residual)  and  added  to  the
  2914.        other  squared  values.   The  goal  is  to minimize the sum of the
  2915.        squared values of the  function.   Thus,  for  a  perfect  fit  the
  2916.        computed  value  of  the  function  for  every observation would be
  2917.        zero.
  2918.  
  2919.        To perform this type of analysis omit the  dependent  variable  and
  2920.        equal sign from the left side of the function specification.
  2921.  
  2922.        As  an  example  of  this  type of analysis consider the problem of
  2923.        fitting a circle to a set of points that form  a  roughly  circular
  2924.        pattern  (i.e., a "circular regression").  Our goal is to determine
  2925.        the center point of the circle (Xc,Yc) and  the  radius  (R)  which
  2926.        will  make  the  circle  best fit the points so that the sum of the
  2927.        squared distances between the  points  and  the  perimeter  of  the
  2928.        circle  is  minimized  (the points are as close to the perimeter of
  2929.        the circle as possible).
  2930.  
  2931.        For this problem we have three parameters whose values  are  to  be
  2932.        determined:  Xc, Yc, and R.  There will be one data observation for
  2933.        each point to which the circle is being  fitted.   For  each  point
  2934.        there  are two variables, Xp and Yp, the X and Y coordinates of the
  2935.        point's position.
  2936.  
  2937.        Since our goal is to minimize the  sum  of  the  squared  distances
  2938.        from  the points to the perimeter of the circle, we need a function
  2939.        that will compute this distance for each point.  If the  center  of
  2940.        the  circle  is  at  (Xc,Yc) and the position of a point is (Xp,Yp)
  2941.        then, from the theorem of Pythagoras, we  know  the  distance  from
  2942.        the center to the point is
  2943.  
  2944.  
  2945.                                        52
  2946.  
  2947.        Chapter 8. Special Applications                                  53
  2948.  
  2949.  
  2950.             sqrt((Xp-Xc)^2 + (Yp-Yc)^2)
  2951.  
  2952.        But  we  are  interested  in the distance from the perimeter to the
  2953.        point.  Since the radius of the circle is R, the distance from  the
  2954.        perimeter  to  the  point (along a straight line from the center to
  2955.        the point) is
  2956.  
  2957.             sqrt((Xp-Xc)^2 + (Yp-Yc)^2) - R
  2958.  
  2959.        That is, the distance from the perimeter to the point is  equal  to
  2960.        the  distance  from  the center to the point less the distance from
  2961.        the center to the perimeter (the radius).   The  distance  will  be
  2962.        positive  or  negative depending on whether the point is outside or
  2963.        inside the circle but this does  not  matter  since  the  value  is
  2964.        squared as part of the minimization process.
  2965.  
  2966.        The NLREG statements for this analysis are as follows:
  2967.  
  2968.             Variables  Xp,Yp;
  2969.             Parameters Xc,Yc,R;
  2970.             Function   sqrt((Xp-Xc)^2 + (Yp-Yc)^2) - R;
  2971.  
  2972.        Note  that there is no dependent variable or equal sign to the left
  2973.        of  the  function.   NLREG  will  determine  the  values   of   the
  2974.        parameters  Yp,  Yc,  and R such that the sum of the squared values
  2975.        of the function  (i.e.,  the  sum  of  the  squared  distances)  is
  2976.        minimized.   The  CIRCLE.NLR  file  contains a full example of this
  2977.        analysis.
  2978.  
  2979.        As a second example similar to the first one, consider a town  that
  2980.        is  trying  to  decide where to place a fire station.  The location
  2981.        should be central such that the sum of the squared  distances  from
  2982.        the  station  to  each  house  is  minimized.  NLREG can be used to
  2983.        determine the coordinates of the station (Xc,Yc)  given  a  set  of
  2984.        coordinates  for  each  house  location (Xh,Yh) by using a slightly
  2985.        simpler function than the first example:
  2986.  
  2987.             Function  sqrt((Xh-Xc)^2 + (Yh-Yc)^2);
  2988.  
  2989.  
  2990.        8.2 Root Finding and Expression Minimization
  2991.  
  2992.        Although it is designed for nonlinear  regression  analysis,  NLREG
  2993.        can  also be used to find the root (zero point) or minimum absolute
  2994.        value of a nonlinear expression.  To  use  NLREG  in  this  fashion
  2995.        follow these steps:
  2996.  
  2997.          . Do not use any VARIABLE statements.
  2998.  
  2999.          . Use  PARAMETER  statements  to  specify  the names and optional
  3000.            starting values for the  parameters  whose  values  are  to  be
  3001.            determined as the roots or minimum value of the expression.
  3002.  
  3003.          . Use  the  FUNCTION  statement  to  specify the expression whose
  3004.            roots or minimum value  is  to  be  found;  do  NOT  specify  a
  3005.  
  3006.        Chapter 8. Special Applications                                  54
  3007.  
  3008.  
  3009.            dependent   variable   and  equal  sign  --  specify  only  the
  3010.            expression that is to be minimized.
  3011.  
  3012.          . Do not include any data records after the  DATA  statement;  it
  3013.            simply  signals  the  end  of  the  command file and causes the
  3014.            analysis to begin.
  3015.  
  3016.        The following is an example command file to find the  root  of  the
  3017.        expression sin(x)-log(x):
  3018.  
  3019.             Parameter x;
  3020.             Function sin(x) - log(x);
  3021.             Data;
  3022.  
  3023.        Notice  that  the  "variable" in the expression, X, is not declared
  3024.        to be a variable but rather a parameter.  This example is  included
  3025.        in the file MINSL.NLR which you can run.
  3026.  
  3027.        For  this  type  of  analysis,  NLREG  determines the values of the
  3028.        parameters that minimize the absolute value of the expression.   If
  3029.        the  expression  has  a  zero  value  (i.e., a root), that value is
  3030.        found since that is the smallest possible absolute value.   If  the
  3031.        expression  does not have a zero point, NLREG determines the values
  3032.        of the parameters that produce the smallest absolute value  of  the
  3033.        expression.   For  example,  the  expression  2*X^2-3*X+10 does not
  3034.        have a root but reaches a minimum value of 8.875 when  X  is  0.75.
  3035.        The MINPAROB.NLR command file contains this example.
  3036.  
  3037.        There  are  a  number of cautions that you should keep in mind when
  3038.        using NLREG to find roots or minimum values:
  3039.  
  3040.          . NLREG will find only one root or minimum  value  per  analysis.
  3041.            For  example,  the  expression  9-X^2 has two roots: -3 and +3.
  3042.            NLREG will find one of the roots; which one  it  finds  depends
  3043.            on the starting value specified for X.
  3044.  
  3045.          . NLREG will find only real roots, not complex.
  3046.  
  3047.          . If  the  expression contains a local minimum, NLREG may find it
  3048.            rather than the global minimum or root.  Of course, if you  are
  3049.            looking  for  a local minimum in a certain region this could be
  3050.            considered   a   feature.    For   example,   the    expression
  3051.            0.5*X^3+5*(X-2)^2+15  has  a local minimum at X=1.61 and a root
  3052.            at X=-13.38.  If the starting value of X is less than -8.3  the
  3053.            root  is found; if the starting value is greater than -8.3, the
  3054.            local minimum is found.  If  the  expression  contains  only  a
  3055.            single  variable,  use  the  Mathplot  program  to  graphically
  3056.            display the expression and determine a good starting value  for
  3057.            the  variable  (see  page  59  for additional information about
  3058.            Mathplot).  The  SWEEP  statement  can  also  be  used  to  try
  3059.            multiple starting values when searching for a global minimum.
  3060.  
  3061.        Chapter 8. Special Applications                                  55
  3062.  
  3063.  
  3064.        8.2.1 Function Minimization Examples
  3065.  
  3066.        MINFALL.NLR  --  The  time  taken  for  an  object  to slide down a
  3067.            frictionless guide from  position  (0,h)  to  another  position
  3068.            (d,0)  (i.e.,  falling  through  a  distance  'h'  while moving
  3069.            horizontally a distance 'd')  depends  on  the  path  that  the
  3070.            object  takes  as  it follows the guide.  It turns out that the
  3071.            path that minimizes the descent time is  not  a  straight  line
  3072.            from   (0,h)   to   (d,0)   but   rather   a   curve  called  a
  3073.            brachistochrone with a steeper slope near the  beginning,  that
  3074.            gives  the  object  a  chance to accelerate quickly, and then a
  3075.            shallower slope further on.
  3076.  
  3077.            Finding the shape of this curve is a  classic  problem  in  the
  3078.            branch  of  mathematics called the Calculus of Variations.  The
  3079.            MINFALL example solves a simpler  case  of  this  problem:  the
  3080.            object  slides  along  a  straight  guide  from  (0,1000) to an
  3081.            intermediate position (px,py), and then along another  straight
  3082.            guide   from   (px,py)   to  (1000,0).   What  point,  (px,py),
  3083.            minimizes the descent time?
  3084.  
  3085.            Note concerning the answer: The fall time for the object if  it
  3086.            follows  a  straight  guide from (0,1000) to (1000,0) is 2.0203
  3087.            seconds; the fall time if it follows the two straight  segments
  3088.            found  by  MINFALL  is  1.8748; the fall time if it follows the
  3089.            ideal curved brachistochrone  is  1.8590.   The  speed  of  the
  3090.            object  at  the  end  of the fall is the same regardless of the
  3091.            path taken due to conservation of energy.
  3092.  
  3093.        MINFUEL.NLR -- A lunar lander is hovering above the surface of  the
  3094.            moon  looking  for  a suitable landing site.  Available fuel is
  3095.            critical and the desired site is 200  meters  away.   How  long
  3096.            should  the  horizontal thruster be fired to start and stop the
  3097.            motion over the ground?  The vertical  thruster  must  be  used
  3098.            continuously  to  keep  the  lander  from  being  pulled to the
  3099.            surface.   If  too  little  horizontal  thrust  is   used   the
  3100.            spacecraft  will  move slowly and much fuel will be consumed by
  3101.            the   vertical   thruster   counterbalancing    the    downward
  3102.            gravitational  pull  while  hovering  over the surface.  On the
  3103.            other hand, if the horizontal thruster  is  fired  for  a  long
  3104.            time,   the   spacecraft  will  move  quickly  (minimizing  the
  3105.            hovering time) but excessive  fuel  will  be  used  during  the
  3106.            horizontal    acceleration   and   deceleration.    MINFUEL.NLR
  3107.            determines how long the thruster should  be  fired  during  the
  3108.            start   and   stop  accelerations  such  that  the  total  fuel
  3109.            consumption (start thrust + stop thrust + hover) is minimized.
  3110.  
  3111.  
  3112.  
  3113.  
  3114.  
  3115.  
  3116.                                     Chapter 9
  3117.  
  3118.                         Acknowledgement and Use of NLREG
  3119.  
  3120.  
  3121.  
  3122.  
  3123.        9.1 Acknowledgement
  3124.  
  3125.        The nonlinear regression algorithm used by NLREG was  published  in
  3126.        ACM   Transactions  on  Mathematical  Software  7,3  (Sept.   1981)
  3127.        "Dennis,  J.E.,  Gay,  D.M.,  and  Welsch,  R.E.   --  An  adaptive
  3128.        nonlinear least-squares algorithm."
  3129.  
  3130.        9.2 Use and Distribution of NLREG
  3131.  
  3132.        There  are  two  versions  of  the  NLREG  program:  shareware  and
  3133.        registered.  You are  welcome  to  make  copies  of  the  shareware
  3134.        version  of  NLREG and pass them on to friends or post this program
  3135.        on bulletin boards or distribute it via disk catalog  services,  CD
  3136.        ROMS,  or  other  means  provided  the entire NLREG distribution is
  3137.        included in its original, unmodified form.  A distribution fee  may
  3138.        be  charged  for  the  cost of the diskette, shipping and handling.
  3139.        Vendors are encouraged to  contact  the  author  to  get  the  most
  3140.        recent version of NLREG.
  3141.  
  3142.        As  a shareware product, you are granted a no-cost, trial period of
  3143.        30 days during which you may evaluate NLREG.  If you find NLREG  to
  3144.        be  useful,  educational,  and/or entertaining, and continue to use
  3145.        it beyond the 30 day trial period, you are required  to  compensate
  3146.        the  author  by sending the registration form printed at the end of
  3147.        this  document  (and  in   REGISTER.DOC)   with   the   appropriate
  3148.        registration  fee  to  help  cover  the  development and support of
  3149.        NLREG.
  3150.  
  3151.        In return for registering,  you  will  be  authorized  to  continue
  3152.        using  NLREG  beyond  the  trial  period  and  you  will  receive a
  3153.        registered version of the program,  a  bound  typeset  manual,  and
  3154.        three  months  of support via telephone, mail, or CompuServe.  Your
  3155.        registration fee will be refunded if you encounter  a  serious  bug
  3156.        that cannot be corrected.
  3157.  
  3158.        The  registered  version  of NLREG omits the shareware notification
  3159.        screen at the start of the run and does not require you to press  a
  3160.        key  to  proceed  with  the  analysis.  The registered version also
  3161.        includes the ability to print plots on HP LaserJet  printers.   The
  3162.        registered  version  of  NLREG  is  NOT  shareware  and  may not be
  3163.        redistributed or used on more than one computer system.
  3164.  
  3165.  
  3166.  
  3167.  
  3168.                                        56
  3169.  
  3170.        Chapter 9. Acknowledgement and Use of NLREG                      57
  3171.  
  3172.  
  3173.        The author frequently improves NLREG and  it  is  likely  that  the
  3174.        version  you  have  is not the most recent version.  Note, the cost
  3175.        of registering NLREG is insignificant compared with what you  would
  3176.        have  to  pay  to purchase a commercial statistical package with an
  3177.        equivalent regression capability.
  3178.  
  3179.        9.3 Association of Shareware Professionals
  3180.  
  3181.        This program  is  produced  by  a  member  of  the  Association  of
  3182.        Shareware  Professionals  (ASP).   ASP  wants to make sure that the
  3183.        shareware principle works for you.  If you are unable to resolve  a
  3184.        shareware-related  problem  with  an  ASP  member by contacting the
  3185.        member directly, ASP may be able to help.  The  ASP  Ombudsman  can
  3186.        help  you resolve a dispute or problem with an ASP member, but does
  3187.        not provide technical support for members' products.  Please  write
  3188.        to  the  ASP  Ombudsman  at  545 Grover Road, Muskegon, MI 49442 or
  3189.        send a CompuServe message via  CompuServe  Mail  to  ASP  Ombudsman
  3190.        7007,3536.
  3191.  
  3192.        You are welcome to contact the author:
  3193.  
  3194.                                Phillip H. Sherrod
  3195.                                 4410 Gerald Place
  3196.                          Nashville, TN  37205-3806  USA
  3197.                              615-292-2881 (evenings)
  3198.                              CompuServe: 76166,2640
  3199.                        Internet: 76166.2640@compuserve.com
  3200.  
  3201.        9.4 Copyright Notice
  3202.  
  3203.        Both   the  NLREG  program  and  documentation  are  copyright  (c)
  3204.        1992-1995 by Phillip  H.   Sherrod.   You  are  not  authorized  to
  3205.        modify the program.  "NLREG" is a trademark.
  3206.  
  3207.        9.5 Disclaimer
  3208.  
  3209.        This  software  and documentation are provided on an "as is" basis.
  3210.        This program may contain "bugs" and inaccuracies, and  its  results
  3211.        should  not  be  assumed  to be correct unless they are verified by
  3212.        independent means.  Phillip H.  Sherrod  disclaims  all  warranties
  3213.        relating  to this software, whether expressed or implied, including
  3214.        but not limited to any implied  warranties  of  merchantability  or
  3215.        fitness  for a particular purpose.  Neither Phillip H.  Sherrod nor
  3216.        anyone else who has been involved in the creation,  production,  or
  3217.        delivery  of  this  software  shall  be  liable  for  any indirect,
  3218.        consequential, or incidental damages arising  out  of  the  use  or
  3219.        inability  to  use  such  software, even if Phillip H.  Sherrod has
  3220.        been advised of the possibility of such  damages  or  claims.   The
  3221.        person  using  the  software  bears  all risk as to the quality and
  3222.        performance of the software.
  3223.  
  3224.        This agreement shall be governed  by  the  laws  of  the  State  of
  3225.        Tennessee  and  shall  inure  to the benefit of Phillip H.  Sherrod
  3226.        and any successors, administrators, heirs and assigns.  Any  action
  3227.        or  proceeding  brought  by  either party against the other arising
  3228.  
  3229.        Chapter 9. Acknowledgement and Use of NLREG                      58
  3230.  
  3231.  
  3232.        out of or related to this agreement shall  be  brought  only  in  a
  3233.        state  or  federal  court  of  competent  jurisdiction  located  in
  3234.        Davidson County, Tennessee.   The  parties  hereby  consent  to  in
  3235.        personam jurisdiction of said courts.
  3236.  
  3237.  
  3238.  
  3239.  
  3240.  
  3241.  
  3242.                                    Chapter 10
  3243.  
  3244.                                  Other Software
  3245.  
  3246.  
  3247.  
  3248.  
  3249.        10.1 Mathplot -- Mathematical Function Plotting Program
  3250.  
  3251.        If  you  like  NLREG,  you should check out the Mathplot program by
  3252.        the same author.
  3253.  
  3254.        Mathplot allows you to specify complicated  mathematical  functions
  3255.        using  ordinary  algebraic  expressions  and immediately plot them.
  3256.        Four types of  functions  may  be  specified:  cartesian  (y=f(x));
  3257.        parametric  cartesian (y=f(t) and x=f(t)); polar (radius=f(angle));
  3258.        and parametric polar (radius=f(t)  and  angle=f(t)).   Up  to  four
  3259.        functions  may  be  plotted  simultaneously.  Scaling is automatic.
  3260.        Options are available to control axis display and labeling as  well
  3261.        as  grid  lines.   Hard  copy  output  may  be generated as well as
  3262.        screen  display.   Mathplot  is  an  ideal  tool   for   engineers,
  3263.        scientists,  math  and  science teachers, and anyone else who needs
  3264.        to quickly visualize mathematical functions.
  3265.  
  3266.        10.2 TSX-32 -- Multi-User Operating System
  3267.  
  3268.        If you have  a  need  for  a  multi-user,  multi-tasking  operating
  3269.        system,  you  should  look into TSX-32.  TSX-32 is a full-featured,
  3270.        high performance, multi-user operating system for the 386  and  486
  3271.        that  provides  both  32-bit  and  16-bit  program  support.   With
  3272.        facilities such  as  multitasking  and  multisessions,  networking,
  3273.        virtual  memory,  X-Windows, background batch queues, data caching,
  3274.        file  access  control,  real-time,  and  dial-in  support,   TSX-32
  3275.        provides a solid environment for a wide range of applications.
  3276.  
  3277.        A  two  user,  shareware  version of TSX-32 called TSX-Lite is also
  3278.        available.
  3279.  
  3280.        TSX-32 is not a limited, 16-bit, multi-DOS add-on.  Rather,  it  is
  3281.        a  complete  32-bit  operating  system  which makes full use of the
  3282.        hardware's potential, including protected mode  execution,  virtual
  3283.        memory,  and  demand paging.  TSX-32 sites range from small systems
  3284.        with 2-3 terminals  to  large  installations  with  more  than  150
  3285.        terminals on a single 486.
  3286.  
  3287.        In  addition to supporting most popular 16-bit DOS programs, TSX-32
  3288.        also provides a 32-bit "flat" address space with both Phar Lap  and
  3289.        DPMI compatible modes of execution.
  3290.  
  3291.  
  3292.  
  3293.  
  3294.                                        59
  3295.  
  3296.        Chapter 10. Other Software                                       60
  3297.  
  3298.  
  3299.        Since  the  DOS  file  structure  is  standard  for TSX-32, you can
  3300.        directly read and write DOS disks.  And, you can run  DOS  part  of
  3301.        the time and TSX-32 the rest of the time on the same computer.
  3302.  
  3303.        TSX-32  allows  each  user  to control up to 10 sessions.  Programs
  3304.        can also "fork"  subtasks  for  multi-threaded  applications.   The
  3305.        patented  Adaptive  Scheduling Algorithm provides consistently good
  3306.        response time under varying conditions.
  3307.  
  3308.        The  TSX-32  network  option  provides  industry  standard   TCP/IP
  3309.        networking  through Ethernet and serial lines.  Programs can access
  3310.        files on remote machines as easily as on their  own  machine.   The
  3311.        SET  HOST  command allows a user on one machine to log onto another
  3312.        computer in the network.  FTP, Telnet, and NFS  are  available  for
  3313.        interoperability with other systems.
  3314.  
  3315.        System  requirements:  386  or 486 system, 4MB memory, 12MB of free
  3316.        disk space (Stacker and DoubleSpace are not supported).
  3317.  
  3318.        TSX-32 is, quite simply,  the  best  and  most  powerful  operating
  3319.        system  available  for the 386 and 486.  For additional information
  3320.        contact:
  3321.  
  3322.                            S&H Computer Systems, Inc.
  3323.                              1027 17th Avenue South
  3324.                              Nashville, TN 37212 USA
  3325.                               615-327-3670 (voice)
  3326.                                615-321-5929 (fax)
  3327.                               CompuServe: 71333,27
  3328.                         Internet: 71333.27@compuserve.com
  3329.  
  3330.  
  3331.        10.3 SIMSTAT -- Interactive Statistics Program
  3332.  
  3333.        If you need a general-purpose statistical package, or would like  a
  3334.        menu-oriented,  mouse-aware  interface  to NLREG, I suggest you try
  3335.        the SIMSTAT program written by Normand Peladeau.
  3336.  
  3337.        SIMSTAT is a menu driven statistical  program  that  provides  many
  3338.        basic   descriptive  and  comparative  statistics  and  includes  a
  3339.        "bridge" module to allow it to function as a "front end"  and  data
  3340.        editor for NLREG.
  3341.  
  3342.        The  shareware  version  of  SIMSTAT  is  available from the IBMAPP
  3343.        forum of CompuServe and from many  BBS,  or  you  can  contact  the
  3344.        author  at  the  address  below.   SIMSTAT  version 3.0 or later is
  3345.        required for use with NLREG.   You  must  also  have  the  "bridge"
  3346.        module  called  SIM2NL.  SIM2NL.ZIP is included on the distribution
  3347.        disk with the registered version of NLREG.
  3348.  
  3349.        For information about SIMSTAT, contact: Normand Peladeau,  Provalis
  3350.        Research,   5000   Adam  Street,  Montreal,  QC  H1V  1W5,  Canada,
  3351.        Compuserve: [71760,2103], Internet: 71760.2103@compuserve.com.
  3352.  
  3353.          ===============================================================
  3354.                                Software Order Form
  3355.          ===============================================================
  3356.  
  3357.        Name ______________________________________________________
  3358.  
  3359.        Address ___________________________________________________
  3360.  
  3361.        City _______________________  State _______ Zip ___________
  3362.  
  3363.        Country ____________________  Telephone ___________________
  3364.  
  3365.        Internet address (optional) _______________________________
  3366.  
  3367.        NLREG version _____________________________________________
  3368.  
  3369.        Bulletin board where you found NLREG ______________________
  3370.  
  3371.        Comments __________________________________________________
  3372.  
  3373.        Check the box below which indicates your order type:
  3374.  
  3375.            ___ I wish to register NLREG ($45).
  3376.  
  3377.            ___ I wish to order Mathplot ($25).
  3378.  
  3379.            ___ I wish to register NLREG and order Mathplot ($65).
  3380.  
  3381.        Add $5 to any amount shown above if the software is  being  shipped
  3382.        out  of  the  United  States.   I  cannot accept checks from non-US
  3383.        banks.  Visa, MasterCard and American Express credit  card  charges
  3384.        are  accepted  but  a check, money order, or cash is preferred.  If
  3385.        you wish to use a credit card specify the  billing  name,  address,
  3386.        card number, and expiration date.
  3387.  
  3388.        In  return for registering, you will receive the registered version
  3389.        of the program, a laser-printed, bound  copy  of  the  manual,  and
  3390.        three   months   of   telephone   or   CompuServe   support.   Your
  3391.        registration fee will be refunded if you find a  serious  bug  that
  3392.        cannot be corrected.
  3393.  
  3394.        Distribution disk choice (check one):
  3395.  
  3396.              3.50" HD (1.4 MB)  ______
  3397.              5.25" HD (1.2 MB)  ______
  3398.              5.25" DD (360 KB)  ______
  3399.  
  3400.        Send this form with the amount indicated to the author:
  3401.  
  3402.                                Phillip H. Sherrod
  3403.                                 4410 Gerald Place
  3404.                           Nashville, TN  37205-3806 USA
  3405.  
  3406.                              615-292-2881 (evenings)
  3407.                              CompuServe: 76166,2640
  3408.                        Internet: 76166.2640@compuserve.com
  3409.  
  3410.        Index                                                            62
  3411.  
  3412.  
  3413.        80x87 coprocessor, 47              CONTINUE statement, 33, 35
  3414.        ABS function, 11                   Convergence criterion, 43
  3415.        Absolute converge, 44              Convergence failures, 45
  3416.        Acknowledgement, 56                Cooling example, 49
  3417.        ACOS function, 11                  Copyright notice, 57
  3418.        Adaptive algorithm, 43             CORRELATE statement, 22, 41
  3419.        AFCTOL value, 43                   Correlation matrix, 41
  3420.        AIDS growth curve, 48              COS function, 11
  3421.        AND operator, 10                   Cosecant function, 11
  3422.        ANGLETYPE statement, 23            COSH function, 11
  3423.        Arc cosine function, 11            COT function, 11
  3424.        Arc sine function, 11              COVARIANCE statement, 22
  3425.        Arc tangent function, 11           CSC function, 11
  3426.        Arithmetic operators, 9            CTOP function, 11
  3427.        Arrays                             DATA statement, 35
  3428.           declaration, 19                 DEG function, 12
  3429.           initialization, 19              Degrees for functions, 23
  3430.           storage order, 19               Degrees to radians, 14
  3431.           subscripts, 20                  Dependent variable, 7
  3432.        ASIN function, 11                  Deviation
  3433.        ASP, 57                               average, 38
  3434.        Assignment operators, 10, 32          definition, 2
  3435.        Assn. of Shareware Prof., 57          maximum, 38
  3436.        Asymptotic function example,       Diode current example, 50
  3437.                 48                        Disclaimer, 57
  3438.        ATAN function, 11                  DO statement, 33
  3439.        Author address, 57                 DOMAIN option, 25, 28, 29
  3440.        Autoregression test, 30, 39        DOUBLE statement, 19
  3441.        Average deviation, 38              DPMI support, 59
  3442.        AVL tree example, 50               Durbin-Watson statistic, 39
  3443.        Bessel function, 13, 15            EI2 function, 12
  3444.        Beta function, 11                  EIC1 function, 12
  3445.        BETAI function, 11                 EIC2 function, 12
  3446.        Brachistochrone, 55                EL1 function, 12
  3447.        BREAK statement, 33, 34            Elliptic integral function,
  3448.        Build-in functions, 11                      12
  3449.        Built-in constant, 11              ERF function, 12
  3450.        Calculus of variations, 55         Examples, 48
  3451.        CEIL function, 11                     AIDS growth curve, 48
  3452.        Chebyshev function, 15                asymptotic function, 48
  3453.        Circular regression, 52               AVL tree, 50
  3454.        Clapeyron's equation, 49              boiling water, 49
  3455.        Comma operator, 10                    circular regression, 52
  3456.        Command files, 15                     cooling, 49
  3457.        Commands, 18                          diode current, 50
  3458.        Comments, 16                          fire station location, 53
  3459.        Comparison operators, 10              function minimization, 55
  3460.        Compass to polar, 11                  linear regression, 48
  3461.        CompuServe, 57, 60                    lunar lander, 55
  3462.        Conditional operator, 10              magnet force, 50
  3463.        Confidence intervals, 22              minimum time path, 55
  3464.        CONFIDENCE statement, 22, 38          multivariate, 48
  3465.        CONSTANT command, 20                  negative exponential, 49
  3466.        Constant variables, 7                 piecewise function, 50
  3467.        CONSTRAIN statement, 20, 46           quadratic equation, 48
  3468.  
  3469.        Index                                                            63
  3470.  
  3471.  
  3472.           square wave, 49                 Logistic curve, 48
  3473.           SWEEP statement, 49             Lunar lander example, 55
  3474.        EXP function, 12                   Magnet example, 50
  3475.        Exponentiation operator, 9         Marquardt algorithm, 43
  3476.        Expression minimization, 53        Mathplot, 59
  3477.        F value, 41                        MAX function, 13
  3478.        FAC function, 12                   Maximum values, 37
  3479.        Factorial function, 12             MIN function, 13
  3480.        False convergence, 45              Minimization algorithm, 43
  3481.        Fire station example, 53           Minimization problem, 53
  3482.        FLOOR function, 12                 Model/trust region, 43
  3483.        FOR statement, 34                  Modulo operator, 9
  3484.        Function minimization, 53          Multi-user operating system,
  3485.        FUNCTION statement, 21                      59
  3486.        Functions, 11                      Multiple determination, 39
  3487.        GAMMA function, 12                 Multivariate regression, 48
  3488.        GAMMAI function, 12                Mutually dependent, 46
  3489.        GAMMALN function, 12               Natural log function, 13
  3490.        Gauss-Newton algorithm, 43         Negative exponential, 2, 49
  3491.        Growth curve, 48                   Networking, 60
  3492.        HAV function, 12                   NLREG environment variable, 4
  3493.        Hessian, 43                        NLREG.DOC file, 4
  3494.        Hyperbolic cosine function,        NLREG.EXE file, 4
  3495.                 11                        NLREG.FON file, 4, 25
  3496.        Hyperbolic sine function, 15       NLREG.LJF file, 4
  3497.        Hyperbolic tangent function,       NOECHO statement, 32
  3498.                 15                        NORMAL function, 13
  3499.        IF statement, 32                   Normal probability plot, 30
  3500.        Include files, 16                  NOT operator, 10
  3501.        #INCLUDE statement, 16             NPD function, 13
  3502.        Incomplete beta function, 11       NPLOT statement, 8, 30
  3503.        Independent variables, 7              autocorrelation test, 40
  3504.        Input variables, 6                    options, 30
  3505.        Installing NLREG, 4                Numeric constants, 10
  3506.        INT function, 12                   Numeric coprocessor, 47
  3507.        Internet, 57, 60                   OBS system variable, 7, 24
  3508.        Inverse gamma function, 12         Operators
  3509.        ITERATIONS statement, 23              assignment, 10
  3510.        J0 function, 13                       comma, 10
  3511.        J1 function, 13                       comparison, 10
  3512.        JN function, 13                       conditional, 10
  3513.        Keywords, 6                           logical, 10
  3514.        LaserJet printer, 4, 56               precedence of, 10
  3515.           resolution, 31                     subscript, 10
  3516.        Least squares regression, 2        OR operator, 10
  3517.        Levenberg-Marquardt, 43            Order form, 61
  3518.        Limits, 47                         OUTPUT statement, 24
  3519.        Linear regression, 1, 3            PARAMETER statement
  3520.           example, 48                        function minimization, 53
  3521.        Listing file, 5                    PARAMETERS statement, 18
  3522.        LOG function, 13                   PAREA function, 13
  3523.        Log gamma function, 12             Performance issues, 47
  3524.        LOG10 function, 13                 Periodic data, 40
  3525.        LOG2 function, 13                  PI constant, 11
  3526.        Logical operators, 10              Piecewise function example,
  3527.  
  3528.        Index                                                            64
  3529.  
  3530.  
  3531.                 50                        Root finding, 53
  3532.        PLOT statement, 7, 24              ROUND function, 14
  3533.           options, 25                     RPLOT statement, 8, 28
  3534.        Plots                                 autocorrelation test, 40
  3535.           data and function, 25              options, 29
  3536.           normal probability, 30          RTOPA function, 14
  3537.           residual values, 28             RTOPD function, 15
  3538.           resolution, 31                  R^2 statistic, 39
  3539.           scatter, 26                     S&H Computer Systems, Inc.,
  3540.           width of, 31                             60
  3541.        Polar to compass, 14               Scatter plots, 26
  3542.        Polar to rectangular, 14           SEC function, 15
  3543.        Polynomial equation example,       Secant function, 15
  3544.                 48                        SEL function, 15
  3545.        POUTPUT statement, 24              SET command, 4
  3546.           extra precision output, 37      Sherrod, Phillip H., 57
  3547.        Precedence of operators, 10        SIM2NL, 60
  3548.        PREDICTED system variable, 6,      SIMSTAT, 60
  3549.                 8, 24                     SIN function, 15, 40
  3550.        PRESOLUTION statement, 31          Singular matrix problems, 46
  3551.        PRINTF function, 13                SINH function, 15
  3552.        Prob(F), 41                        SPLOT statement, 7, 26
  3553.        Prob(t) value, 38                     options, 26
  3554.        Program limits, 47                 SQRT function, 15
  3555.        PTOC function, 14                  Square wave example, 49
  3556.        PTORX function, 14                 Standard deviation, 37
  3557.        PTORY function, 14                 Standard error function, 12
  3558.        PULSE function, 14                 Statements, 18
  3559.        Quadratic equation example,        STEP function, 15
  3560.                 48                        STOP statement, 35
  3561.        RAD function, 14                   Subscript operator, 10
  3562.        Radian to degree conversion,       Subscripts, 20
  3563.                 12                        Support of NLREG, 56
  3564.        Radians for functions, 23          SWEEP statement, 21
  3565.        RANDOM function, 14                   convergence failure, 45
  3566.        Ra^2 statistic, 39                    example, 49
  3567.        Real-time, 59                         function minimization, 54
  3568.        Rectangular to polar, 14              performance issues, 47
  3569.        REGISTER.DOC file, 4               Symbolic constants, 7, 11, 20
  3570.        Registering NLREG, 56              System variables, 6
  3571.        Registration form, 61              T function, 15
  3572.        Relational operators, 10           t statistic, 37, 38
  3573.        Relative convergence, 44           TAN function, 15
  3574.        Remainder operator (modulo),       TANH function, 15
  3575.                 9                         TCP/IP, 60
  3576.        Reserved words, 6                  Theory of operation, 43
  3577.        Residual                           Time series data, 39
  3578.        RESIDUAL system variable, 6,       TITLE statement, 18
  3579.                 8, 24                     TOLERANCE statement, 23
  3580.        Residual values                       converge criterion, 43
  3581.           plotting, 28                    Transformed function, 3
  3582.           average, 38                     TREND example, 40
  3583.           definition, 2                   TREND.NLR, 49
  3584.           maximum, 38                     Trigonometric functions
  3585.        RFCTOL value, 43                      degrees or radians, 23
  3586.  
  3587.        Index                                                            65
  3588.  
  3589.  
  3590.        TSX-32, 59
  3591.        TSX-Lite, 59
  3592.        Use and distribution, 56
  3593.        VARIABLES statement, 18
  3594.        Variance-covariance matrix,
  3595.                 22
  3596.        Vectors
  3597.           see Arrays, 19
  3598.        Warranty, 57
  3599.        WHILE statement, 33
  3600.        WIDTH statement, 31
  3601.        X windows, 59
  3602.        Y0 function, 15
  3603.        Y1 function, 15
  3604.        YN function, 15
  3605.