Computes summary statistics for a polynomial regression model given the fit based on orthogonal polynomials.
A — Vector of length NDEG containing constants used to generate orthogonal polynomials. (Input)
B — Vector of length NDEG containing constants used to generate orthogonal polynomials. (Input)
SMULTC — Multiplicative constant used to compute the scaled version of x, say z, on the interval −2 to 2, inclusive. (Input)
SADDC — Additive constant used to compute the scaled version of x(z) on the interval −2 to 2, inclusive. (Input)
SCOEF — Vector of
length NDEG + 1
containing the regression coefficients of the fitted model using the scaled
version of the original data. (Input)
SCOEF(1) is the
estimated intercept. SCOEF(1 + i)
contains the estimated coefficient for the i-th order orthogonal
polynomial using z.
D — Vector of length NDEG + 1 containing the diagonal elements of the (diagonal) sums of squares and crossproducts matrix. (Input)
DFE — Degrees of freedom for error. (Input)
SSE — Sum of squares for error. (Input)
COEF — NDEG + 1 by 4 matrix
containing statistics relating to the coefficients of the polynomial
model. (Output)
Row 1 corresponds to the intercept. Row 1 +
i corresponds to the coefficient of xi. The columns
are described as follows:
Col. Description
1 Estimated coefficient
2 Estimated standard error of estimated coefficient
3 t-statistic for the test that the coefficient is zero
4 p-value for the two-sided t test
NDEG — Degree of
the polynomial regression. (Input)
Default: NDEG = size (A,1).
LOF — Lack of fit
test option. (Input)
Default: LOF = 0.
LOF Action
0 No lack of fit test is performed.
1 Lack of fit test is performed.
DFPE — Degrees of
freedom for pure error. (Input, if LOF = 1)
If LOF = 0, DFPE is not
referenced.
Default: DFPE = 1.0.
SSPE — Sum of
squares for pure error. (Input, if LOF = 1)
If LOF = 0, SSPE is not
referenced.
Default: SSPE = 0.0.
IPRINT — Printing
option. (Input)
Default: IPRINT = 0.
IPRINT |
Action |
0 |
No printing is performed. |
1 |
AOV, SQSS, COEF are printed. |
AOV — Vector of length 15 that contains statistics relating to the analysis of variance. (Output)
I AOV(I)
1 Degrees of freedom for the model
2 Degrees of freedom for error
3 Total (corrected) degrees of freedom
4 Sum of squares for the model
5 Sum of squares for error
6 Total (corrected) sum of squares
7 Model mean square
8 Error mean square
9 Overall F -statistic
10 p-value
11 R2 (in percent)
12 Adjusted R2 (in percent)
13 Estimate of the standard deviation
14 Overall mean of y
15 Coefficient of variation (in percent)
SQSS — NDEG by 4 matrix
containing sequential statistics for the polynomial model. (Output)
Row i corresponds to xi(i = 1, 2, …, NDEG). The columns are
described as follows:
Col. Description
1 Degrees of freedom
2 Sum of squares
3 F -statistic
4 p-value
LDSQSS — Leading
dimension of SQSS exactly as
specified in the dimension statement of the calling program.
(Input)
Default: LDSQSS = size (SQSS,1).
LDCOEF — Leading
dimension of COEF exactly as
specified in the dimension statement of the calling program.
(Input)
Default: LDCOEF = size (COEF,1).
TLOF — NDEG by 4 matrix
containing tests of lack of fit for each degree of the polynomial.
(Output, if LOF
= 1)
If LOF =
0, TLOF is not referenced
and can be a 1 by 1 array. Row i corresponds to
xi(i =
1, 2, …, NDEG). The columns are
described as follows:
Col. Description
1 Degrees of freedom
2 Lack of fit sum of squares
3 F test for lack of fit of the polynomial model of degree i
4 p-value for the F test
LDTLOF — Leading
dimension of TLOF exactly as
specified in the dimension statement of the calling program.
(Input)
Default: LDTLOF = size (TLOF,1).
Generic: CALL RSTAP (A, B, SMULTC, SADDC, SCOEF, D, DFE, SSE, COEF [,…])
Specific: The specific interface names are S_RSTAP and D_RSTAP.
Single: CALL RSTAP (NDEG, A, B, SMULTC, SADDC, SCOEF, D, DFE, SSE, LOF, DFPE, SSPE, IPRINT, AOV, SQSS, LDSQSS, COEF, LDCOEF, TLOF, LDTLOF)
Double: The double precision name is DRSTAP.
Routine RSTAP transforms a polynomial regression model, fitted using orthogonal polynomials, into a polynomial function of the original independent variable. In addition, summary statistics (analysis of variance, t tests, tests for lack of fit) are computed. Results from routine RFORP, which produces the fit using orthogonal polynomials, are used for input.
The fitted model from RFORP is
where the zi’s are the settings of the independent variable x scaled to the interval [−2, 2] and where the pj(z)’s are the orthogonal polynomials. The “XT X” matrix for this model is a diagonal matrix with elements dj (stored in D). The orthogonal polynomials can be expressed as
First, RSTAP computes
to produce the fit for the polynomial function in terms of the scaled independent variable as given by
The variances and covariances for the estimated coefficients in this model are given by
Second, RSTAP computes
as a linear combination of the
by the formula
in order to produce the fit for the polynomial function in terms of the original independent variable as given by
The variance of
computed from the variances and covariances of the
using the usual formula for computing variances of linear combinations of correlated random variables. The sequential sum of squares due to xj(stored in SQSS) is computed by
Workspace may be
explicitly provided, if desired, by use of R2TAP/DR2TAP.
The
reference is:
CALL R2TAP (NDEG, A, B, SMULTC, SADDC, SCOEF, D, DFE, SSE, LOF, DFPE, SSPE, IPRINT, AOV, SQSS, LDSQSS, COEF, LDCOEF, TLOF, LDTLOF, WK)
The additional argument is:
WK — Work vector of length (NDEG + 1) * (NDEG + 7).
A polynomial model is fitted to data discussed by Neter and Wasserman (1974, pages 279−285). The data set contains the response variable y measuring coffee sales (in hundred gallons) and the number of self-service coffee dispensers. Responses for fourteen similar cafeterias are in the data set and some of the cafeterias have the same number of dispensers so that lack of fit of the model can be assessed.
USE RSTAP_INT
USE RFORP_INT
IMPLICIT NONE
INTEGER LDCOEF, LDSQSS, LDTLOF, LDX, MAXDEG, NCOL, NOBS, J
PARAMETER (MAXDEG=2, NCOL=2, NOBS=14, LDCOEF=MAXDEG+1, &
LDSQSS=MAXDEG, LDTLOF=MAXDEG, LDX=NOBS)
!
INTEGER IND, IPRINT, IRSP, LOF, NDEG, NRMISS
REAL A(MAXDEG), AOV(15), B(MAXDEG), COEF(MAXDEG+1,4), &
CRIT, D(MAXDEG+1), DFE, DFPE, SADDC, SCOEF(MAXDEG+1), &
SMULTC, SQSS(LDSQSS,4), SSE, SSPE, TLOF(MAXDEG,4), &
X(LDX,NCOL)
!
DATA (X(1,J),J=1,2) /0.0, 508.1/
DATA (X(2,J),J=1,2) /5.0, 787.6/
DATA (X(3,J),J=1,2) /0.0, 498.4/
DATA (X(4,J),J=1,2) /1.0, 568.2/
DATA (X(5,J),J=1,2) /2.0, 651.7/
DATA (X(6,J),J=1,2) /7.0, 854.7/
DATA (X(7,J),J=1,2) /2.0, 657.0/
DATA (X(8,J),J=1,2) /4.0, 755.3/
DATA (X(9,J),J=1,2) /6.0, 831.8/
DATA (X(10,J),J=1,2) /4.0, 758.9/
DATA (X(11,J),J=1,2) /5.0, 792.1/
DATA (X(12,J),J=1,2) /6.0, 841.4/
DATA (X(13,J),J=1,2) /7.0, 871.4/
DATA (X(14,J),J=1,2) /1.0, 577.3/
!
IRSP = 2
IND = 1
LOF = 1
CALL RFORP (X, IRSP, IND, MAXDEG, NDEG, A, B, SCOEF, D, LOF=LOF, &
SMULTC=SMULTC, SADDC=SADDC, DFE=DFE, SSE=SSE, &
DFPE=DFPE, SSPE=SSPE)
!
IPRINT = 1
CALL RSTAP (A, B, SMULTC, SADDC, SCOEF, D, DFE, SSE, COEF, &
NDEG=NDEG, LOF=LOF, DFPE=DFPE, SSPE=SSPE, IPRINT=IPRINT, &
AOV=AOV, SQSS=SQSS, TLOF=TLOF)
END
R-squared Adjusted Est. Std.
Dev.
Coefficient of
(percent) R-squared of Model
Error Mean Var.
(percent)
99.685
99.628
8.037
711.0
1.13
* * * Analysis of Variance * *
*
Sum of
Mean
Prob.
of
Source
DF Squares Square
Overall F Larger
F
Regression
2 225031.9 112515.9
1741.748
0.0000
Residual
11
710.6 64.6
Corrected
Total 13
225742.5
* * *
Inference on Coefficients * *
*
Standard
Prob. of
Coef. Estimate
Error t-statistic Larger |t|
1 503.3
4.791 105.054
0.0000
2
78.9
3.453 22.865
0.0000
3
-4.0
0.482 -8.242
0.0000
* * * Sequential Statistics * * *
Degree of Degrees
of Sum
of
Prob. of
Polynomial Freedom
Squares F-statistic Larger
F
1
1 220644.1 3415.574
0.0000
2
1 4387.7
67.922
0.0000
* * * Tests of Lack of Fit * * *
Degree of Degrees
of Sum
of
Prob. of
Polynomial Freedom
Squares F-statistic Larger
F
1
5 4793.7
22.031
0.0004
2
4
406.0 2.332
0.1547
PHONE: 713.784.3131 FAX:713.781.9260 |