IMSL_WEIGHTS, floatweights[] (Input) Array with n_observations components containing the vector of weights for the observation. If this option is not specified, all observations have equal weights of one.
IMSL_SSQ_POLY, float**p_ssq_poly (Output) The address of a pointer to the array containing the sequential sums of squares and other statistics. On return, the pointer is initialized (through a memory allocation request to malloc), and the array is stored there. Typically, float*p_ssq_poly is declared; &p_ssq_poly is used as an argument to this function; and imsl_free(p_ssq_poly) is used to free this array. Row i corresponds to xi, i = 1, …, degree, and the columns are described as follows:
Column
Description
1
degrees of freedom
2
sums of squares
3
F-statistic
4
p-value
IMSL_SSQ_POLY_USER, float ssq_poly[] (Output) Array of size degree× 4 containing the sequential sums of squares for a polynomial fit described under optional argument IMSL_SSQ_POLY.
IMSL_SSQ_POLY_COL_DIM, intssq_poly_col_dim (Input) The column dimension of ssq_poly. Default: ssq_poly_col_dim = 4
IMSL_SSQ_LOF, float**p_ssq_lof (Output) The address of a pointer to the array containing the lack-of-fit statistics. On return, the pointer is initialized (through a memory allocation request to malloc), and the array is stored there. Typically, float*p_ssq_lof is declared; &p_ssq_lof is used as an argument to this function; and imsl_free(p_ssq_lof) is used to free this array. Row i corresponds to xi, i = 1, …, degree, and the columns are described in the following table:
Column
Description
1
degrees of freedom
2
lack-of-fit sums of squares
3
F-statistic for testing lack-of-fit for a polynomial model of degree i
4
p-value for the test
IMSL_SSQ_LOF_USER, floatssq_lof[] (Output) Array of size degree× 4 containing the matrix of lack-of-fit statistics described under optional argument IMSL_SSQ_LOF.
IMSL_SSQ_LOF_COL_DIM, intssq_lof_col_dim (Input) The column dimension of ssq_lof. Default: ssq_lof_col_dim = 4
IMSL_X_MEAN, float*x_mean (Output) The mean of x.
IMSL_X_VARIANCE, float*x_variance (Output) The variance of x.
IMSL_ANOVA_TABLE, float**p_anova_table (Output) The address of a pointer to the array containing the analysis of variance table. On return, the pointer is initialized (through a memory allocation request to malloc), and the array is stored there. Typically, float*p_anova_table is declared; &p_anova_table is used as an argument to this function; and imsl_free(p_anova_table) is used to free this array.
Element
Analysis of Variance Statistic
0
degrees of freedom for the model
1
degrees of freedom for error
2
total (corrected) degrees of freedom
3
sum of squares for the model
4
sum of squares for error
5
total (corrected) sum of squares
6
model mean square
7
error mean square
8
overall F-statistic
9
p-value
10
R2 (in percent)
11
adjusted R2 (in percent)
12
estimate of the standard deviation
13
overall mean of y
14
coefficient of variation (in percent)
IMSL_ANOVA_TABLE_USER, floatanova_table[] (Output) Array of size 15 containing the analysis variance statistics listed under optional argument IMSL_ANOVA_TABLE.
IMSL_DF_PURE_ERROR, int*df_pure_error (Output) If specified, the degrees of freedom for pure error are returned in df_pure_error.
IMSL_SSQ_PURE_ERROR, float*ssq_pure_error (Output) If specified, the sums of squares for pure error are returned in ssq_pure_error.
IMSL_RESIDUAL, float**p_residual (Output) The address of a pointer to the array containing the residuals. On return, the pointer is initialized (through a memory allocation request to malloc), and the array is stored there. Typically, float*p_residual is declared; &p_residual is used as an argument to this function; and imsl_free(p_residual)is used to free this array.
IMSL_RESIDUAL_USER, floatresidual[] (Output) If specified, residual is an array of length n_observations provided by the user. On return, residual contains the residuals.
IMSL_RETURN_USER, floatcoefficients[] (Output) If specified, the least-squares solution for the regression coefficients is stored in array coefficients of size degree + 1 provided by the user.
Description
The function imsl_f_poly_regression computes estimates of the regression coefficients in a polynomial (curvilinear) regression model. In addition to the computation of the fit, imsl_f_poly_regression computes some summary statistics. Sequential sums of squares attributable to each power of the independent variable (stored in ssq_poly) are computed. These are useful in assessing the importance of the higher order powers in the fit. Draper and Smith (1981, pp. 101-102) and Neter and Wasserman (1974, pp. 278-287) discuss the interpretation of the sequential sums of squares. The statistic R2 is the percentage of the sum of squares of y about its mean explained by the polynomial curve. Specifically,
where is the fitted y value at xi and is the mean of y. This statistic is useful in assessing the overall fit of the curve to the data. R2 must be between 0% and 100%, inclusive. R2 = 100% indicates a perfect fit to the data.
Estimates of the regression coefficients in a polynomial model are computed using orthogonal polynomials as the regressor variables. This reparameterization of the polynomial model in terms of orthogonal polynomials has the advantage that the loss of accuracy resulting from forming powers of the x-values is avoided. All results are returned to the user for the original model (power form).
The function imsl_f_poly_regression is based on the algorithm of Forsythe (1957). A modification to Forsythe’s algorithm suggested by Shampine (1975) is used for computing the polynomial coefficients. A discussion of Forsythe’s algorithm and Shampine’s modification appears in Kennedy and Gentle (1980, pp. 342-347).
Examples
Example 1
A polynomial model is fitted to data discussed by Neter and Wasserman (1974, pp. 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 14 similar cafeterias are in the data set. A graph of the results also is given.