home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 12 / CD_ASCQ_12_0294.iso / maj / 4352 / nonlin.doc < prev    next >
Text File  |  1994-01-28  |  178KB  |  3,573 lines

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