Kang, G. and John D. Rawlings; (1989)A nonlinear regression program with emphasis on the curvature and experimental desigDocumentation for Program NLIN-CUR.ED."

No. 1942
Table of Contents
1. Overview
2. Implementation
3. Usage
4. An Example
Acknowledgements
References
Appendix 1. Explanation of Subroutine MODEL
Appendix 2. Structure of the Input Data File
Appendix 3. A Sample Output
Appendix 4. Description of Subroutines
Appendix 5. Program Listings
page 1
Program NLIN-CUR·ED
1. Overview
Program NLIN-CUR·ED (a nonlinear regression program with emphasis on the
curvature and experimental design) is designed to facilitate" the choice of design points for
experiments in which nonlinear response functions are to be fitted. With user-supplied model
and data, the program will compute design criteria and measures of curvature of the
model/data set combination using specified values of the model parameters or values estimated
from the data if response values are given. The determinants of the first-order approximation
of the variance-covariance matrix for all parameters and specified subsets of parameters are
computed as the design criteria, and measures of curvature of the model/data set combination
are computed to assess the adequacy of the linear approximation theory being used in
standard nonlinear estimation.
The program also provides for computation of variance and
measures of curvature for nonlinear functions of the parameters.
1) Parameter estimation (optional)
If a complete data set is given and estimation option is requested, NLIN -CUR· ED uses
a Gauss-Newton method to obtain the least squares estimates of the model parameters
iteratively. It prints out some basic statistics such as estimates, standard errors, correlation
matrix, and variance estimate.
If estimation is not requested, the program uses the user-supplied parameter values to
evaluate other statistics.
2) Global curvature
The two global nonlinearity measures by Bates and Watts (1980), intrinsic curvature
and parameter-effects curvature, are computed.
Bates and Watts proposed two types of
measures, maximum curvature and root mean square (rms) curvature. Since both curvatures
perform similarly, only the rms curvatures are calculated in this program.
page 2
3) Marginal curvature
Marginal curvatures for individual parameters proposed by Clarke (1987) areevaluated.
NLIN-CUR·ED uses the computation algorithm developed in Kang and Rawlings (1989). Two
confidence intervals for each parameter are given.
The first one is based on
linear
approximation theory and the second confidence interval uses the adjustment for marginal
curvature proposed by Clarke (1987).
4) Marginal curvature for functions of parameters (optional)
If the user requests this option and supplies the subroutine TRANSF, which calculates
the first and second derivatives of the transformation functions with respect to the original
parameters, NLIN-CUR·ED computes marginal curvature for each function using the formula
developed in Kang and Rawlings (1989).
The number of transformation functions can be
between 1 and p, the number of the original parameters.
The program also prints out the
values of the transformation evaluated at the current values of the original parameters as well
as their standard errors and two confidence intervals as in 3).
5) O-optimal design criterion
NLIN-CUR·ED evaluates the D-optimal design criterion for all parameters or any
subsets of parameters specified by the user.
For example, assigning the index of one to all
parameters evaluate the full-set D-optimal design criterion.
Given a model function, the above procedure can be repeated for more than one data set.
page 3
2. Implementation
The
main
program
and
all subroutines are written
(FORTRAN 77 or IBM VS FORTRAN Version 2 level).
in
FORTRAN
language
NUN-CUR· ED also uses Linpack
subroutines (Dongarra et. aI, 1979) to do computations more precisely and efficiently.
computations are done in double precision.
All
The program has been used with IBM 3081 at
TUCC, Research Triangle Park, NC.
In addition to the main program and Linpack subroutines, the following subroutines
are used.
(A double-precision function DTIN of IMSL, which returns quantiles of
t
distribution, is used in subroutines RSTWR2 and RSTWR3.)
CNVRGE, CORCOM, DETCOM, EXPAND, FZERO, JDALOC, JIALOC,
JSINIT, MARCUR, MATRAN, PGHEAD, RMSCUR, RSTWR1, RSTWR2,
RSTWR3, STOCOM, TRANSF
These subroutines are explained
10
Appendix 4 and listed in Appendix 5. Each subroutine is
fully documented in the list.
3. Usage
Users should supply subroutine MODEL which evaluates the model function and its
first and second derivatives at the current parameter values, and one or more input data files.
See Appendix 1 for the input and output arguments of subroutine MODEL and Appendix 2
for the structure of the input data file.
If the evaluation of the marginal curvatures for functions of parameters is requested,
the the user should supply subroutine TRANSF, which evaluates the transformation functions
and their first and second derivatives at the current original parameter values. Even when this
computation is not requested, subroutine TRANSF should physically exist because FORTRAN
language tries to link all the subroutines specified in the program.
can be used in this case since it will not be called.
Any subroutine TRANSF
Refer to subroutine TRANSF.M211 listed
in Appendix 5 for the detailed documentation to make subroutine TRANSF for other
page 4
transformations.
Since users do not have to change other subroutines, they may want to compile those
subroutines and to use their object files.
The following is a sample layout of input job control
language in IBM 3081 for the example described in the next section.
IIJOBNAME JOB NCS.ES.G7181,KANG,PRTY=O
EXEC FORTVCLG
IIFORT.SYSIN DD DISP=SHR,DSN=NGKANG.MAIN.CURV.FORT
II
DD DISP=SHR,DSN=NGKANG.M210.FORT
II
DD DISP=SHR,DSN=NGKANG.TRANSF.M211.FORT
IILKED.SYSLIB DD
II
DD
II
DD
II
DD
II
DD DISP=SHR,DSN=NGKANG.NCSU.LINPACK
IILKED.SYSIN DD DISP=SHR,DSN=NGKANG.NONLIN.LIB.OBJ
II
DD DISP=SHR,DSN=NGKANG.CNVRGE.OBJ
II
DD DISP=SHR,DSN=NGKANG.CORCOM.OBJ
II
DD DISP=SHR,DSN=NGKANG.DETCOM.OBJ
II
DD DISP=SHR,DSN=NGKANG.FZERO.OBJ
II
DD DISP=SHR,DSN=NGKANG.MARCUR.OBJ
II
DD DISP=SHR,DSN=NGKANG.MATRAN.OBJ
II
DD DISP=SHR,DSN=NGKANG.RMSCUR.OBJ
II
DD DISP=SHR,DSN=NGKANG.STOCOM.OBJ
II
DD DISP=SHR,DSN=NGKANG.WRITE.OBJ
IIGO.FT07F001 DD DISP=SHR,DSN=NGKANG.D210.DATA
II
In the above layout, file MAIN.CURV.FORT contains the main program, file M210.FORT
contains subroutine MODEL for
the model described in the next section, and file
TRANSF.M211.FORT contains subroutine TRANSF for the requested computation of
marginal curvatures for functions of parameters. The five DD lines from 'I/LKED.SYSLIB'
are needed for Linpack subroutines.
RSTWR2, RSTWR3.
JIALOC, and JSINIT.
input data file.
File WRITE.FORT contains subroutines
RSTWR1,
File NONLIN.LIB.FORT has other subroutines, EXPAND, JDALOC,
Files with
.OBJ are object files.
Finally, file D210.DATA is the
page 5
4. An Example
Consider an example from Clarke (1987) using Michaelis-Menten model
f =
0l x / (02
+
(1)
x)
This model has one desi.gn variable, x, and two parameters, 01 and 02'
observations.
There are 6
File M210.FORT contains subroutine MODEL for this model and file
D210.DATA is the input data file for this example. (See Appendix 1 for the complete list of
M210.FORT and its explanation.
List of D210.DATA is given below and further explained in
Appendix 2.)
Another popular form of model (1) is
f
=x/
(13 1 + t3 2 x )
(2)
That is, the model has been reparametrized with
Suppose we want marginal curvatures of
02
when we use the model (1).
TRANSF which evaluates
01 arid 02'
13 1
and
13 1
and
13 2
as well as marginal curvatures of 01 and
For this, file TRANSF.M211.FORT contains subroutine
13 2
and their first and second derivatives with respect to
(See Appendix 5 for the complete listing of TRANSF.M211.FORT.)
Also suppose we want to estimate 01 and 02 from the data and to evaluate D-optimal
design criterion for all subsets of parameters,
then file D210.DATA can have the following
structure.
Michaelis-Menten Model, f = .1'1
2 1
0.6904 0.5965
161
0.138 0.148
0.220 0.171
0.291 0.234
0.560 0.324
0.766 0.390
1.460 0.493
1
3
1 1
o1
1 0
END
Output of this example is given in Appendix 3.
*x
/ ( .1'2
+x )
page 6
Acknowledgements
This research was supported by funds provided by the Southeastern Forest Experiment
Station,
Southern
Commercial
Forest
Research
Cooperative
within
the
joint
Environmental Protection Agency- USDA Forest Service Forest Response Program.
US
The
Forest Response Program is part of the National Acid Precipitation Assessment Program.
This paper has not been subject to EPA or Forest Service policy review and should not be
construed to represent the policies of either Agency.
We also thank Professor Douglas Bates of University of Wisconsin for allowing use of
his subroutines CNVRGE and RMSCUR.
References
Bates, D. M. and Watts, D. G. (1980), Relative Curvature Measures of Nonlinearity
(with discussion), Journal of the Royal Statistical Society, Ser. B, 42, 1-25.
Clarke, G. P. Y. (1987), Marginal Curvatures and Their Usefullness in the Analysis
of Nonlinear Regression, Journal of the American Statistical Association,
82, 844-850.
Dongarrs, J. J., Bunch, J. R., Moler, C. B., and Stewart, G. W. (1979), Linpack Users'
Guide, SIAM, Philadelphia.
Kang, G. and Rawlings, J. O. (1989), Marginal Curvatures for Functions of
Parameters in Nonlinear Regression. Paper No.
of the Journal Series
of the North Carolina Agricultural Research Service, Raleigh, N.C.
page 7
Appendix 1. Explanation of Subroutine MODEL
Users should supply subroutine MODEL which evaluates the model function and its
first and second derivatives with respect to model parameters.
Following is the description
for subroutine MODEL and its input and output arguments.
SUBROUTINE MODEL (NaBS, P, DESIGN, LDDSGN, JOB, XPECTD, DERIV,
LODER, INFO)
INTEGER NPAR, NTOTAL, NVAR
PARAMETER (NPAR = xx, NTOTAL = xx, NVAR = xx)
INTEGER NaBS, LDDSGN, JOB, LDDER, INFO
DOUBLE PRECISION P(NPAR), DESIGN(LDDSGN ,NVAR), XPECTD(NOBS),
*
DERIV(LDDER,NTOTAL)
*
Input:
NaBS
P
DESIGN
LDDSGN
JOB
LDDER
no. of observations
vector of current parameter values
matrix of design variables
leading dimension of the matrix DESIGN (usually LDDSGN=NOBS)
if JOB=O, model function is evaluated,
if 1 ::; JOB::; 9, model function and first derivatives are evaluated,
if 10 ::; JOB ::;99, model function, first and second derivatives are evaluated.
leading dimension of DERIV (usually LDDER=NOBS)
Output :.
XPECTD
DERIV
vector of the expected values
if 1 ::; JOB ::;9, DERIV has NP AR columns of first derivatives
if 10 ::; JOB::; 99, DERIV has NTOTAL columns of first and second
derivatives. First NPAR columns contain first derivatives and next
NPAR*(NPAR+1)/2 columns contain second derivatives in symmetric
storage format (Le., 11, 12, 22, 13, 23, 33, ..., pp).
Note that there are 3 variables which are defined within each routine; NP AR, NTOTAL, and
NVAR.
NPAR
NTOTAL
NVAR
no. of parameters
= NPAR*(NPAR+3)/2
no. of design variables
These values must be the same as the ones supplied by the input data file or the program will
abort.
The next page shows subroutine MODEL for the example described in Section 4,
M210.FORT.
page 8
c
c
c
Michaelis-Menten : M210
f - p(l)·* x / ( p(2) + x )
subroutine model (nobs, p, design, lddsgn, job, xpectd, deriv1,
ld1, info)
integer npar, ntotal, nvar
parameter (npar-2, ntotal-5, nvar-1)
integer nobs, lddsgn, job, ld1, info
double precision p(npar), design(lddsgn,nvar), xpectd(nobs),
*
derivl(ld1,ntotal)"
*
c
c
c
c
c
c
c
integer i, j, k
double precision f, denom
info - 0
do 100 i - I , nobs
denom - p(2) + design(i,nvar)
if ( denom .le. O.OdO ) then
info - -1
return
eI:\dif
f - p(l) * design(i,nvar) / denom
function values
xpectd(i) - f
first derivatives
if (mod(job,10) .ne. 0) then
deriv1(i,1) - design(i,nvar) / denom
deriv1(i,2) - - f / denom
endif
second derivatives
if (mod((job/10),10) .ne. 0) then
derivl(i,3)
- O.OdO
derivl(i,4)
- - f / ( p(l) * denom"
derivl(i,5)
- 2.0dO * f / denom**2
endif
if (job/IOO .ne. 0) then
info - 3
endif
100 continue
return
end
00000100
00000200
00000300
00000400
00000500
00000600
00000700
00000800
00000900
00001000
00001100
00001200
00001300
00001400
00001500
00001600
00001700
00001800
00001900
00002000
00002100
00002200
00002300
00002400
00002500
00002600
00002700
00002800
00002900
00003000
00003100
00003200
00003300
00003400
00003500
00003600
00003700
00003800
00003900
00004000
00004100
00004200
00004300
00004400
page 9
Appendix 2. Structure of the Input Data File.
Data are input with a free format, separated by blanks.
Line 1: Title, which can be anything
Line 2-1: NPAR
NEEDES
(where NPAR
=
no. of parameters and NEEDES
estimation. If NEEDES
= 0,
=
option for parameter
no estimation is done.
The supplied parameter values (LINE 3) are used to evaluate other statistics.
Otherwise, estimation is done using those values as starting values.)
Line 2-2: variance estimate (This is needed only when NEEDES = O. This line should
not be included when NEEDES
=#
0.)
Line 3: Initial or converged parameter values
Line 4: NIND NOBS YOPT
= no. of design variables,
(NIND
YOPT
NOBS
= no. of observations,
= 0 if no Y values are input. Otherwise, YOPT
=1= 0.)
Line 5 - Line NOBS+4: Data (Y is in the last column.)
Line NOBS+5:
ITRANS
(If ITRANS = 0, no transformations are required.
If ITRANS =1= 0, marginal curvatures of functions of parameters are
computed.
The user should supply an appropriate subroutine TRANSF.)
Line NOBS+6: NSDET
(NSDET = no. of requests for evaluation of the determinant criterion.)
Line NOBS+7 - Line NOBS+NSDET+6: List of indices.
of all parameters.
(Each line contains indices
The determinant criterion is evaluated for the subset of
parameters whose indices are 1.)
Last line: END (optional)
(If there are other data sets for the same model function, then contents from
Line 1 to Line NOBS+NSDET+6 can be repeated for those data sets
without END. The program terminates when it reads END or encounters
the end of the input data file.)
A sample of this input data file for the Michaelis-Menten example was shown in Section 4.
page 10
.Appendix 3.
A Sample Output
The folIoing is the output of NLIN-CUR.ED for the Michaelis-Menten example
,cribed in Section 4.
l
*
Title: MICHAELIS-MENTEN MODEL, F - P1
Input Data
0.14800
0.17100
0.23400
0.32400
0.39000
0.49300
Parameter estimation required.
1
0.59650
Estimate
0.690399
0.596546
Variance estimate
~~obal
Initial parameter values are
2
0.69040
1
2
( p2 + X )
X's and Y
0.13800
0.22000
0.29100
0.56000
0.76600
1.4600
Para.
X /
Std.Error
Correlation
3.682452E-02
6.825694E-02
1.00
0.95
1.8400E-04
based on
1.00
4
degrees of freedom
curvature (rms)
Intrinsic •
0.03070
0.12547
Parameter·
Compare these values with F value with ( 2,
4) d.f., alpha • 0.05.
Both values are considered small if c * sqrt(F) « 1, where c is a curvature.
Eg., if we accept a deviation of no more than 15%(10%), then we will declare
this analysis as having unacceptable curvature if at least one value of
c * sqrt(F)
is greater than 0.3 (0.2) (Bates & watts (1980), JRSSB, pp.1-25)
Marginal curvature for each parameter
Para.
Curvature
1
2
0.04826
0.06321
Ic
*
tl
0.10289
0.13475
where c is the marginal curvature and t
is the upper 0.05 quantile of
t distribution with
4 d.f.
If
Ic * tl < 0.1, curvature effects may be ignored and linear approximation
will suffice.
If 0.1 < Ic * tl < 1/3, curvature effects should be compensated for as
suggested by Clarke.
If
Ic * tl > 1/3, curvature effects are serious enough to make any simple
analysis risky. (Clarke (1987), JASA, pp.844-850)
page 11
j% Confidence Intervals
Para.
Linear Approx.
Lower
Upper
Est.
0.6904
0.5965
1
2
0.6119
0.4510
Adjusted by Curvature
Lower
Upper
0.7689
0.7421
0.6200
0.4706
0.7770
0.7617
Marginal curvature of the transformed parameters
No. of transformation =
Para.
1
2
Value
0.86406
1.4484
2
Std.Error
Curvature
Ic * tl
0.02461
0.00507
0.05247
0.01082
5.73255E-02
7.72569E-02
95% Confidence Intervals
Linear Approx.
Lower
Upper
0.74185
1.2837
0.98627
1.6131
Adjusted by Curvature
Lower
Upper
0.74826
1.2855
0.99268
1.6149
optimal design criterion : evaluated for the subset of parameters whose
index is 1
DET DET DET =
0.22395
0.19873
0.36836
INDEX INDEX •
INDEX =
1
1
1
1
0
o
page 12
Appendix 4. Description of Subroutines
CNVRGE
calculate the parameter estimates in a nonlinear regression model
using a Gauss-Newton algorithm.
CORCOM: calculate the correlation matrix and parameter standard errors.
DETCOM: evaluate the determinant criterion for the optimal design (for both
full and subset designs).
EXPAND
convert a matrix having a symmetric storage form into the regular
three-dimensional array.
FZERO
find the first zero element of a vector and return its index.
JDALOC
allocate a block of double precision scratch storage locations and
return the pointer to them.
JIALOC
allocate a block of integer scratch storage locations and return the
pointer to them.
JSINIT
initialize scratch storage variables.
MARCUR: compute marginal curvatures for parameters in a nonlinear model.
MATRAN: compute marginal curvatures and standard errors of the
transformed parameters.
PGHEAD
write out page header.
RMSCUR
calculate the intrinsic and parameter-effects curvature.
RSTWR1
print summary parameter estimation results such as estimates,
standard errors, correlations, and variance estimate.
RSTWR2
print summary results of the global and marginal curvature.
RSTWR3
print summary results of marginal curvatures of the transformed
parameters.
STOCOM
evaluate the required amount of storage for the submitted jobs.
page 13
Appendix 5. Program listings
Source programs are listed in the following order.
Main Program
CNVRGE
CORCOM
DETCOM
EXPAND
FZERO
JDALOC
JIALOC
JSINIT
MARCUR
MATRAN
PGHEAD
RMSCUR
RSTWR1
RSTWR2
RSTWR3
STOCOM
TRANSF (TRANSF.M211.FORT)
MODEL (M21O.FORT)
input data file (D210.DATA)
C
C
Main of Program NLIN-CUR.ED : a nonlinear regression program with
emphasis on the curvature and experimental design.
C
C
Gunseog Kang (Oct. 1988 - Jan. 1989)
C
integer i, j, info
character*1 ktit1e(80)
common /jtitle/ktitle
integer infile, outfil, verfil
common /units/infile, outfil, verfil
integer npar, nspar, ntotal, needes, nind, nobs, yopt, iter,
*
nsdet, nnorm, ntrans, itrans
double precision ssqrs, crit, sigma2, rparam, rintrn, temp,
*
eps
C
C
C
C
C
C
C
C
C
C
C
C
(
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
ntrans
itrans
no. of parameters
- npar*(npar+i)/2
- npar*(npar+3)/2
option for parameter estimation
no. of design variables
no. of observations
option for Y input
no. of parameters subsets for which the design criterion
is evaluated.
no. of orthogonal columns of the second derivative array
to the tangent plane.
no. of transformed parameters
option for transformed parameters
ssqrs
crit
sigma2
rparam
rintrn
eps
SSQ or variance estimate
estimation criterion
variance estimate
rms parameter-effects curvature
rms intrinsic curvature
machine precision (0.222d-15 for IBM 3081)
npar
nspar
ntotal
needes
nind
nobs
yopt
nsdet
nnorm
storage allocation : the storage for all vectors and matrices are
supplied from a big vector of size 8192.
The required
amount for each job is checked in subroutine STOCOM.
If it exceeds 8192, it will print a message and the amount.
INTEGER MAXRSC, MAXDSC, MAXISC
PARAMETER (MAXRSC-8192, MAXDSC-MAXRSC/2, MAXISC=MAXRSC)
DOUBLE PRECISION DS(MAXDSC)
REAL RS(MAXRSC)
INTEGER IS(MAXISC), RSPTR, ISPTR, JSERR
EQUIVALENCE (RS(1),DS(1),IS(1))
COMMON /JSCRAT/ IS, RSPTR, ISPTR, JSERR
INTEGER JDALOC, JIALOC, JRALOC
C
00000100
00000200
00000300
00000400
00000500
00000600
00000700
00000800
00000900
00001000
00001100
00001200
00001300
00001400
00001500
00001600
00001700
00001800
00001900
00002000
00002100
00002200
00002300
00002400
00002500
00002600
00002700
00002800
00002900
00003000
00003100
00003200
00003300
00003400
00003500
00003600
00003700
00003800
00003900
00004000
00004100
00004200
00004300
00004400
00004500
00004600
00004700
00004800
00004900
00005000
0000510-0
c
c.
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
point of each vector or matrix
*
*
integer ptheta, pdesig, pxpect, pobs, pderi1, pderi2, pcurv,
pstdrs, pdet, pdet2, prinv, pbmat, pstder,
pwork1, pwork2, pwork3, piwork, pwork5
parameter vector
ptheta
design matrix
pdesig
expected response
pxpect
observation vector
pobs
derivative matrix (1st + 2nd with symmetric storage)
pderi1
second derivative array
pderi2
marginal curvatures
pcurv
standardized residuals
pstdrs
pdet : index vector of parameters (for design criterion)
prinv & pbmat : for global curvatures
standard errors of the parameter estimates
pstder
infile - 7
outfil - 6
100 continue
title page & initialization
read(infile,'(80A1)',end-999) (ktitle(i), i-1, ~O)
if (ktitle(l) .eq. 'E' .and. ktitle(2) .eq. 'N' .and.
*
ktitle(3) .eq. '0' ) stop
call pghead(outfil, ktitle)
call jsinit
c
c
Read no. of parameters & option for estimation
c
c
c
Read parameter values
c
read(infile,*) npar, needes
if (needes .eq. 0) read(infile,*) ssqrs
ptheta - jdaloc~npar)
nspar • npar*(npar+1) / 2
ntotal - nspar + npar
if (jserr .ne. 0) then
write(outfil,*) 'Problem allocating scrtch. Abort l'
stop
endif
read(infile,*) (ds(ptheta+i), i-O, npar-1)
read(infile,*) nind, nobs, yopt
if (needes .eq. 1 .and. yopt .ne. 1) then
write(outfil,*) 'Need y-values for estimation. Abort'
stop
endif
00005200
00005300
00005400
00005500
00005600
00005700
00005800
00005900
00006000
00006100
00006200
00006300
00006400
00006500
00006600
00006700
00006800
00006900
00007000
00007100
00007200
00007300
00007400
00007500
00007600
00007700
00007800
00007900
00008000
00008100
00008200
00008300
00008400
00008500
00008600
00008700
00008800
00008900
00009000
00009100
00009200
00009300
00009400
00009500
00009600
00009700
00009800
00009900
00010000
00010100
00010200
00010300
0001040-0
(
Points of working storages
C
pdesig - jda1oc(nobs*nind)
pxpect - jda1oc(nobs)
pderi1 • jda1oc(nobs*ntota1)
pderi2 - jda1oc(nobs*npar*npar)
pstdrs - jda1oc(nobs)
prinv - jda1oc(npar*npar)
pbmat - jda1oc(npar*npar)
pstder - jda1oc(npar)
pwork1 - jda1oc(2*npar)
pwork2 - jda1oc(nobs)
pwork3 - jda1oc(ntota1*ntota1)
piwork - jia1oc(ntota1)
pwork5 - jda1oc(npar*npar*npar)
if (j se r r • ne. 0) then
write(outfi1,*) 'Problem allocating scrtch. Abort 2'
stop
endif
call stocom (npar, nobs, nind)
C
C
C
read & write input data
write(outfi1,'(1x,A,/)') 'Input Data: X"s and Y'
if (yopt .eq. 0) then
do. 150 i - 0, nobs-1
read(infi1e,*) (ds(pdesig+i+j*nobs), j-O, nind-1)
write(outfi1,15) (ds(pdesig+i+j*nobs), j-O, nind-1)
... 50
continue
else
pobs - jda1oc(nobs)
do 200 i - 0, nobs-1
read(infi1e,*) (ds(pdesig+i+j*nobs); j-O, nind-1),
*
ds(pobs+i)
write(outfi1,15)
*
(ds(pdesig+i+j*nobs), j-O, nind-1), ds(pobs+i)
200
continue
endif
C
C
parameter estimation
C
if (needes .eq. 0) then
write(outfi1,10) 'OParameter estimation not required.
*
'Current parameter values are'
write(outfi1,25) (i, i - 1, npar)
write(outfi1,15) (ds(ptheta+i), i-0,npar-1)
write(outfi1,20) 'OCurrent variance estimate' " ssqrs
else
write(outfi1,10) 'OParameter estimation required.
*
'Initial parameter values are'
write(outfil,25) (i, i = 1, npar)
write(outfil,15) (ds(ptheta+i), i-0,npar-1)
00010500
00010600
00010700
00010800
00010900
00011000
00011100
00011200
00011300
00011400
00011500
00011600
00011700
00011800
00011900
00012000
00012100
00012200
00012300
00012400
00012500
00012600
00012700
00012800
00012900
00013000
00013100
00013200
00013300
00013400
00013500
00013600
00013700
00013800
00013900
00014000
00014100
00014200
00014300
00014400
00014500
00014600
00014700
00014800
00014900
00015000
00015100
00015200
00015300
00015400
00015500
00015600
call cnvrge (nobs, npar, nind, ds(ptheta), ds(pdesig), nobs,
ds(pobs), ds(pxpect), ds(pstdrs), ds(pderi1),
nobs, d~(pworkl), ds(pwork2), ssqrs, crit, iter,
info)
if (info .ne. 0) then
write(outfil,*) 'CONVERGENCE ERROR: CODE " info
stop
else
call corcom (ds(pderil), nobs, npar, nobs, ssqrs,
*
ds(pstder), info)
if (info .ne. 0) then
write(outfil,*) 'CORCOM ERROR. CODE: " info
stop
endif
call rstwr1(ds(ptheta), npar, ds(pderi1), nobs, nobs,
*
ssqrs, ds(pstder))
endif
endif
*
*
*
C
C
end of parameter estimation
C
C
Compute global curvature
C
C
c
C
C
compute machine precision 'eps'
eps - .2220D-15
sigma2 - ssqrs
call model(nobs, ds(ptheta), ds(pdesig), nobs, 11, ds(pxpect),
*
, ds(pderi1), nobs, info)
if (info .ne. 0) then
write(outfil,*) 'MODEL ERROR: CODE', info
stop
endif
call rmscur(nobs, npar, ntotal, eps, nobs, npar, npar,
*
ds(pderi1), ds(pxpect), sigma2, ds(pwork3),
*
is(piwork), ds(prinv), ds(pbmat), nnorm, rparam,
*
rintrn, info)
if (info .ne. 0) then
write(outfil,*) 'RMSCUR ERROR. CODE - ' info
stop
endif
Compute marginal curvatures
*
C
call model(nobs, ds(ptheta), ds(pdesig), nobs, 11, ds(pxpect),
ds(pderi1), nobs, info)
if (info .ne. 0) then
write(outfil,*) 'MODEL ERROR: CODE', info
stop
endif
00015700
00015800
00015900
00016000
00016100
00016200
00016300
00016400
00016500
00016600
00016700
00016800
00016900
00017000
00017100
00017200
00017300
00017400
00017500
00017600
00017700
00017800
00017900
00018000
00018100
00018200
00018300
00018400
00018500
00018600
00018700
00018800
00018900
00019000
00019100
00019200
00019300
00019400
00019500
00019600
00019700
00019800
00019900
00020000
00020100
00020200
00020300'
00020400
00020500
00020600
pcurv - jdaloc(npar)
call expand(nspar, npar, ds(pderil+nobs*npar), nobs, ds(pderi2),
*
nobs, nobs, info)
if (info .ne. 0) then
write(outfil,*) 'EXPAND ERROR: CODE', info
stop
endif
C
*
call marcur(npar, nobs, ds(pderil), nobs, ds(pderi2), nobs,
ds(pcurv), ssqrs, info)
if (info .ne. 0) then
write(outfil,*) 'MARCUR ERROR. CODE: ',info
stop
endif
C
*
call rstwr2(outfil, nobs, npar, rintrn, rparam, ds(pcurv),
ds(ptheta), ds(pstder»
C
C
C
Evaluate marginal curvatures of the transformed parameters, if
requested
C
read(infile,*) itrans
if (itrans .ne. 0) then
call model(nobs, ds(ptheta), ds(pdesig), nobs, 1,
*
ds(pxpect), ds(pderi1), nobs, info)
call matran(npar, ds(ptheta), ds(pderi1), nobs, ds(pderi2),
*
nobs, ds(pcurv),ds(pwork1), ntrans, ds(pstder),
*
ds(pwork3), ntotal, ds(pwork5), ssqrs, info)
if (info .ne. 0) then
write(outfil,*) 'MATRAN ERROR. CODE: " info
stop
endif
call rstwr3(outfil, nobs, npar, ntrans, ds(pwork1),
*
ds(pcurv), ds(pstder»
endif
C
C
C
Evaluate D-optimal design criterion
(FDET & SDET)
C
*
C
call model(nobs, ds(ptheta), ds(pdesig), nobs, 1, ds(pxpect),
ds(pderi1), nobs, info)
save derivatives
call dcopy (nobs*npar, ds(pderi1), 1, ds(pderi2), 1)
pdet - jialoc(npar)
pdet2 - jialoc(npar)
C
read(infile,*) nsdet
if (nsdet .le. 0) then
write(outfil,*) 'No evaluation of SDET required'
else
00020700
00020800
00020900
00021000
00021100
00021200
00021300
00021400
00021500
00021600
00021700
00021800
00021900
00022000
00022100
00022200
00022300
00022400
.00022500
00022600
00022700
00022800
00022900
00023000
00023100
00023200
00023300
00023400
00023500
00023600
00023700
00023800
00023900
00024000
00024100
00024200
00024300
00024400
00024500
00024600
00024700
00024800
00024900
00025000
00025100
00025200
00025300
00025400
00025500
00025600
write(outfil,'(//lx,A,A)') 'D-optimal design criterion
'evaluated for the subset of parameters whose'
write(outfil,'(30x,A,/)') 'index is l'
do 500 i • 1, nsdet
read(infile,*) (is(pdet+j), j • 0, npar-1)
do 400 j - 0, npar-1
is(pdet2+j) • is(pdet+j)
continue
call dcoP¥ (nobs*npar, ds(pderi2), 1, ds(pderi1), 1)
call detcom (ds(pderi1), nobs, nobs, npar, is(pdet),
ds(pwork1), temp)
write(outfil,20)'x
DET - " temp,'
INDEX(is(pdet2+j), j • 0, npar-1)
continue
*
400
*
*
500
endif
c
c
c
go to 100
999
10
15
20
25
stop
format(A, A, /)
format(lx, 6(lp, g13.5))
format(A, 1p, g13.5, A, (10i3))
format(6x, 6(i2,11x))
end
00025700
00025800
00025900
00026000
00026100
00026200
00026300
00026400
00026500
00026600
00026700
00026800
00026900
00027000
00027100
00027200
00027300
00027400
00027500
00027600
00027700
00027800
00027900
00028000
00028100
subroutine cnvrge(nobs, npar, nvar, theta, design, ldd, rspnse,
resid, stdres,first, ldf, workv, workrs, ssqrs,
crit, iter, ifault)
integer nobs, npar, nvar, ldd, ldf, iter, ifault
double precision theta(npar), design(ldd,nvar), rspnse(nobs),
*
resid(nobs), stdres(nobs), first(ldf,npar*(npar+1)/2),
*
ssqrs, workv(l), workrs(nobs), crit
*
*
C
C
C
purpose:
calculates the parameter estimates in a nonlinear regression
model using a gauss-newton algorithm with halving of the
step size when the sum of squares is not reduced and with
a relative offset convergence criterion (Bates, Douglas M.
and Watts, Donald G. (1981) A Relative Offset Orthogonality
Convergence Criterion for Nonlinear Least Squares,
Technometrics, 23 (2), 179-184). The standardized residuals
are also calculated.
C
C
parameters:
C
C
C
C
C
C
C
C
C
C
on entry:
C
C
C
C
C
C
C
C
C
nobs
npar
nvar
theta
design
ldd
integer
integer
integer
real(npar)
real(ldd,nvar)
integer
rspnse
real(nobs)
number of observations
number of parameters
number of variables
initial parameter estimates
design matrix
leading dimension of design
as declared in calling program
response vector
C
C
on exit:
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
theta
resid
stdres
real(npar)
real(nobs)
real(nobs)
final parameter estimates
residual vector at estimates
standardized residuals (using
the standardization with the
"hat" matrix)
real(ldf,npar)
information on the qr
first
decomposition of the first
derivative matrix at the
estimates as returned from sqrdc
ssqrs
real
sum of squares at the estimates
crit
relative offset at the estimates
real
number of iterations to converge
iter
integer
error indicator - 0 indicates
integer
ifault
successful convergence
error indications
meaning
code
1
number of iterations exceeded maximum
failure to reduce sum of squares after
2
step factor was cut to the minimum.
(probably caused by incorrectly coded
derivatives)
00000100
00000200
00000300
00000400
00000500
00000600
00000700
00000800
00000900
00001000
00001100
00001200
00001300
00001400
00001500
00001600
00001700
00001800
00001900
00002000
00002100
00002200
00002300
00002400
00002500
00002600
00002700
00002800
00002900
00003000
00003100
00003200
00003300
00003400
00003500
00003600
00003700
00003800
00003900
00004000
00004100
00004200
00004300
00004400
00004500
00004600
00004700
00004800
00004900
00005000
00005100
00005200
000053000
00005400
00005500
3
C
l
4
C
C
singular derivative matrix at current
parameter values
derivative matrix could not be
calculated at current parameter values
C
working storage:
C
C
workv
workrs
C
C
C
C
C
C
real(2~npar)
real(nobs)
common blocks
setngs
tol
real
C
C
mxiter
integer
fctrmn
real
dlarge
real
nfixed
integer
pfixed
integer(nfixed)
C
C
C
C
C
C
C
C
C
tolerance level for relative
offset (0.001 recommended)
maximum number of iterations
allowed (50 recommended)
minimum value of step length
factor (2**-10 recommended)
a large double precision
number (10**30 or whatever)
number of parameters held
fixed
indices of fixed parameters
C
C Made modifications for fixing a single parameter.
C Also provided a verbose.optionn with interation output
C
C
C
C
hanged the method of calculation of the standardized residuals
use the Linpack calculation of the residual from the canonical
basis vectors.
~o
C
C
C
C
written by Doug Bates, Univ. of Wisconsin
(COMMON blocks modified by G. Kang since INCLUDE command
does not work in IBM Fortran compiler.)
C
double precision tol,fctrmn,dlarge
integer mxiter, nfixed, pfixed, iverbo
parameter (tol-0.001, fctrmn-0.0005dO,
dlarge-1.0d30)
parameter (mxiter-50, nfixed-O, pfixed-1, iverbo-O)
C
integer i,j,idum(1),npp1,npmfp1,nres,info
double precision dummy(l,l),nwssqs,tolsqr,factor,varnce,temp
double precision ddot
C
C
C
C
C
C
C
C
workv should. be dimensioned at least 2*npar.
the increment is stored in the first npar locations
and the trial paramete~ vector in the last npar
locations
establish constants
00005600
00005700
00005800
00005900
00006000
00006100
00006200
00006300
00006400
00006500
00006600
00006700
00006800
00006900
00007000
00007100
00007200
00007300
00007400
00007500
00007600
00.007700
00007800
00007900
00008000
00008100
00008200
00008300
00008400
00008500
00008600
00008700
00008800
00008900
00009000
00009100
00009200
00009300
00009400
00009500
00009600
00009700
00009800
00009900
00010000
00010100
00010200
00010300
00010400
00010500
00010600
00010TOO
c
c
c
c
c
c
c
c
c
c
c
c
npp1 npmfp1
nres tolsqr
initialize output variables, set increment to zero,
set the sum of squares to a 'large' number and the
step length factor to one.
crit - O.OdO
iter - 0
ssqrs = dlarge
factor - 1.0dO
do 100 i - 1, npar
workv(i) - O.OdO
100 continue
ifault = 0
main. iteration loop
200 continue
iter - iter+1
if(iter .gt. mxiter ) then
ifault - 1
return
endif
300
continue
350
*
400
c
c
npar+1
- npar - nfixed + 1
nobs - (npar - nfixed)
- tol**2
if (factor .It. fctrmn) then
ifault - 2
return
endif
do 350 i • 1, npar
j - npar+i
workv(j) - theta(i)+factor*workv(i)
continue
call model(nobs, workv(npp1), design, ldd, 0, resid, first,
ldf, info)
factor = factor/2.0dO
if (info .ne. 0)
go to 300
do 400 i • 1, nobs
resid(i) - rspnse(i)-resid(i)
continue
nwssqs - ddot(nobs,resid,l,resid,l)
if (nwssqs .ge. ssqrs) go to 300
00010800
00010900
00011000
00011100
00011200
00011300
00011400
00011500
00011600
00011700
00011800
00011900
00012000
00012100
00012200
00012300
00012400
00012500
00012600
00012700
00012800
00012900
00013000
00013100
00013200
00013300
00013400
00013500
00013600
00013700
. 00013800
_ 00013900
00014000
00014100
00014200
00014300
00014400
00014500
00014600
00014700
00014800
00014900
00015000
00015100
00015200
00015300
00015400
00015500
00015600
00015700
ssqrs - nwssqs
00015800
factor - dmin1(4.0dO*factor,1.0dO)
00015900
call dcopy(npar,workv(npp1),1,theta,1)
00016000
call model(nobs, theta, design, ldd, 1, resid, first,
00016100
*
ldf, info)
00016200
if (info .ne. 0) then
00016300
ifault - 4
00016400
return
00016500
endif
00016600
do 450 i - I , nobs
00016700
resid(i) - rspnse(i)-resid(i)
00016800
450
continue
00016900
call dcopy(nobs,resid,1,workrs,1)
00017000
if (nfixed .ne. 0 .and. pfixed .ne. npar) then
00017100
call dswap(nobs, first(1,pfixed), 1, first(1,npar), 1)
00017200
endif
00017300
call dqrdc(first,ldf,nobs,npar-nfixed,workv(npp1),idum,workv,0)00017400
call dqrsl(first,ldf,nobs,npar-nfixed,workv(npp1),workrs,dummy,00017500
*
workrs,workv,dummy,dummy,01100,info)
00017600
if (info .ne. 0) then
00017700
ifault - 3
00017800
return
00017900
endif
00018000
if (nfixed .ne. 0 .and. pfixed .ne. npar) then
00018100
workv(npar) - workv(pfixed)
00018200
. workv(pfixed) - O.OdO
00018300
endif
00018400
crit - nres*ddot(npar-nfixed,workrs,1,workrs,1)/((npar-nfixed)*00018500
*
ddot(nres,workrs(npmfp1),I,workrs(npmfp1),1))
00018600
if (iverbo .ne. 0) then
00018700
write(6,'(1p,2g13.5,2x,(5g11.3))') ssqrs, crit,
00018800
*
(theta(i), i • 1, npar)
00018900
endif
00019000
if (crit .gt. tolsqr) go to 200
00019100
C
00019200
C
00019300
C
00019400
crit = sqrt(crit)
00019500
varnce - ssqrs/nres
00019600
do 500 i - 1, nobs
00019700
call dcopy(nobs,0.OdO,0,workrs,1)
00019800
workrs(i) - 1.0dO
00019900
call dqrsl(first,ldf,nobs,npar-nfixed,workv(npp1),workrs,dummy,00020000
*
workrs,dummy,workrs,dummy,00010,info)
00020100
stdres(i) - resid(i)/sqrt(workrs(i)*varnce)
00020200
500 continue
00020300
return
00020400
end
00020500
SUBROUTINE CORCOM(R, LDR, NPAR, NOBS, RSS, STDERR, JERROR)
INTEGER LDR, NPAR, NOBS, JERROR
DOUBLE PRECISION R(LDR, NPAR), RSS, STDERR(NPAR)
C
C
C
C
PURPOSE: TO CALCULATE OUT THE CORRELATION MATRIX AND
PARAMETER STANDARD ERRORS
C
C
C
C
C
C
ON ENTRY:
C
ON EXIT:
R
NOBS
NPAR
RSS
C
C
R
C
STDERR
RSS
JERROR
C
C
C
TRIANGULAR FACTOR OF DERIVATIVE MATRIX
NUMBER OF OBSERVATIONS
NUMBER OF PARAMETERS
RESIDUAL SUM OF SQUARES
THE UPPER TRIANGLE IS OVERWRITTEN WITH R-INVERSE.
THE STRICT LOWER TRIANGLE CONTAINS CORRELATIONS
PARAMETER STANDARD ERRORS
VARIANCE ESTIMATE
ERROR INDICATOR. 0 FOR SUCCESSFUL COMPLETION
1 R IS EXACTLY SINGULAR
C
C
GUNSEOG KANG (NOV,1988), DEPT. OF STATISTICS, NCSU
C
C
C
DOUBLK PRECISION DOF, DUMMY, TEMP
DOUBLE PRECISION"DDOT," DNRM2
INTEGER I, J, NLEN
$PROFILE
IF (NOBS .LE. NPAR) THEN
RSS - 0.000
ELSE
DOF - DBLE(NOBS - NPAR)
RSS = RSS / DOF
END IF
CALL DTRDI(R, LOR, NPAR, DUMMY, 011, JERROR)
IF (JERROR .NE. 0) THEN
JERROR - 1
RETURN
END IF
DO 110 I - 1, NPAR
NLEN - NPAR + 1 - I
TEMP - DNRM2(NLEN, R(I,I), LOR)
CALL DSCAL(NLEN, 1.0DO/TEMP, R(I,I), LOR)
STDERR(I) - TEMP * SQRT(RSS)
DO 100 J - 1, I-1
R(I,J) - DDOT(NLEN, R(I,I), LOR, R(J,I), LOR)
100
CONTINUE
110 CONTINUE
RETURN
END
00000100
00000200
00000300
00000400
00000500
00000600
00000700
00000800
00000900
00001000
00001100
00001200
00001300
00001400
00001500
00001600
00001700
00001800
00001900
00002000
00002100
00002200
00002300
00002400
00002500
0000"2600
00002700
00002800
00002900
00003000
00003100
00003200
00003300
00003400
00003500
00003600
00003700
00003800
00003900
00004000
0'0004100
00004200
00004300
00004400
00004500
00004600
00004700
00004800
00004900
00005000
c
c
c
c
c
c
c
c
subroutine detcom (deriv, ldd, nrow, ncol, index, work, det)
integer ldd, nrow, ncol, index(ncol)
double precision deriv(ldd,ncol), work(l), det
Purpose: Evaluate the determinant criterion for the optimal design.
Can be used for both the full and subset design.
Input:
deriv
ldd
nrow
ncol
index
C
C
C
C
C
C
C
C
C
C
C
C
C
c
c
c
c
c
work
Output:
det
derivative matrix
leading dimension of 'deriv'
usually no. of observations
no. columns of 'deriv'
contains a nonzero value for each parameter which
are envolved in the evaluation. (e.g., For the full
design, every element should be nonzero.)
a working storage (ncol x 1)
value of the D-optimal design criterion
( sqrt ( v-transpose V ) )
Gunseog Rang (11/15/88), Dept. of Statistics, NCSU
integer i, nzero, pzero, itemp
double precision dummy
nzero - 0
det - 1.0dO
do 100 i - I , ncol
if (index(i) .eq. 0) nzero - nzero + 1
100 continue
if(nzero .eq. ncol) then
print *, 'All ZERO INDEX'
return
endif
if (nzero .eq. 0) then
call dqrdc (deriv, ldd, nrow, ncol, work, 0, dummy, 0)
do 200 i - I , nco I
det - det * deriv(i,i)
200
continue
det - abs(det)
return
else
do 300 i - I , ncol-1
if (index(i) .ne. 0) then
call fzero (ncol-i, index(i+1), pzero)·
if (pzero .eq. 0) then
go to 400
else
00000100
00000200
00000300
00000400
00000500
00000600
00000700
00000800
00000900
00001000'
00001100
00001200
00001300
00001400
00001500
00001600
00001700
00001800
00001900
00002000
00002100
00002200
00002300
00.002400
00002500
00002600
00002700
00002800
00002900
00003000
00003100
00003200
00003300
00003400
00003500
00003600
00003700
00003800
00003900
00004000
00004100
00004200
00004300
00004400
00004500
00004600
00004700
00004800
00004900
00005000
00005100
00005200
00005300
00005400
call dswap(nrow, deriv(1,i),1, deriv(1,i+pzero),1) 00005500
itemp • index(i)
00005600
00005700
index(i) • index(i+pzero)
00005800
index(i+pzero) - itemp
00005900
endif
00006000
endif
00006100
300
continue
00006200
c
00006300
400
continue
00006400
c
00006500
call dqrdc(deriv, ldd, nrow, ncol, work, 0, dummy, 0)
00006600
do 500 i • nzero+1, ncol
00006700
det • det * deriv(i,i)
00006800
500
continue
00006900
det • abs(det)
00007000
c
00007100
endif
00007200
c
00007300
return
00007400
end
subroutine expand (ntcol, ncol, a, Ida, b, ldb, nrow, info)
integer ntcol, ncol, Ida, ldb, nrow, info
double precision a(lda,ntcol), b(ldb,ncol,ncol)
C
C
C
C
C
C
C
C
C
C
Purpose: Convert the matrix 'a' having a symmetric storage form
into the regular array 'b'
Input:
input matrix, Ida x ntcol, where
a
ntcol - ncol*(ncol+1)/2
Output:
b : output array, ldb x nco I x ncol
Gunseog Kang,
(Nov,1988). Dept. of Statistics,
NCSU
C
C
integer i, j, k, itemp
C
info - 0
itemp - ncol * (ncol+1) / 2
if (itemp .. ne. ntcol) then
info - 1
return
endif
C
k -
0
do 200 j - 1, ncol
do 100 i - 1, j
k - k + 1
call dcopy(nrow, a(l,k), 1, b(l,i,j), 1)
call dcopy(nrow, b(l,i,j), 1, b(l,j,i), 1)
100
continue
200 continue
return
end
00000100
00000200
00000300
00000400
00000500
00000600
00000700
00000800
00000900
00001000
00001100
00001200
00001300
00001400
00001500
00001600
00001700
00001800
00001900
00002000
00002100
00002200
00002300
00002400
00002500
00002600
00002700
00002800
00002900
00003000
00003100
00003200
00003300
00003400
subroutine fzero (n, ivec, pzero)
integer n, pzero, ivec(n)
C
C
C
C
Purpose: Find the first zero element of the vector 'ivec' and
return its index 'pzero'.
This is used only in subroutine DETCOM.
C
C
Gunseog Kang (11/15/88), NCSU, Dept. of Statistics
C
integer i
C
pzero - 0
do 100 i - I , n
if (ivec(i) .eq. 0) then
pzero - i
return
endif
100 continue
return
end
00000100
00000200
00000300
00000400
00000500
00000600
00000700
00000800
00000900
00001000
00001100
00001200
00001300
00001400
00001500
00001600
00001700
00001800
00001900
00002000
integer function jdaloc(need)
integer need
C
C
C
C
C
Purpose:
Allocate a block of size NEED double precision scratch
storage locations and returns the pointer to them.
The value returned is the index of the first location
in the block within the OS array
C
INTEGER MAXRSC, MAXDSC, MAXISC
PARAMETER (MAXRSC-8192, MAXDSC-MAXRSC/2, MAXISC-MAXRSC)
DOUBLE PRECISION DS(MAXDSC)
REAL RS(MAXRSC)
INTEGER IS(MAXISC), RSPTR, ISPTR, JSERR
EQUIVALENCE (RS(l),DS(l),IS(l»
COMMON /JSCRAT/ IS, RSPTR, ISPTR, JSERR
INTEGER JIALOC, JRALOC
C
C
if ( mod(rsptr,2) .ne. 0) rsptr - rsptr + 1
if (need .It. 0 .or. rsptr+2*need .gt. isptr) then
jserr - 1
jdaloc - 0
return
endif
jdaloc - rsptr/2
rsptr - rsptr + 2*need
return
end
00000100
0'0000200
00000300
00000400
00000500
00000600
00000700
00000800
00000900
00001000
00001100
00001200
00001300
00001400
00001500
00001600
00001700
00001800
00001900
00002000
00002100
00002200
00002300
00002400
00002500 .
00002600
00002700
00002800
integer function jialoc(need)
integer need
C
C
C
'C
C
Purpose:
Allocate a block of size NEED integer scratch
storage locations and returns the pointer to them.
The value returned is the index of the first location
in the block within the IS array
C
INTEGER MAXRSC, MAXDSC, MAXISC
PARAMETER (MAXRSC-8192, MAXDSC-MAXRSC/2, MAXISC-MAXRSC)
DOUBLE PRECISION DS(MAXDSC)
REAL RS(MAXRSC)
INTEGER IS(MAXISC), RSPTR, ISPTR, JSERR
EQUIVALENCE (RS(l),DS(l),IS(l))
COMMON /JSCRAT/ IS, RSPTR, ISPTR, JSERR
INTEGER JDALOC, JRALOC
C
C
if (need .It. 0 .or. isptr-need .It. rsptr
jserr - 1
jialoc - 0
return
endif
isptr - isptr - need
jialoc - isptr
return'
end
) then
00000100
00000200
00000300
00000400
00000500
00000600
00000700
00000800
00000900
00001000
00001100
00001200
00001300
00001400
00001500
00001600
00001700
00001800
00001900
00002000
00002100
00002200
00002300
00002400
00002500
00002600
00002700
subroutine jsinit
C
C
C
Purpose:
Initialize scratch storage variables.
the beginning of a program
Called once at
C
INTEGER MAXRSC, MAXDSC, MAXISC
PARAMETER (MAXRSC-8192, MAXDSC-MAXRSC/2, MAXISC-MAXRSC)
DOUBLE PRECISION DS(MAXDSC)
REAL RS(MAXRSC)
INTEGER IS(MAXISC), RSPTR, ISPTR, JSERR
EQUIVALENCE (RS(l),DS(l),IS(l))
COMMON /JSCRAT/ IS, RSPTR, ISPTR, JSERR
INTEGER JDALOC, JIALOC, JRALOC
C
rsptr - 1
isptr - maxisc + 1
jserr - 0
return
end
00000100
00000200
00000300
00000400
00000500
00000600
00000700
00000800
00000900
00001000
00001100
00001200
00001300
00001400
00001500
00001600
00001700
00001800
00001900
subroutine marcur (npar, nobs, deriv1, Id1, deriv2, Id2,
curv, sigma2, info)
integer npar, nobs, Id1, Id2, info
double precision deriv1(ld1,npar), deriv2(ld2, npar, npar),
*
curv(npar), sigma2
00000100
00000200
00000300
00000400
00000500
00000600
00000700
Evaluate P. Clarke's marginal curvatures for parameters in
a nonlinear model (JASA, 1987, pp.844-850)
00000800
The computing algorithm developed by Kang and Rawlings
00000900
(1989) is used.
00001000
00001100
00001200
Input; npar
No. of parameter
nobs
00001300
No. of observations
00001400
deriv1
first-order derivative matrix
deriv2
second-order derivative array
00001500
Id1
leading dimension of deriv1
00001600
leading dimension of deriv2
Id2
00001700
sigma.2
variance estimate
00001800
00001900
Output; curv
vector of marginal curvatures (also serves
00002000
00002100
as a working storage until 300)
deriv2
contains GAMMA matrix (npar x npar x npar)
00002200
which can be used when computing the marginal
00002300
curvature of the transformed parameters
00002400
00002500
Gunseog Kang (11/15/1988), Dept. of Statistics, NCSU
00002600
00002700
00002800
integer i, j, k
00002900
double precision dnrm2, dummy
00003000
00003100
info - 0
00003200
QR of the derivative matrix
00003300
call dqrdc (deriv1, Id1, nobs, npar, curv, 0, dummy, 0)
00003400
00003500
multiply the 'columns' of deriv2 by Q-transpose & R1-inverse
00003600
00003700
00003800
do 150 j - 1, npar
do 100 k ~ 1, npar
00003900
call dqrsl (deriv1, Id1, nobs, npar, curv, deriv2(1,j,k),
00004000
*
dummy, deriv2(1,j,k), dummy, dummy, dummy, 1000, info) 00004100
call dtrsl (deriv1, Id1, npar, deriv2(1,j,k), 1, info)
00004200
100
continue
00004300
150 continue
00004400
00004500
*
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C'
C
C
C
C
C
C
C
~
~ultiply
the 'columns' of deriv2 by R1-inverse
C
C
do 300 i • 1, npar
do 200 k - 1, npar
call dcopy (npar, deriv2(i,1,k), Id2, curv, 1)
call dtrsl (deriv1, Id1, npar, curv, 11, info)
call dtrsl (deriv1, Id1, npar, curv, 1, info)
call dcopy (npar, curv, 1, deriv2(i,1,k), Id2)
200
continue
C
do 250 j - 1,
call dcopy
call dtrsl
call dtrsl
call dcopy
250
continue
300 continue
npar
(npar, deriv2(i,j,1), Id2*npar, curv, 1)
(deriv1, Id1, npar, curv, 11, info)
(deriv1, Id1, npar, curv, 1, info)
(npar, curv, 1, deriv2(i,j,1), Id2*npar)
C
C
Compute the marginal curvatures
C
C
R1-inverse
call dtrdi (deriv1, Id1, npar, dummy, 11, info)
do 350 i - I , npar
curv(i) - dnrm2(npar-i+1, deriv1(i,i), Id1) ** 2
curv(i) - deriv2(i,i,i) / (curv(i)**1.5)
curv(i) - - curv(i) * 0.50dO * sqrt(sigma2)
50 continue
return
end
00004600
00004700
00004800
00004900
00005000
00005100
00005200
00005300
00005400
00005500
00005600
00005700
00005800
00005900
00006000
00006100
00006200
00006300
00006400
00006500
00006600
00006700
00006800
00006900
00007000
00007100
00007200
00007300
00007400
00007500
subroutine matran (npar, theta, deriv1, Id1, gamma, ldg, curv,
trans, ntrans, stderr, tderiv, ntotal, work, sigma2,
info)
integer npar, Id1, ldg, ntrans, ntotal, info
double precision theta(npar), deriv1(ld1,npar), stderr(npar),
*
gamma(ldg,npar,npar), curv(npar), trans(npar),
*
tderiv(npar,ntotal), work(npar,npar,npar), sigma2
*
*
C
C
purpose
C
Compute marginal curvatures and standard errors of the
transformed parameters (Kang and Rawlings, 1989).
C
C
C
C
C
Input :
npar
theta
deriv1
C
C
gamma
C
C
sigma2
no. of the original parameters
current values of the original parameters
1st derivative matrix of the model funtion w.r.t.
the original parameters
GAMMA matrix used for the marginal curvature of the
original parameters. '(output of MARCUR)
variance estimate
C
C
C
C
C
C
C
C
C
C
C
C
Output :
ntrans
trans
no. of the transformed parameters
values of the transformed evaluated at the current
values of the original parameters
curv
marginal curvature of the transformed parameters
gamma ": GAMMA matrix for the transformed parameters
stderr
standard errors of the transformed parameters
Gunseog Kang (12/17/88), Dept. of Statistics, NCSU
C
integer nspar, i, j, k
double precision dnrm2, temp, dummy
C
C
info - 0
nspar - npar*(npar+1)/2
if(ntotal .ne. nspar+npar) then
info • 1
return
endif
C
C
Compute 1st & 2nd derivatives of the transformation
C
call transf(npar, theta, ntrans, trans, tderiv, info)
if (info .ne. 0) then
print *, 'TRANSF ERROR. CODE: " info
info = 2
return
endif
C
00000100
00000200
00000300
00000400
00000500
00000600
00000700
00000800
00000900
00001000
00001100
00001200
00001300
00001400
00001500
00001600
00001700
00001800
0000i900
00002000
00002100
00002200
00002300
00002400
00002500
00002600
00002700
00002800
00002900
00003000
00003100
00003200
00003300
00003400
00003500
00003600
00003700
00003800
00003900
00004000
00004100
00004200
00004300
00004400
000045"00
00004600
00004700
00004800
00004900
00005000
000051"00
00005200
C
r
C
C
C
C
C
C
(
C
C
C
C
C
C
C
C
C
C
C
C
C
Al - [H) [ GAMMA]
0000 5300
00005400
do 30 i - I , npar
00005500
do 20 j - 1, npar
00005600
do 10 k - 1, npar
00005700
work(i,j,k) - ddot(npar, tderiv(i,l), npar, gamma(l,j,k),l)
00005800
10
continue
00005900
20 continue
00006000
30 continue
00006100
00006200
A2 - H * Al
00006300
00006400
do 60 i - I , npar
00006500
do' 50 j - 1, npar
00006600
do 40 k - 1, npar
00006700
gamma(i,j,k) - ddot(npar, tderiv(j,l), npar, work(i,l,k), npar)00006800
40
continue
00006900
50 continue
00007000
60 continue
00007100
00007200
A3 - A2 * H-trans
00007300
00007400
do 90 i - I , npar
00007500
do 80 j - 1, npar
00007600
do 70 k - 1, npar
00007700
work(i,j,k) - ddot(npar,gamma(i,j,1),ldg*npar,tderiv(k,1),npar)00007800
70
continue
00007900
80 continue
00008000
90 continue
00008100
00008200
GAMMA1 - H*[H][GAMMA]*H-trans
00008300
00008400
,
do 100 i - I , npar
00008500
call dcopy(npar*npar, work(i,l,l), npar, gamma(i,l,l), ldg)
00008600
100 continue
00008700
00008800
Construction of H..
00008900
00009000
call expand(nspar,npar,tderiv(1,npar+1),npar,work,npar,npar,info) 00009100
00009200
OR-decomposition of the derivative matrix
00009300
00009400
call dqrdc(deriv1, Id1, Id1, npar, curv, 0, dummy, 0)
00009500
00009600
K - H * G - H * R-inv * R-inv&trans
00009700
Save H * R-inv into tderiv[,(npar+1):npar] for later use
00009800
00009900
do 110 i - I , npar
00010000
call dcopy(npar, tderiv(i,l), npar, curv, 1)
00010100
call dtrsl(deriv1, Id1, npar, curv, 11, info)
00010200
call dcopy(npar, curv, 1, tderiv(i,npar+1), npar)
00010300
call dtrsl(deriv1, Id1, npar, curv, 1, info)
00010400
call dcopy(npar, curv, 1, tderiv(i,1), npar)
00010S00
110 continue
00010600
00010700
C
t
C
C
C
C
C
C
C
C
C
C
C
C
C
GAMMA2 - K * H.. * K-trans
00010800
00010900
Q - K * H..
00011000
00011100
do 150 i - I , npar
00011200
do 130 j - 1, npar
00011300
do 120 k - 1, npar
00011400
deriv1(j,k) - ddot(npar,tderiv(j,l),npar,work(i,l,k),npar) 00011500
120
continue
00011600
130
continue
00011700
do 140 j - 1, npar
00011800
call dcopy(npar, deriv1(1,j), 1, work(i,l,j), npar)
00011900
140
continue
00012000
150 continue
00012100
00012200
GAMMA2 - Q * K-trans
00012300
00012400
do 190 i - I , npar
00012500
do 170 j - 1, npar
00012600
do 160 k -1, npar
00012700
deriv1(j,k) - ddot(npar,work(i,j,1),npar*npar,tderiv(k,1),npar)00012800
160
continue
00012900
170 continue
00013000
do 180 j - 1, npar
00013100
call dcopy(npar, deriv1(1,j), 1, work(i,l,j), npar)
00013200
180 continue
00013300
190 continue
00013400
00013500
3AMMA - GAMMA1 - GAMMA2
00013600
00013700
do 220 i - 1, npar
00013800
do 210 j - 1, npar
00013900
do 200 k - 1, npar
00014000
gamma(i,j,k) - gamma(i,j,k) - work(i,j,k)
00014100
200
continue
00014200
210
continue
00014300
220 continue
00014400
00014500
Compute marginal curvature
00014600
00014700
do 230 i - 1, ntrans
00014800
temp - dnrm2(npar, tderiv(i,npar+1), npar)
00014900
stderr(i) = temp * sqrt(sigma2)
00015000
curv(i) - gamma(i,i,i)/(temp**3)
00015100
curv(i) - - curv(i) * 0.50dO * sqrt(sigma2)
00015200
230 continue
00015300
00015400
00015500
return
00015600
end
00015700
c
C
subroutine pghead(iunit, ktitle)
integer iunit
character*l ktitle(80)
Purpose: Write out page header
C
integer i
write(iunit,'(A,71A1//)') 'lTitle:'
return
end
(ktitle(i), i-1, 71) .
00000100
00000200
00000300
00000400
00000500
00000600
00000700
00000800
00000900
00001000
C
C
c
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
subroutine rmscur(nobs,npar,ntotal,eps,ldder,ldrinv,ldbmat,derivs,00000100
*resid, rhores,wrkmat,iwrkv,rinv,bmat,nnorm,rparam,rintrn,ifauIt) 00000200
dimension derivs(ldder,ntotal),resid(nobs),rinv(ldrinv,npar),
00000300
*bmat(ldbmat,npar),wrkmat(ntotal,ntotal),iwrkv(ntotal)
00000400
integer nobs,npar,ntotal,ldder,ldrinv,ldbmat,iwrkv,nnorm,ifault
00000500
double precision eps,derivs,resid,rhores,rinv,bmat,wrkmat,rparam, 00000600
*rintrn
00000700
00000800
purpose - to calculate the intrinsic and parameter-effects
00000900
curvature arrays from first and second
00001000
derivative information in a nonlinear regression
00001100
model·
00001200
00001300
parameters
00001400
00001500
on entry:
00001600
00001700
nobs
- integer
- number of observations
00001800
npar
- integer
- number of parameters
00001900
ntotal - integer
- number of first and second
00002000
derivatives (- p(p+3)/2 )
00002100
eps
- real
- tolerance level for comparisons00002200
to determine nnorm
00002300
ldder - integer
leading dimension of derivs
00002400
as declared in the calling
00002500
program
00002600
ldrinv - integer
- leading dimension of rinv
00002700
ldbmat - integer
- leading dimension of bmat
00002800
derivs - real(ldder,ntotal)- first and second derivatives
00002900
comprise the columns (second
00003000
derivatives in symmetric mode) 00003100
resid - real(nobs)
- residual vector
00003200
rhores - real
- variance estimate
00003300
00003400
on exit:
00003500
00003600
derivs
real(ldder,ntotal)- the (scaled) r-tilde comprises 00003700
the first p columns. a .. (in
00003800
symmetric mode) comprises the 00003900
next p(p+1)/2 columns
00004000
resid - real(nobs)
- q'(residuals)
00004100
rhores - real
- standard radius
00004200
rinv
real(ldrinv,npar) - inverse of the (scaled) r-tilde00004300
bmat
- real(ldbmat,npar) - the b matrix
00004400
nnorm
integer
the apparent number of normal 00004500
acceleration dimensions
00004600
rparam - real
- rms parameter-effects
00004700
curvature
00004800
rintrn - real
- rms intrinsic curvature
00004900
ifault - integer
- error indicator. 0 indicates
00005000
successful completion
00005100
C
C
C
C
c
C
C
C
c
C
C
C
C
c
c
C
C
C
C
C
C
C
C
C
C
C
00005200
00005300
00005400
00005500
00005600
00005700
00005800
00005900
working storage:
00006000
00006100
wrkmat - real(ntotal,ntotal)
00006200
iwrkv - integer(ntotal)
00006300
00006400
written: doug bates, u. of wisconsin
june, 1981
00006500
00006600
integer npp1,npairs,nrows,i,j,k,ii,jj,kk
00006700
double precision accum,rhoinv,diag,temp,rmsfac,ddot
00006800
00006900
check dimensions and positivity of rhores
00007000
00007100
ifault - 1
00007200
if(npar .le. 0) return
00007300
i faul t - 2
00007400
if(nobs .It. npar) return
00007500
ifault· - 3
00007600
if(ntotal .ne. npar*(npar+3)/2) return
00007700
ifault - 4
00007800
if(rhores .le. O.OdO) return
00007900
00008000
scale derivatives and resid, form qr decomposition,
00008100
and multiply resid by q-transpose
00008200
00008300
rhores = sqrt(float(npar)*rhores)
00008400
rhoinv = 1.0dO/rhores
00008500
call dscal(nobs,rhoinv,resid,l)
00008600
do 100 i - 1,ntotal
00008700
call dscal(nobs,rhoinv,derivs(l,i),l)
00008800
iwrkv(i) • 0
00008900
100 continue
00009000
do 200 i - 1,npar
00009100
iwrkv(i) - i
·00009200
200 continue
00009300
call dqrdc(derivs,ldder,nobs,ntotal,wrkmat(l,l),iwrkv,wrkmat(1,2),00009400
*
1)
00009500
call dqrsl(derivs,ldder,nobs,ntotal,wrkmat(1,1),resid,wrkmat(1,2),00009600
*
resid,wrkmat(1,2),wrkmat(1,2),wrkmat(1,2),01000,i)
00009700
00009800
zero trailing entries of columns of derivs,
00009900
calculate rinv, and calculate nnorm
00010000
00010100
code
1
2
3
4
5
error indications
meaning
npar is not positive
npar > nobs
ntotal <> npar(npar+3)/2
rhores is not positive
the first derivatives are singular
c
nrows - maxO(ntotal,nobs)
do 300 i - l,ntotal
j - minO(i+l,nobs+l)
k - nrows+l-j
call dcopy(k,O.OdO,O,derivs(j,i),I)
if (i .le. npar)
*
call dcopy(npar,derivs(l,i),I,rinv(l,i),I)
300 continue
call dtrdi(rinv,ldrinv,npar,wrkmat(I,I),OII,i)
ifault - 5
if(i .ne. 0) return
ifault - 0
nppl - npar+l
nnorm - 0
temp - derivs(nppl,nppl)
if (temp .ne. O.OdO) then
do 400 i - nppl,ntotal
if (eps .le. abs(derivs(i,i)/temp»
nnorm 400
continue
endif
C
C
i - npar
reverse the effect of the pivots on the
columns of derivs
C
do 500 i - nppl,ntotal
call dcopy(ntotal,derivs(l,i),I,wrkmat(l,i),I)
500 continue
do 600 i - nppl,ntotal
j - iwrkv(i)
call dcopy(ntotal,wrkmat(l,i),I,derivs(l,j),I)
600 continue
C
C
C
perform pre- and post multiplications by
I-transpose and 1. temporary results are stored
in wrkmat
C
C
*
npairs • ntotal-npar
k - 1
do 730 i - l,npar
do 720 j - l,i
k - k+l
kk - 0
do 710 ii = l,npar
do 700 jj - l,ii
kk - kk+l
wrkmat(kk,k) -
if (i i . eq . j j )
wrkmat(kk,k)
*
700
710
720
730
C
rinv(ii,i)*rinv(jj,j)+rinv(jj,i)*
rinv(ii,j)
continue
continue
continue
continue
=
wrkmat(kk,k)/2.0dO
00010200
00010300
00010400
00010500
00010600
00010700
00010800
00010900
00011000
00011100
00011200
00011300
00011400
00011500
00011600
00011700
00011800
00011900
00012000
00012100
00012200
00012300
00012400
00012500
00012600
00012700
00012800
00012900
00013000
00013100
00013200
00013300
00013400
00013500
00013600
00013700
00013800
00013900
00014000
00014100
00014200
00014300
00014400
00014500
00014600
00014700
00014800
00014900
00015000
00015100
00015200
00015JOO
00015400
00015500
00015500
00015600
00015700
00015800
00015900
00016000
00016100
00016200
00016300
00016400
00016500
00016600
00016700
00016800
00016900
00017000
00017100
c
00017200
c
calculate r.m.s. curvatures
00017300
C
00017400
rparam - O.OdO
00017500
rintrn - O.OdO
00017600
do 1100 i • 1,ntotal
accum • 4.0dO*ddot(npairs,derivs(i,npp1),ldder,derivs(i,npp1), 00017700
00017800
*
ldder)
00017900
diag - O.OdO
00018000
do 1000 j • 1,npar
00018100
k • npar+(j*(j+1))/2
00018200
diag • diag+derivs(i,k)
00018300
accum. accum-2.0dO*derivs(i,k)**2
00018400
1000
continue
00018500
if (i .le. npar) then
00018600
rparam - rparam+accum+diag**2
00018700
else
00018800
rintrn • rintrn+accum+diag**2
00018900
endif
00019000
1100 continue
00019100
rmsfac - 1.0dO/float(npar*(npar+2))
00019200
rparam. sqrt(rparam*rmsfac)
00019300
rintrn • sqrt(rintrn*rmsfac)
00019400
c
00019500
return
00019600
end
r
do 850 i • 1,ntotal
do 800 j • 1,npairs
wrkmat(j,1) - ddot(npairs,derivs(i,npp1),ldder,
*
wrkmat(1,j+1), 1)
800
continue
call dcopy(npairs,wrkmat(1,1),1,derivs(i,npp1),ldder)
850 continue
k - npar
do 950 i - 1,npar
do 900 j • 1,i
k • k+1
bmat(i,j) - ddot(npairs,derivs(npp1,k),1,resid(npp1),1)
bmat(j,i) • bmat(i,j)
900
continue
950 continue
SUBROUTINE RSTWR1(THETA, NPAR, R, LOR, NOBS, RSS, STDERR)
DOUBLE PRECISION THETA(NPAR), R(LDR,NPAR), STDERR(NPAR), RSS
INTEGER NPAR, LOR, NOBS
C
C
C
purpose:
Print summary results such as parameter estimates,
standard errors, correlations, and variance estimate
C
C
C
C
C
C
C
C
THETA
NPAR
R
LOR
RSS
STDERR
paramter vector
no. of parameters
array of NPAR x NPAR.
The strict lower triable contains
correlations
leading dimension of R.
variance estimate
parameter standard errors
C
C
C
Gunseog Kang (Nov,1988),
Dept.- of Statistics,
NCSU
C
C
INTEGER INFILE, OUTFIL, VERFIL
COMMON /UNITS/INFILE, OUTF~L, VERFIL
INTEGER DOF, I
C
DOF - NOBS - NPAR
WRITE(OUTFIL,'(/lX,A,/)')
*
'Para.
Estimate
Std.Error
Correlation'
DO 100 I - 1, NPAR
WRITE(OUTFIL,'(lX, I3, 1P,G14.6,G14.6, OP,{lX,10F6.2))')
*
I, THETA(I), STDERR(I), (R(I,J), J-1, 1-1), 1.000
100 CONTINUE
WRITE(OUTFIL,'(/lX,A,lP,G12.4,A, IS, A)')
*
'Variance estimate " RSS, ,
based on', DOF,
*
, degrees of freedom'
RETURN
END
00000100
00000200
00000300
00000400
00000500
00000600
00000700
00000800
00000900
00001000
00001100
00001200
00001300
00001400
00001500
00001600
00001700
00001800
00001900
00002000
00002100
00002200
00002300
00002400
- 00002500
00002600
00002700
00002800
00002900
00003,000
00003100
00003200
00003300
00003400
00003500
00000100
00000200
00000300
00000400
00000500
00000600
00000700
print summary results of the global and marginal
Purpose
00000800
curvature
00000900
00001000
no. of observations
NOBS
00001100
no. of parameters
NPAR
00001200
rms intrinsic curvature
RINTRN
00001300
rms
parameter-effects
curvature
RPARAM
00001400
marginal curvatures for each parameter
MARCUR
00001500
current parameter values
THETA
00001600
parameter standard errors
STDERR
00001700
00001800
00001900
Gunseog Kang (Dec,1988), Dept. of Statistics, NCSU
00002000
00002100
00002200
INTEGER DOF, I
00002300
REAL RDOF
00002400
DOUBLE PRECISION TVAL, TEMPO, TEMP11, TEMP12, TEMP21, TEMP22,
00002500
*
. DTIN
00002600
00002700
DOF - NOBS - NPAR
00002800
WRITE(OUTFIL,10) 'Global curvature (rms)'
00002900
WRITE(OUTFIL,20) 'Intrinsic - " RINTRN,'
Parameter - "
00003000
RPARAM
*
00003100
WRITE(OUTFIL,30) 'Compare these values with F value with (',
00003200
*
NPAR,',', DOF, ') d.f., alpha - 0.05.'
00003300
WRITE(OUTFIL,*) 'Both values are considered small if c * ,
00003400
'sqrt(F) « 1, where c is a curvature.'
*
00003500
WRITE(OUTFIL,*) 'Eg., if we accept a deviation of "
00003600
*
'no more than 15%(10%), then we will declare'
WRITE(OUTFIL,*) 'this analysis as having unacceptable curvature , ,00003700
00003800
*
'if at least one value of'
00003900
WRITE(OUTFIL,*) 'c * sqrt(F)
is greater than 0.3 (0.2)',
00004000
*
, (Bates & watts (1980), JRSSB, pp.1-25)'
00004100
00004200
Print summary results of marginal curvatures
00004300
00004400
RDOF - FLOAT(DOr)
00004500
TVAL - DTIN(0.95, RDOF)
00004600
00004700
WRITE(OUTFIL,10) 'Marginal curvature for each parameter'
00004800
WRITE(OUTFIL,'(/8x,A,/)') 'Para.
Curvature
Ie * tl'
00004900
DO 100 I = 1, NPAR
000050'00
TEMPO = ABS(MARCUR(I)*TVAL)
00005100
WRITE(OUTFIL,40) I, MARCUR(I), TEMPO
00005200
100 CONTINUE
SUBROUTINE RSTWR2(OUTFIL, NOBS, NPAR, RINTRN, RPARAM, MARCUR,
THETA, STDERR)
INTEGER OUTFIL, NOBS, NPAR
DOUBLE PRECISION RINTRN, RPARAM, MARCUR(NPAR), THETA(NPAR),
*
STDERR(NPAR)
*
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
WRITE(OUTFIL,'(/lx,A,A)') 'where c is the marginal curvature "
'and t
is the upper 0.05 quantile of '
WRITE(OUTFIL,'(lx,A,I3,A)') ' t distribution with " DOF, , d.f.'
WRITE(OUTFIL,*) 'If
Ic * tl < 0.1, curvature effects may be "
'ignored and linear approximation'
*
WRITE(OUTFIL,*) ,
will suffice.'
WRITE(OUTFIL,*) 'If 0.1 < I~ * tl < 1/3, curvature effects'
*
'should be compensated for as '
WRITE(OUTFIL,*) ,
suggested by Clarke.'
WRITE(OUTFIL,*) 'If
Ic * tl > 1/3, curvature effects are'
*
'serious enough to make any simple'
WRITE(OUTFIL,*) ,
analysis risky. '
*
'(Clarke (1987), JASA,pp.844-850)'
*
C
C
Print confidence intervals
C
WRITE(OUTFIL,10) '95% Confidence Intervals'
WRITE(OUTFIL,'(/24x,A,A)') 'Linear Approx.
Adjusted'
*
'by Curvature'
WRITE(OUTFIL,'(3x,A,A,/)') 'Para.
Est.
Lower',
*
,
Upper
Lower
Upper'
DO 200 I - I , NPAR
TEMP11 - THETA(I) - TVAL*STDERR(I)
TEMP12 - THETA(I) + TVAL*STDERR(I)
TEMPO. TVAL**2 * STDERR(I) * MARCUR(I)
TEMP21 - TEMP11 + TEMPO
TEMP22 - TEMP12 + TEMPO
WRITE(OUTFIL,50) I, THETA(I), TEMP11, TEMP12, TEMP21, TEMP22
200 CONTINUE
10 format(//lx,A)
20 format(/lx, A, f10.5, A, f10.5)
30 format(/lx, A, I3, A, I3, A)
40 format(8x, I3, lx, 2f14.5)
50 format(3x, I3, 1P, G13.4, 2x, 2G11.4, 3x, 2G11.4)
return
end
00005300
00005400
00005500
00005600
00005700
00005800
00005900
00006000
00006100
00006200
00006300
00006400
00006500
00006600
00006700
00006800
00006900
00007000
00007100
00007200
00007300
00007400
00007500
00007600
00007700
00007800
00007900
00008000
00008100
00008200
00008300
00008400
00008500
00008600
00008700
00008800
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
subroutine rstwr3(outfil, nobs, npar, ntrans, trans, curv, stderr)00000100
integer outfil, nobs, npar, ntrans
00000200
double precision trans(ntrans), curv(ntrans), stderr(ntrans)
00000300
00000400
Print the result for the marginal curvature of the transformed
00000500
parameters
00000600
00000700
nobs
no. of observations.
00000800
npar
no. of parameters
00000900
ntrans
no. of parameter transformations
00001000
trans
values of transformations evaluated at the current
00001100
parameter values
00001200
curv
marginal curvatures for transformations
00001300
stderr
standard errors of transformations
00001400
00001500
Gunseog Kang (Dec, 1988), Dept. of Statistics, NCSU
00001600
00001700
INTEGER DOF, I
00001800
REAL RDOF
00001900
DOUBLE PRECISION TVAL, TEMPO, TEMP11, TEMP12, TEMP21, TEMP22,
00002000
*
DTIN
00002100
00002200
DOF • NOBS - NPAR
00002300
RDOF - FLOAT(DOF)
00002400
TVAL • DTIN(0.95, RDOF)
00002500
00002600
write(outfil,'(//lx,A,A)') 'Marginal curvature of the',
00002700
*
, transformed parameters'
00002800
write(outfil,'(/7x,A;i3)') 'No. of transformation • '~ ntrans
00002900
write(outfil,'(/7x,A,A,/)') 'Para.
Value
Std.Error',
00003000
*
,
Curvature
Ic * tl'
00003100
do 100 i • 1, ntrans
00003200
tempO - abs(curv(i)*tval)
00003300
write(outfil,10) i, trans(i), stderr(i), curv(i), tempO
00003400
100 continue
00003500
00003600
Print confidence intervals
00003700
00003800
WRITE(OUTFIL,'(/7x,A)') '95% Confidence Intervals'
00003900
WRITE(OUTFIL,'(/29x,A,A)') 'Linear Approx.
Adjusted',
00004000
*
'by Curvature'
00004100
WRITE(OUTFIL,'(27x,A,A,/)') 'Lower
Upper
Lower', 00004200
*
,
Upper'
00004300
DO 200 I - 1, NTRANS
00004400
TEMP11 - TRANS(I) - TVAL*STDERR(I)
00004500
TEMP12 - TRANS(I) + TVAL*STDERR(I)
00004600
TEMPO - TVAL**2 * STDERR(I) * CURV(I)
00004700
TEMP21 - TEMP11 + TEMPO
00004800
TEMP22 - TEMP12 + TEMPO
00004900
WRITE(OUTFIL,20) TEMP11, TEMP12, TEMP21, TEMP22
00005000
200 CONTINUE
00005100
10 format(7x, i3, 2x, 1p, 2g13.5, Op, 2f13.5)
00005200
20 format(23x, 1p, 2g13.5, 2x, 2g13.5)
000053'00
return
00005400
end
00005500
subroutine stocom (npar, nobs, nind)
integer npar, nobs, nind
C
C
C
C
C
C
C
C
Purpose : Evaluate the amount of storage for the submitted job.
If the amount excesses the one currently assigned,
then it prints a warning message and the necessary
amount of storage for the submitted job.
In that case, the user should modify the currently
assigned storage amount in the main program and
subroutines JSINIT, JDALOC, and JIALOC
C
npar
no. of observations
nobs : no. of observations
nind : no. of design variables
C
C
C
C
Input
C
Gunseog Kang (1/18/89), Dept. of Statistics, NCSU
C
C
integer ntoal, temp1, temp2
C
*
*
integer ptheta, pdesig, pxpect, pobs, pderi1, pderi2, pcurv,
pstdrs, pdet, pdet2, prinv, pbmat, pstderr,
pwo~k1, pwork2, piwork, pwork4, pwork5
C
C
ntotal - npar * (npar+3) /
2
C
C
ptheta
pdesig
pxpect
pderi1
pderi2
pstdrs
prinv
pbmat
pstder
pwork1
pwork2
pwork3
piwork
pwork5
pobs
pcurv
pdet
pdet2
..
•
..
..
..
..
..
..
..
..
..
npar
nobs*nind
nobs
nobs*ntotal
nobs*npar*npar
nobs
npar*npar
npar*npar
npar
2*npar
nobs
ntotal*ntotal
ntotal
npar*npar*npar
nobs
npar
npar
npar
C
C
tempI .. ptheta + pdesig
prinv + pbmat +
*
pwork5
+
* temp2 .. piwork ++ pobs
pdet +
temp1 .. temp1*2 + temp2
C
+ pxpect + pderi1 + pderi2 + pstdrs +
pstder + pwork1 + pwork2 + pwork3 +
pcurv
pdet2
00000100
00000200
00000300
00000400
00000500
00000600
00000700
00000800
00000900
00001000
00001100
00001200
00001300
00001400
00001500
00001600
00001700
00001800
00001900
00002000
00002100
00002200
00002300
00002400
00002500
00002600
00002700
00002800
00002900
00003000
00003100
00003200
00003300
00003400
00003500
00003600
00003700
00003800
00003900
00004000
00004100
00004200
00004300
00004400
00004500
00004600
00004700
00004800
00004900
00005000
00005100
000052'00
00005300
00005400
-C
if (temp1 .gt. 8192) then
write(6,*} 'The total amount of storage needed for this job',
*
, is " temp1, , which is greater than 8192.'
write(6,*} 'Increase the specified amount in the main "
*
, program, and subtoutines JSINIT, JDALOC, JIALOC.'
endif
return
end
00005500
00005600
00005700
00005800
00005900
00006000
00006100
00006200
00006300
00006400
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
subroutine transf (nparam, p, ntrans, trans, tderiv, info)
integer nparam, ntrans, info
double precision p(nparam), trans(nparam),
*
tderiv(nparam,nparam*(nparam+3)/2)
TRANSF for Michaelis-Menten model: f ... p1 * x / (p2 +x)
and transformation f ... x / (p1 + p2*x)
Purpose : specify the 1st and 2nd derivatives of the parameter
transformation.
For each problem, modify only the enclosed part by '*'s.
Input :
nparam
p
Output
ntrans
trans
tderiv
No. of parameters (= npar)
current parameter vector
no. of transformed parameters (- ntpar)
current values of transformed parameters
1st and 2nd derivatives of transformation.
Need to specify only first 'ntpar' rows.
The rest can be set to arbitrary values (or zeros)
1st 'npar' columns contain 1st derivatives
and
next 'npar*(npar+1)/2' columns contain 2nd derivatives
in symmetric storage format (i.e., 11, 12, 22, 13, 23,
33, ••. , PP)
c
c
c
c
c
c
c
c
c
integer npar, ntpar, ntotal, i, j
*************************************************************
parameter (npar=2, ntpar=2)
*************************************************************
if (npar .ne. nparam) then
print *, 'No. of parameters does not match'
info - 1
return
endif
ntrans
ntotal
ntpar
npar*(npar+3)/2
do 200 i - 1, npar
trans(i) ... O.OdO
do 100 j - 1, ntotal
tderiv(i,j) ... O.OdO
100
continue
200 continue
00000100
00000200
00000300
00000400
00000500
00000600
00000700
00000800
00000900
00001000
00001100
00001200
00001300
00001400
00001500
00001600
00001700
00001800
00001900
00002000
00002100
00002200
00002300
00002400
00002500
00002600
00002700
00002800
00002900
00003000
00003100
00003200
00003300
00003400
00003500
00003600
00003700
00003800
00003900
00004000
00004100
00004200
00004300
00004400
00004500
00004600
00004700
00004800
00004900
00005000
00005100
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
00005200
00005300
00005400
transformation:
trans(l)00005500
trans(2) 00005600
up to trans(ntpar) 00005700
00005800
tderiv(l,l) .•••
tderiv(l,npar)
1st derivative :
00005900
00006000
tderiv(ntpar,l) •... tderiv(ntpar,npar)
00006100
00006200
tderiv(1,npar+1) ••.. tderiv(l,ntotal)
2nd derivative
00006300
00006400
tderiv(ntpar,npar+1) ... tderiv(npar,ntotal)
00006500
Example: Let npar - 3, ntpar • 1
and consider a new transformation 00006600
00006700
t - p(l) + p(3)**3.
Then,
00006800
00006900
trans(l) - p(l) + p(3)**3
00007000
tderiv(l,l) • 1.0dO
00007100
tderiv(1,3) • 3.0dO * p(3)**2
00007200
tderiv(1,9) • 6.0dO * p(3)
00007300
00007400
Note : it is not necessary to define terms whose value
00007500
is zero.
00007600
00007700
*********~***************************************************
00007800
**
00007900
trans(l) - p(2) / p(l)
00008000
trans(2) - 1.0dO / p(l)
00008100
00008200
first derivatives
00008300
00008400
tderiv(l,l) - - p(2) / p(1)**2
00008500
tderiv(I,2) - 1.0dO / p(l)
00008600
tderiv(2,1) • - 1.OdO/ p(I)**2
00008700
tderiv(2,2) • O.OdO
00008800
00008900
second derivatives
00009000
00009100
tderiv(I,3) • 2.0dO * p(2) / p(1)**3
00009200
tderiv(I,4) . ' - 1.0dO/ p(1)**2
00009300
tderiv(I,5) = O.OdO
00009400
tderiv(2,3) - 2.0dO / p(1)**3
00009500
tderiv(2,4) - O.OdO
00009600
tderiv(2,5) - O.OdO
00009700
**
00009800
*************************************************************
00009900
00010000
info = 0
00010100
return
000102-00
end
Specification of the transformation and its 1st and 2nd derivatives
..... . .. . . . ......... . ..........
c
C
C
Michaelis-Menten : M210
f - p(l) * x / ( p(2) + x )
subroutine model (nobs, p, design, lddsgn, job, xpectd, deriv1,
Id1, info)
integer npar, ntotal, nvar
parameter (npar-2, ntotal-5, nvar-1)
integer nobs, lddsgn, job, Id1, info
double precision p(npar), design(lddsgn,nvar), xpectd(nobs),
*
deriv1(ld1,ntotal)
*
C
C
c
c
C
C
integer i, j, k
double precision f, denom
info - 0
do 100 i - 1, nobs
denom - p(2) + design(i,nvar)
if ( denom .le. O.OdO ) then
info - -1
return
endif
f -- p(l) * design(i,nvar) / denom
xpectd(i) - f
function values
first derivatives
if (mod(job,10) .ne. 0) then
deriv1(i,1) - design(i,nvar) / denom
deriv1(i,2) - - f / denom
endif
C
second derivatives
if (mod((job/10),10) .ne. 0) then
deriv1(i,3)
= O.OdO
deriv1(i,4)
- - f / ( p(l) ~ denom
deriv1(i,5)
- 2.0dO * f / denom**2
endif
if (job/100 .ne. 0) then
info - 3
endif
100 continue
return
end
00000100
00000200
00000300
00000400
00000500
00000600
00000700
00000800
00000900
00001000
00001100
00001200
00001300
00001400
00001500
00001600
00001700
00001800
00001900
00002000
00002100
00002200
00002300
00002400
00002500
00002600
00002700
00002800
00002900
00003000
00003100
00003200
00003300
00003400
00003500
00003600
00003700
00003800
0000390000004000
00004100
00004200
00004300
.00004400
HAELIS-MENTEN MODEL, F - P1 * X / ( P2 + X )
2 1
<--- NO. OF PARA. , OPTION FOR ESTIMATION
0.6904 0.5965
<-- INITIAL PARA. VALUES
1 6
1
<-- NO. OF X VARIABLES, OBS., & OPTION FOR Y
0.138 0.148
<-- DATA, X'S & Y
0.220 0.171
0.291 0.234
0.560 0.324
0.766 0.390
1.460 0.493
1
<-- OPTION FOR PARAMETER TRANSFORMATION
3
<-- NO. OF PARA. COMBINATION FOR SUBSET DESIGN
1
1 1
o1
1 0
END
00000100
00000200
00000300
00000400
00000500
00000600
00000700
00000800
00000900
00001000
00001100
00001200
00001300
00001400
00001500
00001600