home *** CD-ROM | disk | FTP | other *** search
/ Best Objectech Shareware Selections / UNTITLED.iso / boss / educ / math / 001 / nonlin.doc < prev    next >
Encoding:
Text File  |  1992-06-13  |  70.1 KB  |  1,464 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.                                     N O N L I N
  10.  
  11.  
  12.  
  13.                        Nonlinear Regression Analysis Program
  14.  
  15.  
  16.  
  17.  
  18.                                 Phillip H. Sherrod
  19.  
  20.                                A "shareware" program
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.               Nonlin  allows  you  to  perform regression analyses to
  28.               estimate  the  values   of   parameters   for   linear,
  29.               multivariate,   polynomial,   and   general   nonlinear
  30.               functions.   The  regression  analysis  determines  the
  31.               values  of  the  parameters which cause the function to
  32.               best fit the observed data that you  provide.    Nonlin
  33.               allows you to specify the function whose parameters are
  34.               being estimated  using ordinary algebraic notation.  In
  35.               addition to determining the parameter estimates, Nonlin
  36.               can  be  directed  to  generate  an  output  file  with
  37.               predicted values  and  residuals.  It can also plot the
  38.               data observations and the computed function.
  39.  
  40.                NONLIN -- Nonlinear Regression Program       Page 1
  41.  
  42.  
  43.  
  44.  
  45.          INTRODUCTION TO REGRESSION ANALYSIS
  46.  
  47.          The  goal  of  regression  analysis  is  to  determine  the  best
  48.          estimates of parameters for a function
  49.  
  50.          depvar = f(p,indepvar)
  51.  
  52.          where `depvar' is the dependent variable, `indepvar'  is  one  or
  53.          more  independent  variables,  and  `p' is one or more parameters
  54.          whose values are to be estimated.    In  linear  regression,  the
  55.          function, f, is a linear (straight line) equation.
  56.  
  57.          For example, if we assume the value of an automobile decreases by
  58.          a constant amount each year after its purchase, and for each mile
  59.          driven,  the  following  linear  function would predict its value
  60.          (the dependent variable) as a function  of  the  two  independent
  61.          variables which are age and miles:
  62.  
  63.          value = price + depage*age + depmiles*miles
  64.  
  65.          where  `value',  the dependent variable, is the value of the car,
  66.          `age' is the age of the car, and `miles' is the number  of  miles
  67.          that the car has been driven.
  68.  
  69.          The  regression  analysis  will  determine the best values of the
  70.          three parameters, `price', the estimated value  when  age  is  0,
  71.          `depage',  the  depreciation  that  takes  place  each  year, and
  72.          `depmiles', the depreciation for each mile driven.  The values of
  73.          `depage' and `depmiles' will be negative because  the  car  loses
  74.          value as time and miles increase.
  75.  
  76.          In  a  problem  such  as  this car depreciation example, you must
  77.          provide a data file containing the values of  the  dependent  and
  78.          independent variables for a set of observations.  In this example
  79.          each  observation record would contain three numbers: value, age,
  80.          and miles, collected from used car ads for the  same  model  car.
  81.          The  more observations you provide, the more accurate will be the
  82.          estimate of the parameters.
  83.  
  84.          Once the values of the parameters are estimated, you can use  the
  85.          formula  to predict the value of a car based on its age and miles
  86.          driven.  If a perfect fit existed between the  function  and  the
  87.          actual data, the actual value of each car in your data file would
  88.  
  89.                NONLIN -- Nonlinear Regression Program       Page 2
  90.  
  91.  
  92.          exactly equal  the  predicted value.  Typically, however, this is
  93.          not  the case, and the difference between the actual value of the
  94.          dependent variable and  its  predicted  value  for  a  particular
  95.          observation  is  the  error of the estimate which is known as the
  96.          "deviation" or "residual".  The goal of regression analysis is to
  97.          determine the values of the parameters which minimize the sum  of
  98.          the squared residual values for the set of observations.  This is
  99.          known as a "least squares" regression fit.
  100.  
  101.  
  102.          INTRODUCTION TO NONLIN
  103.  
  104.          Nonlin is  a very powerful regression analysis program.  Using it
  105.          you can perform multivariate,  linear,  polynomial,  and  general
  106.          nonlinear regression.    What  this means is that you specify the
  107.          form of the function to be fitted to the data, and  the  function
  108.          can  include  nonlinear  terms such as variables raised to powers
  109.          and library  functions  such  as  log,  exponential,  sine,  etc.
  110.          Nonlin uses a state-of-the-art regression algorithm that works as
  111.          well,  or  better,  than any you are likely to find in commercial
  112.          statistical packages.
  113.  
  114.          As  an  example  of  nonlinear   regression,   consider   another
  115.          depreciation problem.  The value of a used airplane decreases for
  116.          each year of its age.  Assuming the value of a plane falls by the
  117.          same  amount  each  year, a linear function relating value to age
  118.          is:
  119.  
  120.               Value = p0 + p1*Age
  121.  
  122.          Where `p0' and `p1' are the parameters whose  values  are  to  be
  123.          determined.   However,  it  is a well known fact that planes (and
  124.          automobiles) lose more value the first year than the second,  and
  125.          more the  second  than  the third, etc.  This means that a linear
  126.          (straight line) function cannot accurately model this  situation.
  127.          A better, nonlinear, function is:
  128.  
  129.               Value = p0 + p1*exp(-p2*Age)
  130.  
  131.          Where  the `exp' function is the value of e (2.7182818...) raised
  132.          to a power.    This  type  of  function  is  known  as  "negative
  133.          exponential"  and  is appropriate for modeling a value whose rate
  134.          of decrease is proportional to the difference between  the  value
  135.          and some base value.  The F33YEAR.NLR example command file fits a
  136.          linear function  to  the value of used airplanes.  The F33EXP.NLR
  137.  
  138.                 NONLIN -- Nonlinear Regression Program       Page 3
  139.  
  140.  
  141.          example fits a negative exponential function to  the  same  data.
  142.          Run both  examples  and  compare  the  fitted  functions.     The
  143.          COOLING.NLR example also uses a negative exponential function.
  144.  
  145.          Much  of  the  convenience of Nonlin comes from the fact that you
  146.          can  enter  complicated  functions   using   ordinary   algebraic
  147.          notation.   Examples of functions that can be handled with Nonlin
  148.          include:
  149.  
  150.          Linear: Y = p0 + p1*X
  151.  
  152.          Quadratic: Y = p0 + p1*X + p2*X^2
  153.  
  154.          Multivariate: Y = p0 + p1*X + p2*Z + p3*X*Z
  155.  
  156.          Exponential: Y = p0 + p1*exp(X)
  157.  
  158.          Periodic: Y = p0 + p1*sin(p2*X)
  159.  
  160.          Misc: Y = p0 + p1*Y + p2*exp(Y) + p3*sin(Z)
  161.  
  162.          In other words, the function is a  general  expression  involving
  163.          one  dependent  variable  (on the left of the equal sign), one or
  164.          more independent variables, and  one  or  more  parameters  whose
  165.          values are to be estimated.
  166.  
  167.          Because  of  its  generality,  Nonlin  can  perform  all  of  the
  168.          regressions handled by ordinary linear or multivariate regression
  169.          programs as well as nonlinear regression.  However, in  order  to
  170.          handle  nonlinear  functions,  Nonlin  uses an iterative function
  171.          optimization algorithm which is slower  than  the  simple  linear
  172.          regression  algorithm and has the potential for not converging to
  173.          a solution.
  174.  
  175.  
  176.          INSTALLING NONLIN
  177.  
  178.          The NONLIN system consists of the following files:
  179.  
  180.          NONLIN.EXE -- The executable program.
  181.          NONLIN.DOC -- Documentation file.
  182.          NONLIN.FON -- Font file used if you request a plot.
  183.          NONLIN.LJF -- HP LaserJet font file used if you print a plot.
  184.               *.NLR -- Example command files.
  185.  
  186.                 NONLIN -- Nonlinear Regression Program       Page 4
  187.  
  188.  
  189.          To install Nonlin, copy the files  into  the  directory  of  your
  190.          choice.  If you do not plan to generated hard copy output  for  a
  191.          LaserJet printer,  you  may  delete  the NONLIN.LJF file.  If the
  192.          NONLIN.FON  and  NONLIN.LJF  files  are  not  in   your   current
  193.          directory, you must place a command of the following form in your
  194.          AUTOEXEC.BAT  file  to  tell  Nonlin  where  to look for its font
  195.          files:
  196.  
  197.          SET NONLIN=directory
  198.  
  199.          Where "directory" is the name of the device and  directory  where
  200.          the files  are located.  For example, if the files are located in
  201.          a directory named NONLIN on the C  disk,  the  following  command
  202.          could be used:
  203.  
  204.          SET NONLIN=C:\NONLIN
  205.  
  206.  
  207.          USING NONLIN
  208.  
  209.          Once  Nonlin  has  been  installed, it can be started using a DOS
  210.          command of the form:
  211.  
  212.          NONLIN command_file
  213.  
  214.          where "command_file" is the name  of  a  file  containing  Nonlin
  215.          commands that  control  the  analysis.   The sections that follow
  216.          describe these commands.  If you  omit  the  command  file  name,
  217.          Nonlin prints a list of its commands.
  218.  
  219.          If  you wish to direct the output produced by Nonlin to a file or
  220.          printer, use the DOS  `>'  redirection  operator  on  the  NONLIN
  221.          command line.    This  is  useful  because  the  Nonlin output is
  222.          frequently longer than a single screen display and may scroll off
  223.          the screen  before  you  have  a  chance  to  examine  it.     By
  224.          redirecting  output  to  a file, you can use an editor or the DOS
  225.          MORE command to examine the output page by page.  Note  that  you
  226.          can  use  redirection  even  if you request a plot; the plot will
  227.          appear on your screen but the printed output will be  redirected.
  228.          For   example,  to  process  a  command  file  named  LINEAR.NLR,
  229.          directing output to a file named LINEAR.LST,  use  the  following
  230.          command:
  231.  
  232.          NONLIN LINEAR > LINEAR.LST
  233.  
  234.                NONLIN -- Nonlinear Regression Program       Page 5
  235.  
  236.  
  237.          At  this  point,  I  suggest  you  pause  in your reading and try
  238.          running a Nonlin example to get a feel for how it works.  Several
  239.          example  files  with  the  extension ".NLR" are provided with the
  240.          distribution.  LINEAR.NLR is a good one to start with.  If you do
  241.          not have a graphics monitor, edit  the  LINEAR.NLR  command  file
  242.          (and other example files) and remove the PLOT command.
  243.  
  244.  
  245.          FUNCTION SPECIFICATION
  246.  
  247.          Much  of  the  power of Nonlin comes from its ability to estimate
  248.          the value of parameters that are part  of  complicated  functions
  249.          that you enter in ordinary algebraic form.  This section explains
  250.          the  arithmetic operators and built in functions that are used to
  251.          specify a function.
  252.  
  253.          Arithmetic Operators
  254.  
  255.          The following arithmetic operators may be used in expressions:
  256.  
  257.              +        addition
  258.              -        subtraction or unary minus
  259.              *        multiplication
  260.              /        division
  261.              ** or ^  exponentiation
  262.  
  263.          Exponentiation  has   the   highest   precedence,   followed   by
  264.          multiplication  and  division, and then addition and subtraction.
  265.          Parentheses may be used to group terms.
  266.  
  267.          As a convenience, Nonlin allows you to  omit  the  multiplication
  268.          operator  between  a  numeric  constant and a following variable,
  269.          parameter, or function.  For example, the expressions "2pi",  and
  270.          "2 pi" are  equivalent  to "2*pi".  Similarly, "5X" is equivalent
  271.          to "5*X".  However, if you specify a  number  before  the  letter
  272.          "E",  it  will  be taken as the exponential form of a number (see
  273.          below) rather than the number  times  the  constant  E  (base  of
  274.          natural logarithms).
  275.  
  276.          Numeric Constants
  277.  
  278.          Numeric  constants  may  be  written in their natural form (1, 0,
  279.          1.5, .0003, etc.) or in exponential form, n.nnnEppp, where  n.nnn
  280.          is  the  base value and ppp is the power of ten by which the base
  281.          is multiplied.  For example, the number 1.5E4  is  equivalent  to
  282.  
  283.                NONLIN -- Nonlinear Regression Program       Page 6
  284.  
  285.  
  286.          15000.   All  numbers  are  treated  as  "floating point" values,
  287.          regardless of  whether a decimal point is specified or not.  As a
  288.          convenience for entering time values, if a value contains one  or
  289.          more  colons,  the portion to the left of the colon is multiplied
  290.          by 60.  For  example,  1:00  is  equivalent  to  60;  1:00:00  is
  291.          equivalent to 3600.
  292.  
  293.          Symbolic Constants
  294.  
  295.          There  are  two  numeric  constants  that  may be specified using
  296.          symbolic names.  The symbolic name  "PI"  is  equivalent  to  the
  297.          value of  pi, 3.14159...  Similarly, the symbolic constant "E" is
  298.          equivalent to the base of natural logarithms, 2.7182818...
  299.  
  300.  
  301.          Built in Functions
  302.  
  303.          The following functions are built into Nonlin and may be used  in
  304.          expressions:
  305.  
  306.          ABS(x) -- Absolute value of x.
  307.  
  308.          ACOS(x) -- Arc cosine of x.  Angles are measured in radians.
  309.  
  310.          ASIN(x) -- Arc sine of x.  Angles are measured in radians.
  311.  
  312.          ATAN(x) -- Arc tangent of x.  Angles are measured in radians.
  313.  
  314.          BETAI(x,a,b) --   Incomplete   beta   function:   Ix(a,b).    The
  315.                    incomplete beta function  can  be  used  to  compute  a
  316.                    variety of  statistical  functions.    For example, the
  317.                    probability of Student's t with `df' degrees of freedom
  318.                    can be computed with BETAI(df/(df+t^2),.5*df,.5).   The
  319.                    probability of the F statistic with df1 and df2 degrees
  320.                    of      freedom      can      be      computed     with
  321.                    2*BETAI(df2/(df2+df1*f),.5*df2,.5*df1).
  322.  
  323.          COS(x) -- Cosine of x.  Angles are measured in radians.
  324.  
  325.          COSH(x) -- Hyperbolic cosine of x.
  326.  
  327.          COT(x) -- Cotangent of x. (COT(x) = 1/TAN(x)).
  328.  
  329.                NONLIN -- Nonlinear Regression Program       Page 7
  330.  
  331.  
  332.          CSC(X) -- Cosecant of x. (CSC(x) = 1/SIN(x)).
  333.  
  334.          DEG(x)  --  Converts  an  angle,  x,  measured  in radians to the
  335.                    equivalent number of degrees.
  336.  
  337.          EI1(alpha,phi) -- Elliptic integral of the first kind.   Computes
  338.                    the  integral  from  0  to  phi radians of the function
  339.                    d.phi/sqrt(1-k**2*sin(phi)**2),  where  k = sin(alpha).
  340.                    alpha and phi must be in the range 0 to pi/2.
  341.  
  342.          EI2(alpha,phi) -- Elliptic integral of the second kind.  Computes
  343.                    the  integral  from  0  to  phi radians of the function
  344.                    sqrt(1-k**2*sin(phi)**2)*d.phi,  where  k = sin(alpha).
  345.                    alpha and phi must be in the range 0 to pi/2.
  346.  
  347.          EIC1(alpha)  --  Complete  elliptic  integral  of the first kind.
  348.                    Computes the integral from 0 to  pi/2  radians  of  the
  349.                    function      d.phi/sqrt(1-k**2*sin(phi)**2),     where
  350.                    k = sin(alpha). alpha must be in the range 0  to  (less
  351.                    than) pi/2.
  352.  
  353.          EIC2(alpha)  --  Complete  elliptic  integral of the second kind.
  354.                    Computes the integral from 0 to  pi/2  radians  of  the
  355.                    function      sqrt(1-k**2*sin(phi)**2)*d.phi,     where
  356.                    k = sin(alpha). alpha must be in the range 0 to pi/2.
  357.  
  358.          ERF(x) -- Standard error function of x.
  359.  
  360.          EXP(x) -- e (base of natural logarithms) raised to the x power.
  361.  
  362.          FAC(x) -- x factorial (x!).  Note, the FAC function  is  computed
  363.                    using   the   GAMMA   function  (FAC(x)=GAMMA(x+1))  so
  364.                    non-integer argument values may be computed.
  365.  
  366.          GAMMA(x) -- Gamma function.  Note, GAMMA(x+1) = x! (x factorial).
  367.  
  368.          GAMMAI(x)  --  Reciprocal  of   GAMMA   function   (GAMMAI(x)   =
  369.                    1/GAMMA(x)).
  370.  
  371.          GAMMALN(x) -- Log (base e) of the GAMMA function.
  372.  
  373.          HAV(x) -- Haversine of x. (HAV(x) = (1-COS(x))/2).
  374.  
  375.                 NONLIN -- Nonlinear Regression Program       Page 8
  376.  
  377.  
  378.          J0(x) -- Bessel function of the first kind, order zero.
  379.  
  380.          J1(x) -- Bessel function of the first kind, order one.
  381.  
  382.          JN(n,x) -- Bessel function of the first kind, order n.
  383.  
  384.          LOG(x) -- Natural logarithm of x.
  385.  
  386.          LOG10(x) -- Base 10 logarithm of x.
  387.  
  388.          MAX(x1,x2) -- Maximum value of x1 or x2.
  389.  
  390.          MIN(x1,x2) -- Minimum value of x1 or x2.
  391.  
  392.          NORMAL(x) -- Normal probability distribution of x.  X is in units
  393.                    of standard deviations from the mean.
  394.  
  395.          PAREA(x) -- Area under the normal probability distribution  curve
  396.                    from  -infinity to x. (i.e., integral from -infinity to
  397.                    x of NORMAL(x)).
  398.  
  399.          PULSE(a,x,b) -- Pulse function.  If the value of x is less than a
  400.                    or greater than b, the value of the function is 0.   If
  401.                    x  is greater than or equal to a and less than or equal
  402.                    to b, the value of the function is 1.  In other  words,
  403.                    it is  1  for  the domain (a,b) and zero elsewhere.  If
  404.                    you need a function that is zero in  the  domain  (a,b)
  405.                    and 1 elsewhere, use the expression (1-PULSE(a,x,b)).
  406.  
  407.          RAD(x) -- Converts an angle measured in degrees to the equivalent
  408.                    number of radians.
  409.  
  410.          SEC(x) -- Secant of x. (SEC(x) = 1/COS(x)).
  411.  
  412.          SEL(a1,a2,v1,v2)  --  If a1 is less than a2 then the value of the
  413.                    function is v1.  If a1 is greater than or equal to  a2,
  414.                    then the value of the function is v2.
  415.  
  416.          SIN(x) -- Sine of x.  Angles are measured in radians.
  417.  
  418.          SINH(x) -- Hyperbolic sine of x.
  419.  
  420.          SQRT(x) -- Square root of x.
  421.  
  422.                NONLIN -- Nonlinear Regression Program       Page 9
  423.  
  424.  
  425.          STEP(a,x) --  Step  function.   If x is less than a, the value of
  426.                    the function is 0.  If x is greater than or equal to a,
  427.                    the value of the function is 1.  If you need a function
  428.                    which is 1 up to a certain value and then 0 beyond that
  429.                    value, use the expression STEP(x,a).
  430.  
  431.          T(n,x) -- Chebyshev polynomial of order n.
  432.  
  433.          TAN(x) -- Tangent of x.  Angles are measured in radians.
  434.  
  435.          TANH(x) -- Hyperbolic tangent of x.
  436.  
  437.          Y0(x) -- Bessel function of the second kind, order zero.
  438.  
  439.          Y1(x) -- Bessel function of the second kind, order one.
  440.  
  441.          YN(n,x) -- Bessel function of the second kind, order n.
  442.  
  443.                 NONLIN -- Nonlinear Regression Program      Page 10
  444.  
  445.  
  446.          NONLIN COMMAND FILES
  447.  
  448.          The commands described in this section are placed  in  a  command
  449.          file.  When you start Nonlin, you specify the name of the command
  450.          file as  a  parameter  on  the command line.  For example, if the
  451.          command file name is CAR.NLR, the following command  would  cause
  452.          Nonlin to execute the commands in the command file:
  453.  
  454.          NONLIN CAR.NLR
  455.  
  456.          If you do not specify a file name extension for the command file,
  457.          ".NLR" is  used by default.  Command files can be created using a
  458.          text editor such as  EDIT-32,  EDLIN,  the  DOS  version  5  EDIT
  459.          program, or any other editor or word processor that is capable of
  460.          creating an ascii text file without formatting codes.
  461.  
  462.          Comments  may be placed in command files by preceding the comment
  463.          with an exclamation point.  Entire lines may be used for comments
  464.          and comments can be placed at the end of commands.
  465.  
  466.          Command lines can be continued by placing a  semicolon  character
  467.          as the last non-blank character on the line (a comment may follow
  468.          the  semicolon)  and then continuing the command on the following
  469.          line(s).
  470.  
  471.          Every  command  file  must  contain   the   following   commands:
  472.          VARIABLES,  PARAMETERS,  FUNCTION,  and  DATA. The DATA statement
  473.          introduces the data for the analysis and must be the last command
  474.          in the file (data records  may  follow  it).    Other,  optional,
  475.          commands may be interspersed in the command file.
  476.  
  477.          The following is an example of a complete command file:
  478.  
  479.              VARIABLES  VALUE,AGE,MILES
  480.              PARAMETERS BASE,DEPAGE,DEPMILES
  481.              FUNCTION VALUE = BASE + DEPAGE*AGE + DEPMILES*MILES
  482.              DATA
  483.              (data records follow)
  484.  
  485.                 NONLIN -- Nonlinear Regression Program      Page 11
  486.  
  487.  
  488.          NONLIN COMMANDS
  489.  
  490.          The following is a list of the valid Nonlin commands that can  be
  491.          placed in  a  Nonlin  command  file.    Command  keywords  may be
  492.          abbreviated to the first three letters except for  CONSTRAIN  and
  493.          CONFIDENCE which  require  four letters.  Nonlin commands are not
  494.          case sensitive.
  495.  
  496.          TITLE string (optional) -- Specifies a title line that is printed
  497.                  with the results of the analysis.
  498.  
  499.          VARIABLES var1,var2,... (required) -- Specifies the names of  the
  500.                  variables that  will  be  used  in  the  function.    The
  501.                  dependent variable and the independent variables must  be
  502.                  specified.   The  order  of the variable names must match
  503.                  the order of the data values for each observation.    You
  504.                  may  define  more  variables than you actually use in the
  505.                  function specification.  A maximum of 12 variables may be
  506.                  specified.  The length of a variable name is  limited  to
  507.                  10 characters.  Capitalize the variable names as you want
  508.                  them displayed in the results.
  509.  
  510.                  If  you  wish  to assign a weight to the observations (so
  511.                  some observations are considered  more  significant  than
  512.                  others),  use $WEIGHT as the name of the weight variable.
  513.                  If a weight variable is specified, the objective function
  514.                  to be minimized is SUM(i=1, N;  ($WEIGHT*(y[i]-f[i]))**2)
  515.                  where  y[i] is the actual value of the dependent variable
  516.                  at point 'i' and  f[i]  is  the  computed  value  of  the
  517.                  dependent variable at point 'i'.  If one wants to perform
  518.                  "optimal  weighting"  in  the  usual  sense for nonlinear
  519.                  regression, $WEIGHT for each observation should be chosen
  520.                  inversely proportional to the standard deviation  of  the
  521.                  measurement error for that observation.
  522.  
  523.                  You  may specify all of the variables on a single command
  524.                  line (which may be continued), or you may  have  multiple
  525.                  VARIABLES commands.    If  you use multiple commands, the
  526.                  order in which they appear in the command file must match
  527.                  the order of the variable values  for  each  observation.
  528.                  The VARIABLES command must precede the FUNCTION command.
  529.  
  530.                NONLIN -- Nonlinear Regression Program      Page 12
  531.  
  532.  
  533.          PARAMETERS param1[=initial1],param2[=initial2],...  (required) --
  534.                  Specifies the names of the parameters whose values are to
  535.                  be determined  by  Nonlin.  Nonlin is capable of handling
  536.                  up to 12 parameters.  The parameter names may not  exceed
  537.                  10 characters  in  length.  Do not specify any parameters
  538.                  that are not  used  in  the  function.    The  PARAMETERS
  539.                  command must precede the FUNCTION command.
  540.  
  541.                  Optionally,  an  initial  estimate of the parameter value
  542.                  may be specified by following the parameter name with  an
  543.                  equal sign and the value.  If no value is specified, 1 is
  544.                  used by  default.    Specifying  an initial value that is
  545.                  near the actual value usually speeds up the operation  of
  546.                  Nonlin  and  may  enable it to successfully converge to a
  547.                  solution.  If Nonlin is unable to converge to a solution,
  548.                  try  specifying  different  starting   values   for   the
  549.                  parameters.  Try to specify a value that at least has the
  550.                  correct sign as the expected final value.
  551.  
  552.                  The  CONSTRAIN  command  (described below) can be used to
  553.                  limit the range of values  for  parameters.    The  SWEEP
  554.                  command  can  be  used to perform the regression analysis
  555.                  with a range of parameter initial values.
  556.  
  557.          CONFIDENCE [percent] (optional) -- Specifies  that  a  confidence
  558.                  interval  is  to be printed for each estimated parameter.
  559.                  The purpose of regression analysis is  to  determine  the
  560.                  best estimate of parameter values.  However, as with most
  561.                  statistical   calculations,  the  values  determined  are
  562.                  estimates of the true values.    The  CONFIDENCE  command
  563.                  causes  Nonlin  to  print  a  table  showing the range of
  564.                  possible values for  each  parameter  given  a  specified
  565.                  confidence value.    The "percent" parameter spcifies the
  566.                  probability that that the actual value of  the  parameter
  567.                  is within  the  confidence  interval to be computed.  For
  568.                  example, the command
  569.  
  570.                  CONFIDENCE 95
  571.  
  572.                  specifies that  the  confidence  interval(s)  are  to  be
  573.                  computed such that there is a 95 percent probability that
  574.                  the  actual  values  of  the  parameters  are  within the
  575.                  intervals (or that there is a 5 percent chance  that  the
  576.                  parameters are  outside  the  intervals).   The "percent"
  577.                  parameter may range from 50 to 99.999.  If the CONFIDENCE
  578.  
  579.                 NONLIN -- Nonlinear Regression Program      Page 13
  580.  
  581.  
  582.                  command is used without specifiying a percent  value,  90
  583.                  is used by default.
  584.  
  585.          CONSTRAIN parameter=lowvalue[,highvalue] (optional) --  Specifies
  586.                  a  lower  and  upper  limit  on  the range of a parameter
  587.                  value.  During the solution process, Nonlin may  allow  a
  588.                  parameter's value to temporarily move in a direction away
  589.                  from its  final  value.    With  some functions it may be
  590.                  necessary to constrain the parameter's value so  that  it
  591.                  does  not  go  negative  (e.g., if the function takes the
  592.                  square root of the parameter), or zero (if the  parameter
  593.                  is in  a  denominator).    If  only  a  single  value  is
  594.                  specified (CONSTRAIN parameter=value), the value  of  the
  595.                  parameter is   fixed  at  the  specified  value.    If  a
  596.                  parameter  is  tightly  constrained,  Nonlin  may  report
  597.                  "singular  convergence"  because it is unable to converge
  598.                  to an  optimum  value  of  the  parameter;  however,  the
  599.                  estimated values of other parameters may be useful.
  600.  
  601.                  Only  a single parameter and its associated limits may be
  602.                  specified on each CONSTRAIN  command,  but  you  may  use
  603.                  multiple CONSTRAIN commands.  The PARAMETERS command must
  604.                  precede the CONSTRAIN command.
  605.  
  606.                  The  parameter  value is allowed to range from `lowvalue'
  607.                  to `highvalue'.  If you want to prevent a parameter value
  608.                  from going to zero, you must specify a value greater than
  609.                  zero for the low value (specifying zero would allow it to
  610.                  reach, but  not  go  below,  zero).    For  example,  the
  611.                  following  command  constrains  the  value of `age' to be
  612.                  greater than zero and less than or equal to 100:
  613.  
  614.                  CONSTRAIN age = .0001,100
  615.  
  616.                  See the COOLING.NLR, F33EXP.NLR, and POWER.NLR files  for
  617.                  examples of the CONSTRAIN command.
  618.  
  619.          COVARIANCE  (optional)  --  Causes the variance-covariance matrix
  620.                  for the parameters to be printed.
  621.  
  622.          SWEEP parameter=lowvalue,highvalue,stepsize  (optional)        --
  623.                  Specifies that the regression analysis is to be performed
  624.                  repeatedly   with  a  set  of  starting  values  for  the
  625.                  parameter.  The first  analysis  is  performed  with  the
  626.                  parameter  having the `lowvalue'; the value of `stepsize'
  627.  
  628.                 NONLIN -- Nonlinear Regression Program      Page 14
  629.  
  630.  
  631.                  is then added to the parameter's initial  value  and  the
  632.                  analysis is performed again.   The  process  is  repeated
  633.                  until the value of the parameter reaches `highvalue'.
  634.  
  635.                  Each  time  the  analysis  is  performed the value of the
  636.                  residual  sum  of  squares  is  compared  with  the  best
  637.                  previous result.   The estimated values of the parameters
  638.                  for the best starting value are saved and  used  for  the
  639.                  final analysis and report.
  640.  
  641.                  Only  one  parameter  may  be  specified  on  each  SWEEP
  642.                  command, but you may have as many SWEEP commands as there
  643.                  are parameters.    The  number  of  regression   analyses
  644.                  performed  will  be equal to the product of the number of
  645.                  parameter values for each SWEEP command.
  646.  
  647.                  The SWEEP command is useful when you are trying to fit  a
  648.                  complicated function that may have "local minimum" values
  649.                  other than  the  "global  minimum".    Periodic functions
  650.                  (sin, cos, etc.) are especially troublesome.
  651.  
  652.                  See the SINE.NLR command file for an example of the SWEEP
  653.                  command.
  654.  
  655.          FUNCTION depvar = function  (required) -- Specifies the  form  of
  656.                  the function  whose parameters are to be determined.  The
  657.                  dependent variable must be the only thing to the left  of
  658.                  the equal sign.  The expression to the right of the equal
  659.                  sign   may   contain  variables,  parameters,  constants,
  660.                  operators, and library functions such as sqrt, sin,  exp,
  661.                  etc.   The  VARIABLES  and  PARAMETERS commands must have
  662.                  appeared in the command file before the FUNCTION command,
  663.                  and all variables and parameters  used  in  the  function
  664.                  must have been specified on those commands.  Some example
  665.                  FUNCTION commands are show below:
  666.  
  667.                  FUNCTION Y = P0 + P1*X
  668.  
  669.                  FUNCTION DISTANCE = .5 * ACCEL * TIME^2
  670.  
  671.                  FUNCTION VALUE = PRICE + YRDEP*AGE + MILEDEP*MILES
  672.  
  673.                  FUNCTION POPULATN = BASE * GROWRATE * EXP(TIME)
  674.  
  675.                NONLIN -- Nonlinear Regression Program      Page 15
  676.  
  677.  
  678.          TOLERANCE value   (optional,   default=1E-10)  --  Specifies  the
  679.                  tolerance  factor  that  is  used  to  determine when the
  680.                  algorithm has converged to  a  solution.    Reducing  the
  681.                  tolerance  value  may  produce  a  slightly more accurate
  682.                  result but will increase the number of iterations and the
  683.                  running time.
  684.  
  685.          ITERATIONS value (optional, default=50) -- Specifies the  maximum
  686.                  number  of  iterations  that  should  be attempted by the
  687.                  algorithm.  If the solution  does  not  converge  to  the
  688.                  limit  specified  by  the  TOLERANCE  command  (or to the
  689.                  default  tolerance)  before   the   maximum   number   of
  690.                  iterations  is  reached,  the  process is stopped and the
  691.                  results are printed.   Failure  to  converge  before  the
  692.                  specified  number of iterations could be caused by one of
  693.                  three things:
  694.  
  695.                  1. The maximum allowed number of iterations  may  be  too
  696.                  small.   Try  using  an  ITERATIONS command with a larger
  697.                  value.
  698.  
  699.                  2. The tolerance  factor  may  be  too  small.    Even  a
  700.                  properly  converging solution will eventually "level off"
  701.                  or oscillate around a good, but non-zero, sum of  squares
  702.                  value.   Try  using the TOLERANCE command to increase the
  703.                  tolerance value.
  704.  
  705.                  3. The function may not be converging.    Try  specifying
  706.                  better  (or  at  least different) starting values for the
  707.                  parameters on the PARAMETERS command.  Consider using the
  708.                  SWEEP command to specify a range  of  parameter  starting
  709.                  values.
  710.  
  711.          REGISTER  (optional)  --  The  REGISTER  command  suppresses  the
  712.                  copyright  and  registration  message  that  is  normally
  713.                  printed as  part  of  a  Nonlin  report.  The use of this
  714.                  command is a reminder that you should register  your  use
  715.                  of Nonlin.
  716.  
  717.          OUTPUT [TO file] var1,var2,... (optional) -- Specifies that after
  718.                  the  analysis is completed, data values are to be printed
  719.                  or written to a file.  If the "TO file"  portion  of  the
  720.                  command  is  specified,  the  output  is  written  to the
  721.                  specified file.   If  this  portion  of  the  command  is
  722.                  omitted,  the  output  values  are printed along with the
  723.  
  724.                 NONLIN -- Nonlinear Regression Program      Page 16
  725.  
  726.  
  727.                  results.   If  a  file  name  is  specified  without   an
  728.                  extension, ".OUT" is used by default.
  729.  
  730.                  The list of variable names determines which variables are
  731.                  written to the file and the order  in  which  the  values
  732.                  appear in  each  output  record.  Any variable previously
  733.                  declared on a VARIABLES command may  be  specified.    In
  734.                  addition,  the folowing special variable names may appear
  735.                  in the output list:
  736.  
  737.                  $OBS -- The observation record number, starting at 1  and
  738.                  increasing by 1.
  739.  
  740.                  $PREDICTED  --  The  predicted  value  for  the dependent
  741.                  variable  for  the  observation,  given  the  independent
  742.                  variable  values  and the parameters as calculated by the
  743.                  analysis.
  744.  
  745.                  $RESIDUAL -- The difference between the actual  value  of
  746.                  the dependent variable and its predicted value.
  747.  
  748.                  Examples of OUTPUT commands are shown below:
  749.  
  750.                  OUTPUT AGE,MILES,VALUE,$PREDICTED,$RESIDUAL
  751.  
  752.                  OUTPUT TO GROWTH.DAT $OBS,TIME,POPULATN,$PREDICTED
  753.  
  754.          POUTPUT   file  --  Write  the  final  estimated  values  of  the
  755.                  parameters to a file.  Each parameter value is written to
  756.                  a separate line of the file.  This command is  useful  to
  757.                  create  a  file  of  estimated parameter values to be fed
  758.                  into another analysis program.
  759.  
  760.          PLOT [options] -- Display a plot of the calculated  function  and
  761.                  the data observations.  The PLOT command may be used only
  762.                  if  there  is  a  single  independent  variable (multiple
  763.                  independent  variables  would  require  an  n-dimensional
  764.                  surface  plot);  however,  there is no restriction on the
  765.                  number of parameters being estimated.  You  must  have  a
  766.                  CGA, EGA, or VGA monitor to use the PLOT command, and the
  767.                  NONLIN.FON  font file must be in the current directory or
  768.                  in  a  directory  specified  by  the  NONLIN  environment
  769.                  variable.   In the plot, the data values you provided are
  770.                  shown as blue X's and the function fitted to the data  by
  771.                  Nonlin is  shown  as a solid green line.  Press Return to
  772.  
  773.                NONLIN -- Nonlinear Regression Program      Page 17
  774.  
  775.  
  776.                  proceed with the analysis after you have finished looking
  777.                  at the plot.
  778.  
  779.                  The  following  options  may  be  specified  on  the PLOT
  780.                  command:
  781.  
  782.                  GRID -- display grid lines to make it easier to  estimate
  783.                  values.
  784.  
  785.                  RESIDUAL  --  draw vertical lines from each observed data
  786.                  point  to  the  corresponding  point  on  the  calculated
  787.                  function line.    These  lines  represent  the "residual"
  788.                  value that Nonlin is attempting to minimize.
  789.  
  790.                  ITERATION -- draw  a  plot  for  each  iteration  of  the
  791.                  regression analysis.    Normally, the plot is drawn after
  792.                  the analysis has converged to a solution; you may use the
  793.                  ITERATION option to  observe  the  function  during  each
  794.                  iteration  of  the  analysis  as  it converges to fit the
  795.                  data.
  796.  
  797.                  VALUES -- use in conjunction with the ITERATION option to
  798.                  cause the current parameter values to be displayed before
  799.                  the plot for the current iteration.
  800.  
  801.                  PRINT -- print a copy of  the  plot  on  an  HP  LaserJet
  802.                  printer.   Nonlin writes the plot to the PRN device which
  803.                  much be attached  to  an  HP  Series  II  or  Series  III
  804.                  printer.  The NONLIN.LJF font file must be in the current
  805.                  directory  or  in  a  directory  specified  by the NONLIN
  806.                  environment variable.
  807.  
  808.                  The option keywords may be  abbrievated  to  their  first
  809.                  letter.   If  more than one option is specified, separate
  810.                  them with commas.  For example, to produce  a  plot  with
  811.                  both  grid  lines  and  residual lines, use the following
  812.                  command:
  813.  
  814.                      PLOT GRID,RESIDUAL
  815.  
  816.          DOMAIN lowvalue,highvalue (optional) -- Specifies the domain over
  817.                  which the plot  is  to  be  generated.    If  the  DOMAIN
  818.                  statement  is  omitted,  the  domain  of  the independent
  819.                  variable is used for the plot.  The DOMAIN  statement  is
  820.                  useful  to  allow  you  to  generate a plot of the fitted
  821.  
  822.                NONLIN -- Nonlinear Regression Program      Page 18
  823.  
  824.  
  825.                  function extrapolated over the specified domain.  You can
  826.                  also  use  the  DOMAIN command to restrict the domain and
  827.                  "zero in" on a particular range of  the  function.    The
  828.                  DOMAIN  command only affects the plot; it does not affect
  829.                  the regresson calculation.
  830.  
  831.          DATA  [file]  (required)  --  Specifies  the  name  of  the  file
  832.                  containing  the  data  records,  or  introduces  the data
  833.                  records which follow the command.   If  a  file  name  is
  834.                  specified  on  the  DATA command, the file is opened, its
  835.                  data records are read, and  the  regression  analysis  is
  836.                  performed.   If  a  file  name  is  specified  without an
  837.                  extension, ".DAT" is used by default.
  838.  
  839.                  If no file name is specified on  the  DATA  command,  the
  840.                  data  records must immediately follow the DATA command in
  841.                  the command file.
  842.  
  843.                  Each data record must  contain  at  least  as  many  data
  844.                  values  as  the  number  of  variables  specified  on the
  845.                  VARIABLES command(s).  The  order  of  the  variables  as
  846.                  specified  on  the VARIABLES command must match the order
  847.                  of the values in  each  observation.    Any  data  values
  848.                  beyond  those  required  for  the specified variables are
  849.                  ignored.  Each observation must begin on a new line.
  850.  
  851.                  The data values must be separated by one or  more  spaces
  852.                  and/or a  comma.   Data values may contain decimal points
  853.                  and   may   be   expressed   in   exponential    notation
  854.                  (i.e., n.nnnnEppp).   As  a convenience for entering time
  855.                  values, if a value  contains  one  or  more  colons,  the
  856.                  portion  to  the  left  of the colon is multiplied by 60.
  857.                  For  example,  1:00  is  equivalent  to  60;  1:00:00  is
  858.                  equivalent to 3600.
  859.  
  860.                  You  may continue data lines by specifying a semicolon as
  861.                  the last non-blank character on a record and then placing
  862.                  the continuation value on the following line(s).
  863.  
  864.                  The DATA command must be the last command in the  command
  865.                  file.   If no file name is specified on the DATA command,
  866.                  the data records must immediately follow the DATA command
  867.                  in the command file.
  868.  
  869.                 NONLIN -- Nonlinear Regression Program      Page 19
  870.  
  871.  
  872.                  The following is an example of a  complete  command  file
  873.                  including data records:
  874.  
  875.                  VARIABLES AGE,MILES,VALUE
  876.                  PARAMETERS BASE,DEPAGE,DEPMILES
  877.                  FUNCTION VALUE = BASE + DEPAGE*AGE + DEPMILES*MILES
  878.                  DATA
  879.                  2  10000  13000
  880.                  4  42000   9000
  881.                  1   7000  17000
  882.                  6  52000   6000
  883.                  5  48000   8000
  884.  
  885.                  If the data records had been placed in  a  separate  file
  886.                  named  CAR.DAT,  the  DATA  statement would be changed to
  887.                  "DATA CAR.DAT".
  888.  
  889.                NONLIN -- Nonlinear Regression Program      Page 20
  890.  
  891.  
  892.          UNDERSTANDING THE RESULTS
  893.  
  894.          Nonlin  prints  a  variety  of  statistics  at  the  end  of each
  895.          analysis.  For each variable, Nonlin lists the minimum value, the
  896.          maximum value, the mean value, and the standard deviation.    You
  897.          should  confirm  that  these  values  are  within  the ranges you
  898.          expect.
  899.  
  900.          For  each  parameter,  Nonlin  displays  the  initial   parameter
  901.          estimate,  the  final (maximum likelihood) estimate, the standard
  902.          deviation of the estimated parameter  value,  the  "t"  statistic
  903.          comparing  the  estimated  parameter  value  with  zero,  and the
  904.          significance of the t statistic.
  905.  
  906.          The final estimate  parameter  values  are  the  results  of  the
  907.          analysis.   By  substituting  these  values  in  the equation you
  908.          specified to be fitted to the data, you will have a function that
  909.          can be used to predict the value of the dependent variable  based
  910.          on a  set  of values for the independent variables.  For example,
  911.          if the equation being fitted is
  912.  
  913.          y = p0 + p1*x
  914.  
  915.          and the final estimates are 1.5 for p0 and 3  for  p1,  then  the
  916.          equation
  917.  
  918.          y = 1.5 + 3*x
  919.  
  920.          is  the best equation of this form that will predict the value of
  921.          y based on the value of x.
  922.  
  923.          The "t" statistic is computed by dividing the estimated value  of
  924.          the parameter  by  its  standard  deviation.  This statistic is a
  925.          measure of the likelihood that the actual value of the  parameter
  926.          is not zero.  The larger the absolute value of t, the less likely
  927.          that the actual value of the parameter could be zero.
  928.  
  929.          The  "Prob(t)"  is  the  probability that the actual value of the
  930.          parameter could be zero.  The smaller the value of  Prob(t),  the
  931.          more significant   the   parameter.    For  example,  assume  the
  932.          estimated value of a parameter is 1.0 and its standard  deviation
  933.          is 0.7.   Then  the  t  value  would  be  1.43 (1.0/0.7).  If the
  934.          computed Prob(t) value was 0.05 then this indicates that there is
  935.          only a 0.05 (5%) chance that the actual value  of  the  parameter
  936.          could be zero.  If Prob(t) was 0.001 this indicates there is only
  937.  
  938.                NONLIN -- Nonlinear Regression Program      Page 21
  939.  
  940.  
  941.          1 chance  in  1000  that the parameter could be zero.  If Prob(t)
  942.          was  0.92 this indicates that there is a 92% probability that the
  943.          actual value of the parameter could be zero;  this  implies  that
  944.          the  term of the regression equation containing the parameter can
  945.          be eliminated without significantly affecting the accuracy of the
  946.          regression.  The t statistic  probability  is  computed  using  a
  947.          two-sided test.    The  CONFIDENCE  command  can be used to cause
  948.          Nonlin to print confidence intervals for parameter values.    The
  949.          SQUARE.NLR  example  regression  includes an extraneous parameter
  950.          (p0) whose estimated value is  much  smaller  than  its  standard
  951.          deviation;  the Prob(t) value is 0.99982 indicating that there is
  952.          a high probability that the value is zero.
  953.  
  954.          In addition to the variable and parameter values, Nonlin displays
  955.          several statistics that indicate how well the equation  fits  the
  956.          data.   The  "Final  sum of squared deviations" is the sum of the
  957.          squared differences between the actual  value  of  the  dependent
  958.          variable  for  each  observation  and  the value predicted by the
  959.          function, using the final parameter estimates.
  960.  
  961.          The "Average deviation" is the average over all  observations  of
  962.          the  absolute value of the difference between the actual value of
  963.          the dependent variable and its predicted value.
  964.  
  965.          The "Maximum  deviation  for  any  observation"  is  the  maximum
  966.          difference (ignoring sign) between the actual and predicted value
  967.          of the dependent variable for any observation.
  968.  
  969.          The  "Proportion  of variance explained (R^2)" indicates how much
  970.          better the function predicts the  dependent  variable  than  just
  971.          using the  mean  value  of  the dependent variable.  This is also
  972.          known as the "coefficient of  multiple  determination."    It  is
  973.          computed  as  follows: Suppose that we did not fit an equation to
  974.          the data  and  ignored  all  information  about  the  independent
  975.          variables in each observation.  Then, the best prediction for the
  976.          dependent  variable  value  for any observation would be the mean
  977.          value of the dependent  variable  over  all  observations.    The
  978.          "variance" is the sum of the squared differences between the mean
  979.          value   and   the  value  of  the  dependent  variable  for  each
  980.          observation.  Now, if we use our fitted function to  predict  the
  981.          value  of  the  dependent  variable,  rather  than using the mean
  982.          value, a second kind of variance can be computed  by  taking  the
  983.          sum  of the squared difference between the value of the dependent
  984.          variable  predicted  by  the  function  and  the  actual   value.
  985.          Hopefully, the variance computed by using the values predicted by
  986.  
  987.                NONLIN -- Nonlinear Regression Program      Page 22
  988.  
  989.  
  990.          the  function is better (i.e., a smaller value) than the variance
  991.          computed using  the  mean  value.    The  "Proportion of variance
  992.          explained" is computed as 1 - (variance using  predicted  value /
  993.          variance using  mean).    If  the function perfectly predicts the
  994.          observed data, the value of this statistic will be  1.00  (100%).
  995.          If  the function does no better a job of predicting the dependent
  996.          variable than using the mean, the value will be 0.00.
  997.  
  998.          An "Analysis of Variance" table  provides  statistics  about  the
  999.          overall significance of the model being fitted.
  1000.  
  1001.  
  1002.          THEORY OF OPERATION
  1003.  
  1004.          The  basis  for  the  minimization technique used by Nonlin is to
  1005.          compute the sum of the squared residuals for one set of parameter
  1006.          values and then slightly alter each parameter value and recompute
  1007.          the sum of squared residuals  to  see  how  the  parameter  value
  1008.          change affects the sum of the squared residuals.  By dividing the
  1009.          difference  between  the original and new sum of squared residual
  1010.          values by the amount the parameter was altered, Nonlin is able to
  1011.          determine the approximate partial derivative with respect to  the
  1012.          parameter.   This  partial derivative is used by Nonlin to decide
  1013.          how to alter the value of the parameter for the next iteration.
  1014.  
  1015.          If the function being modeled is well behaved, and  the  starting
  1016.          value  for  the  parameter is not too far from the optimum value,
  1017.          the procedure will eventually converge to the best  estimate  for
  1018.          the parameter.   This procedure is carried out simultaneously for
  1019.          all parameters  and  is,  in  fact,  a  minimization  problem  in
  1020.          n-dimensional space, where `n' is the number of parameters.
  1021.  
  1022.          For  a much more detailed explanation of the regression algorithm
  1023.          used by Nonlin see ACM Transactions on Mathematical Software  7,3
  1024.          (Sept.  1981)  "Dennis,  J.E.,  Gay, D.M., and Welsch, R.E. -- An
  1025.          adaptive nonlinear least-squares algorithm."
  1026.  
  1027.  
  1028.          CONVERGENCE CRITERION
  1029.  
  1030.          Nonlin has several convergence criterion that stop the  iterative
  1031.          minimization procedure.    The  TOLERANCE  command can be used to
  1032.          alter the convergence tolerance value.
  1033.  
  1034.                NONLIN -- Nonlinear Regression Program      Page 23
  1035.  
  1036.  
  1037.          Two internal variables are used to determine when convergence has
  1038.          occurred.  RFCTOL has a default value of 1E-10 and can be altered
  1039.          by use  of  the TOLERANCE command.  AFCTOL has a default value of
  1040.          1E-20 and is only altered by the TOLERANCE command if  the  value
  1041.          specified is  less  than  the  default  value.  In the discussion
  1042.          which follows the "function value" is half the sum of the squared
  1043.          residuals computed using the current parameter estimates.
  1044.  
  1045.          "Relative function convergence"  is  reported  if  the  predicted
  1046.          maximum  possible  function  reduction  is at most RFCTOL*ABS(F0)
  1047.          where F0 is the function  value  at  the  start  of  the  current
  1048.          iteration,  and  if the last step attempted achieved no more than
  1049.          twice the predicted function decrease.
  1050.  
  1051.          "Absolute function convergence" is reported if the function value
  1052.          is less than AFCTOL.
  1053.  
  1054.  
  1055.          HINTS FOR NONLIN USE
  1056.  
  1057.          Convergence Failures
  1058.  
  1059.          One of  the  potential  problems  that  confronts  any  nonlinear
  1060.          minimization    procedure    is    that    of    non-convergence.
  1061.          Non-convergence is usually not a problem for regressions using  a
  1062.          linear model, but becomes a more serious consideration when using
  1063.          complicated   nonlinear   functions;  increasing  the  number  of
  1064.          parameters aggravates the problem.
  1065.  
  1066.          Non-convergence can occur in two ways: the solution  may  diverge
  1067.          or  it  may  converge  to  the  wrong solution -- a local minimum
  1068.          rather than the global minimum.  Periodic functions, such as sin,
  1069.          and cos, are particularly prone to  convergence  problems.    For
  1070.          example,  consider  a  nonlinear  regression  performed  with the
  1071.          function:
  1072.  
  1073.          y = offset + amplitude * sin(frequency * x)
  1074.  
  1075.          where x and y are variables, and offset, amplitude, and frequency
  1076.          are the parameters whose values are to be  determined.    If  the
  1077.          starting  value  for  frequency  is  not  reasonably close to the
  1078.          correct value, the solution may converge to a harmonic (multiple)
  1079.          or subharmonic (fundamental) value of the frequency.   A  command
  1080.          file  named  SINE.NLR  is  supplied with the commands and data to
  1081.          perform this analysis.
  1082.  
  1083.                NONLIN -- Nonlinear Regression Program      Page 24
  1084.  
  1085.  
  1086.  
  1087.          The  SWEEP  command  can  be  very  useful in cases like the sine
  1088.          example.  In the SINE.NLR example analysis, the actual  value  of
  1089.          the  frequency  is  3;  the  function  converges  to  the correct
  1090.          solution if the starting value  is  in  the  range  2.6  to  3.3.
  1091.          However,  this example is quite insensitive to the starting value
  1092.          of the amplitude parameter.  With  an  actual  value  of  2,  the
  1093.          correct  solution  is  found  with starting values from 1 through
  1094.          10000.  Similarly, the offset  parameter,  which  had  an  actual
  1095.          value  of  10,  was  successfully determined with starting values
  1096.          ranging from 1 to over 50000.
  1097.  
  1098.          Another example which is sensitive to a parameter starting  value
  1099.          is  POWER.NLR  which  attempts  to  determine  the  values of the
  1100.          parameters p0, p1, and p2 for the function
  1101.  
  1102.          y = p0 + p1*x^p2
  1103.  
  1104.          (where "x^p2" means x raised to the p2 power).  The actual  value
  1105.          of  p2 in the example data is 2; the solution converges correctly
  1106.          if the starting value of p2 is in the range 1.8 to 3.8.  As  with
  1107.          the  other example, the solution is relatively insensitive to the
  1108.          starting values of p0 and p1.
  1109.  
  1110.          Singular Matrix Problems
  1111.  
  1112.          Another possible problem is that the analysis may stop  with  the
  1113.          message "Singular  convergence.  Mutually dependent parameters?".
  1114.          This is usually due  to  one  of  two  things:  (1)  a  redundant
  1115.          parameter  that  is co-dependent with another parameter, or (2) a
  1116.          situation where the value of one parameter "blocks" the effect of
  1117.          other parameters.
  1118.  
  1119.          As an example of a redundant parameter, consider the function
  1120.  
  1121.          y = p0 + p1*p2*x
  1122.  
  1123.          This is a simple linear equation except there are two parameters,
  1124.          p1, and p2, which are both factors to the variable x.  It  should
  1125.          be  clear  that there is no unique solution to this problem since
  1126.          any value of p1 is possible if the right value of p2  is  chosen.
  1127.          Similarly, the function
  1128.  
  1129.          y = p0 + p1 + p2*x
  1130.  
  1131.                 NONLIN -- Nonlinear Regression Program      Page 25
  1132.  
  1133.  
  1134.          has no unique solution since either p0 or p1 is redundant.
  1135.  
  1136.          Similarly, in the equation
  1137.  
  1138.          y = p0 + p1*exp(x+p2)
  1139.  
  1140.          either p1 or p2 is redundant.
  1141.  
  1142.          The second type of singular matrix problem can be illustrated  by
  1143.          the function
  1144.  
  1145.          y = p0 + p1*x^p2
  1146.  
  1147.          If,  during  the  solution process, p1 takes on the value 0, then
  1148.          varying the value of p2 has no effect on the equation and  Nonlin
  1149.          cannot  figure  out  which  way to change the value of p2 to move
  1150.          toward convergence.  The solution to this problem is to assign  a
  1151.          starting  value  that  is  not  zero to p1, and use the CONSTRAIN
  1152.          command to force p1 to remain non-zero.
  1153.  
  1154.  
  1155.          PERFORMANCE ISSUES
  1156.  
  1157.          Nonlin is carefully programmed and compiled  with  an  optimizing
  1158.          compiler for  maximum  performance.    However,  Nonlin is a real
  1159.          "number cruncher," and  the  nonlinear  regression  algorithm  is
  1160.          mathematically very  elaborate.    During  each iteration, Nonlin
  1161.          computes gradients, Jacobians,  Hessians,  and  eigenvalues,  and
  1162.          performs QR and Cholesky matrix decompositions.  All calculations
  1163.          are carried out using double precision (64 bit) floating point.
  1164.  
  1165.          Nonlin  does  not  require  an 80x87 numeric coprocessor, but its
  1166.          performance is greatly enhanced if one is present.  In  fact,  an
  1167.          8088  CPU with an 8087 numeric coprocessor can perform regression
  1168.          analyses faster  than  a  20 MHz  80386  that  does  not  have  a
  1169.          coprocessor.   If  you  have  an  8088  without a coprocessor, be
  1170.          patient -- Nonlin is probably giving it the workout of its life.
  1171.  
  1172.          Very long running times can result if you use the  SWEEP  command
  1173.          with many starting values.  The problem is compounded if you have
  1174.          multiple SWEEP  commands.   If you use the SWEEP command to try a
  1175.          large number of starting parameter values, you can save  time  by
  1176.          using  the  ITERATIONS  command  to  specify  a  small  number of
  1177.          iterations (such as 5) during  the  initial  attempt  to  find  a
  1178.          solution.   Once  a feasible set of starting parameter values has
  1179.  
  1180.                 NONLIN -- Nonlinear Regression Program      Page 26
  1181.  
  1182.  
  1183.          been determined, remove the SWEEP command, specify  the  starting
  1184.          values  on  the  PARAMETERS  command,  increase  the  number   of
  1185.          iterations, and rerun the analysis to get the final result.
  1186.  
  1187.          PROGRAM LIMITS
  1188.  
  1189.          The following is a summary of the Nonlin program limitations:
  1190.  
  1191.          Maximum number of variables = 12
  1192.          Maximum number of parameters = 12
  1193.          Maximum length of variable or parameter names = 10
  1194.  
  1195.          The  maximum  number  of data observations that Nonlin can handle
  1196.          depends on the number of parameters as shown by  the  table  that
  1197.          follows:
  1198.  
  1199.               # Parameters    Max Observations
  1200.                     1               2019
  1201.                     2               1611
  1202.                     3               1339
  1203.                     4               1144
  1204.                     5                997
  1205.                     6                883
  1206.                     7                791
  1207.                     8                715
  1208.                     9                652
  1209.                    10                599
  1210.  
  1211.  
  1212.          EXAMPLE ANALYSES
  1213.  
  1214.          A  number  of example regression analysis files are provided with
  1215.          your Nonlin distribution.  All of the example command files  have
  1216.          the extension  ".NLR".   Some of the important ones are described
  1217.          below, others contain comment lines that explain what they do.
  1218.  
  1219.          LINEAR.NLR -- Simple linear regression with plotted function  and
  1220.                    data.
  1221.  
  1222.          QUAD.NLR --  Fit a quadratic equation.  Plot the function and the
  1223.                    data.
  1224.  
  1225.          ASYMPTOT.NLR -- Fit an asymptotic function Y = 12 - 10/X.
  1226.  
  1227.                 NONLIN -- Nonlinear Regression Program      Page 27
  1228.  
  1229.  
  1230.          F33.NLR -- Multivariate linear regression.  Calculate  the  value
  1231.                    of a used Beech F33 Bonanza  airplane  using  a  linear
  1232.                    model  based  on  its  age,  the number of hours on its
  1233.                    airframe, and the number of hours on its engine.  The t
  1234.                    value and Prob(t) indicate that the number of hours  on
  1235.                    the  engine  (`Engdep' parameter) are not signficant to
  1236.                    the  regression  model;  the   other   parameters   are
  1237.                    significant  but  airframe  hours  are less significant
  1238.                    than the base price and age of the plane.
  1239.  
  1240.          F33YEAR.NLR -- Similar to F33.NLR except the price of the Bonanza
  1241.                    is calculated based only on the age.  The  function  is
  1242.                    plotted.
  1243.  
  1244.          F33EXP.NLR   --   Similar   to   F33YEAR.NLR  except  a  negative
  1245.                    exponential function  is  used  rather  than  a  linear
  1246.                    function.   Compare  the fit of this model with that of
  1247.                    the F33YEAR.NLR example.
  1248.  
  1249.          SINE.NLR -- Fit an equation involving a sin function.  The  SWEEP
  1250.                    command  is  used  to  find  a starting point that will
  1251.                    converge.
  1252.  
  1253.          SQUARE.NLR -- Fit a sine series to a square wave.  Note  in  this
  1254.                    example  that  the 'p0' parameter, which represents the
  1255.                    constant term of the equation, has an  estimated  value
  1256.                    of  9.22715E-006  (very  nearly  zero)  and  a standard
  1257.                    deviation of 0.0398754.   This  yields  a  t  value  of
  1258.                    nearly  zero  and  Prob(t)  of 0.99982 which means that
  1259.                    there is a 99.982% chance that the actual value  of  p0
  1260.                    may be zero (it is in fact zero).  This illustrates how
  1261.                    you  can  use  the  t  value  and  Prob(t)  to identify
  1262.                    extraneous parameters.
  1263.  
  1264.          COOLING.NLR -- Fit an equation involving an exponential function.
  1265.                    If a heated object is allowed  to  cool,  the  rate  of
  1266.                    cooling   at   any   instant  is  proportional  to  the
  1267.                    difference between the object's temperature and ambient
  1268.                    (room) temperature.   The  function  that  relates  the
  1269.                    object's temperature to time is:
  1270.  
  1271.                    Temperature = Roomtemp+InitTemp*exp(-Coolrate*Time)
  1272.  
  1273.                    Where  InitTemp  is  the  temperature  at  time  0, and
  1274.                    Coolrate is a factor that depends on the  mass  of  the
  1275.  
  1276.                NONLIN -- Nonlinear Regression Program      Page 28
  1277.  
  1278.  
  1279.                    object, how  well  it  is  insulated,  etc.    The  exp
  1280.                    function  is  the value of e (2.7182818...) raised to a
  1281.                    power.   The   COOLING.NLR   example   determines   the
  1282.                    parameters  InitTemp and Coolrate to fit an equation of
  1283.                    this form to some data the author collected.
  1284.  
  1285.          BOIL.NLR -- The boiling point of water decreases as the  pressure
  1286.                    in   the   vessel   containing   the  water  decreases.
  1287.                    "Clapeyron's equation" shows that the boiling point  is
  1288.                    related   to   pressure   according  to  the  following
  1289.                    function:
  1290.  
  1291.                    Temperature = b / log(Pressure/a) - 459.7
  1292.  
  1293.                    Where `Temperature' is in degrees Fahrenheit (the 459.7
  1294.                    constant converts degrees Fahrenheit to degrees Rankine
  1295.                    --  relative  to  absolute  zero),  `Pressure'  is  the
  1296.                    pressure  in  the vessel in pounds per square inch, and
  1297.                    `a' and `b' are  parameters  whose  values  are  to  be
  1298.                    determined.  The data for this example was collected by
  1299.                    the author's son for a science project.
  1300.  
  1301.          MAGNET.NLR  --  Fit  a  function  involving  an arc tangent and a
  1302.                    variable to the third power.  This  is  an  interesting
  1303.                    physics problem.    If a magnet is placed due east of a
  1304.                    compass, the deflection  of  the  compass  needle  from
  1305.                    north  is  equal to the arc tangent of the ratio of the
  1306.                    strength of the magnet's field relative to the  earth's
  1307.                    magnetic field.   The strength of the magnet's field at
  1308.                    the compass is inversely proportional to  the  cube  of
  1309.                    the distance from the magnet to the compass.  Thus, the
  1310.                    function relating these terms is
  1311.  
  1312.                    Deflection = deg(atan(Strength / Distance ^ 3))
  1313.  
  1314.                    The  deg  function  converts  an  angle  in  radians to
  1315.                    degrees.  In the example, Deflection and  Distance  are
  1316.                    the  variables, and the value of the Strength parameter
  1317.                    is determined.
  1318.  
  1319.          DIODE.NLR -- The current through a diode increases sharply as the
  1320.                    voltage across the diode is  increased.    An  equation
  1321.                    that approximates the current flow as a function of the
  1322.                    voltage is:
  1323.  
  1324.                 NONLIN -- Nonlinear Regression Program      Page 29
  1325.  
  1326.  
  1327.                            I = exp(b*(V-c))
  1328.  
  1329.                    where `I' is the current, `V' is the voltage, and  `b',
  1330.                    and  `c' are parameters that are to be estimated by the
  1331.                    nonlinear regression.
  1332.  
  1333.                NONLIN -- Nonlinear Regression Program      Page 30
  1334.  
  1335.  
  1336.          ACKNOWLEDGEMENT
  1337.  
  1338.          The  nonlinear  regression algorithm used by Nonlin was published
  1339.          in ACM Transactions on Mathematical  Software  7,3  (Sept.  1981)
  1340.          "Dennis,  J.E.,  Gay,  D.M.,  and  Welsch,  R.E.  --  An adaptive
  1341.          nonlinear least-squares algorithm."
  1342.  
  1343.  
  1344.          USE AND DISTRIBUTION OF NONLIN
  1345.  
  1346.          Nonlin is a "shareware" product.  You are welcome to make  copies
  1347.          of  this program and pass them on to friends or post this program
  1348.          on bulletin boards.
  1349.  
  1350.          However, if you find Nonlin to be useful and/or entertaining  you
  1351.          are expected to compensate the author by sending the registration
  1352.          form  printed  on  a  following  page  with $20 to help cover the
  1353.          development and support of Nonlin.  In return, you  will  receive
  1354.          the most recent version of the program along with a bound manual.
  1355.          Specify the  type  of disk you wish to receive.  Add $5 if Nonlin
  1356.          is being shipped out of the United States.
  1357.  
  1358.          See also the special offer that follows  involving  the  Mathplot
  1359.          program.
  1360.  
  1361.          You are welcome to write to the author:
  1362.  
  1363.                                 Phillip H. Sherrod
  1364.                                  4410 Gerald Place
  1365.                              Nashville, TN  37205-3806
  1366.  
  1367.          Both  the Nonlin program and documentation are copyright (c) 1992
  1368.          by Phillip H. Sherrod.  You are  not  authorized  to  modify  the
  1369.          program. "Nonlin" is a trademark.
  1370.  
  1371.          Disclaimer
  1372.  
  1373.          Nonlin  is  provided "as is" without warranty of any kind, either
  1374.          expressed or implied.    This  program  may  contain  "bugs"  and
  1375.          inaccuracies, and its results should not be assumed to be correct
  1376.          unless they  are  verified  by  independent  means.    The author
  1377.          assumes no responsibility for the use of Nonlin and will  not  be
  1378.          responsible for any damage resulting from its use.
  1379.  
  1380.                 NONLIN -- Nonlinear Regression Program      Page 31
  1381.  
  1382.  
  1383.  
  1384.  
  1385.                                   M A T H P L O T
  1386.  
  1387.  
  1388.                       Mathematical Function Plotting Program
  1389.  
  1390.  
  1391.                                    Special Offer
  1392.  
  1393.  
  1394.  
  1395.          If you like Nonlin, you should check out the Mathplot program  by
  1396.          the same author.
  1397.  
  1398.          Mathplot allows you to specify complicated mathematical functions
  1399.          using  ordinary  algebraic expressions and immediately plot them.
  1400.          Four types of functions may  be  specified:  cartesian  (Y=f(X));
  1401.          parametric     cartesian     (Y=f(T)     and    X=f(T));    polar
  1402.          (Radius=f(Angle));  and   parametric   polar   (Radius=f(T)   and
  1403.          Angle=f(T)).  Up to four functions may be plotted simultaneously.
  1404.          Scaling is  automatic.    Options  are  available to control axis
  1405.          display and labeling as well as grid lines.  Hard copy output may
  1406.          be generated as well as screen display.   Mathplot  is  an  ideal
  1407.          tool  for  engineers,  scientists, math and science teachers, and
  1408.          anyone  else  who  needs  to   quickly   visualize   mathematical
  1409.          functions.
  1410.  
  1411.  
  1412.          SPECIAL OFFER
  1413.  
  1414.          Registered users of Nonlin can order Mathplot for a special price
  1415.          of $18.   Or, for an even better deal, if you register Nonlin and
  1416.          order Mathplot at the same time, you can get both for $36.
  1417.  
  1418.                NONLIN -- Nonlinear Regression Program      Page 32
  1419.  
  1420.  
  1421.        =====================================================================
  1422.                                 Software Order Form
  1423.        =====================================================================
  1424.  
  1425.          NAME ______________________________________________________
  1426.  
  1427.          ADDRESS ___________________________________________________
  1428.  
  1429.          CITY _______________________  STATE _______ ZIP ___________
  1430.  
  1431.          TELEPHONE _________________________________________________
  1432.  
  1433.          NONLIN VERSION ____________________________________________
  1434.  
  1435.          BULLETIN BOARD WHERE YOU FOUND NONLIN _____________________
  1436.  
  1437.          COMMENTS __________________________________________________
  1438.  
  1439.          Check the box below which indicates your order type:
  1440.  
  1441.          ___ I wish to register Nonlin ($20).
  1442.  
  1443.          ___ I wish to order Mathplot ($20).
  1444.  
  1445.          ___ I wish to register Nonlin and order Mathplot ($36).
  1446.  
  1447.          Add $5 to any amount shown above if the software is being shipped
  1448.          out of the United States.
  1449.  
  1450.          In  return  for  registering,  you  will  receive the most recent
  1451.          version of the program and a bound copy of the manual.
  1452.  
  1453.          Distribution disk choice (check one):
  1454.  
  1455.                3.50" HD (1.4 MB)  ______
  1456.                5.25" HD (1.2 MB)  ______
  1457.                5.25" DD (360 KB)  ______
  1458.  
  1459.          Send this form with the amount indicated to the author:
  1460.  
  1461.                                 Phillip H. Sherrod
  1462.                                  4410 Gerald Place
  1463.                              Nashville, TN  37205-3806
  1464.