The GLM Procedure

Example 47.2 Regression with Mileage Data

(View the complete code for this example.)

A car is tested for gas mileage at various speeds to determine at what speed the car achieves the highest gas mileage. A quadratic model is fit to the experimental data. The following statements produce Output 47.2.1 through Output 47.2.4.

title 'Gasoline Mileage Experiment';
data mileage;
   input mph mpg @@;
   datalines;
20 15.4
30 20.2
40 25.7
50 26.2  50 26.6  50 27.4
55   .
60 24.8
;
ods graphics on;
proc glm;
   model mpg=mph mph*mph / p clm;
run;
ods graphics off;

Output 47.2.1: Standard Regression Analysis

Gasoline Mileage Experiment

The GLM Procedure

Number of Observations Read8
Number of Observations Used7

Gasoline Mileage Experiment

The GLM Procedure
 
Dependent Variable: mpg

SourceDFSum of SquaresMean SquareF ValuePr > F
Model2111.808618355.904309177.960.0006
Error42.86852460.7171311  
Corrected Total6114.6771429   

R-SquareCoeff VarRoot MSEmpg Mean
0.9749863.5645530.84683623.75714

SourceDFType I SSMean SquareF ValuePr > F
mph185.6446428685.64464286119.430.0004
mph*mph126.1639754126.1639754136.480.0038

SourceDFType III SSMean SquareF ValuePr > F
mph141.0117121941.0117121957.190.0016
mph*mph126.1639754126.1639754136.480.0038

ParameterEstimateStandard
Error
t ValuePr > |t|
Intercept-5.9852459023.18522249-1.880.1334
mph1.3052459020.172598767.560.0016
mph*mph-0.0130983610.00216852-6.040.0038


The overall F statistic is significant. The tests of mph and mph*mph in the Type I sums of squares show that both the linear and quadratic terms in the regression model are significant. The model fits well, with an R square of 0.97. The table of parameter estimates indicates that the estimated regression equation is

Output 47.2.2: Results of Requesting the P and CLM Options

Observation ObservedPredictedResidual95% Confidence Limits for Mean Predicted
Value
1 15.4000000014.880327870.5196721312.6970131717.06364257
2 20.2000000021.38360656-1.1836065620.0172719222.74994119
3 25.7000000025.267213110.4327868923.8746004126.65982582
4 26.2000000026.53114754-0.3311475425.4457342327.61656085
5 26.6000000026.531147540.0688524625.4457342327.61656085
6 27.4000000026.531147540.8688524625.4457342327.61656085
7*.26.18073770.24.8867930827.47468233
8 24.8000000025.17540984-0.3754098423.0595497727.29126990


The P and CLM options in the MODEL statement produce the table shown in Output 47.2.2. For each observation, the observed, predicted, and residual values are shown. In addition, the 95% confidence limits for a mean predicted value are shown for each observation. Note that the observation with a missing value for mph is not used in the analysis, but predicted and confidence limit values are shown.

Output 47.2.3: Additional Results of Requesting the P and CLM Options

Sum of Residuals-0.00000000
Sum of Squared Residuals2.86852459
Sum of Squared Residuals - Error SS-0.00000000
PRESS Statistic23.18107335
First Order Autocorrelation-0.54376613
Durbin-Watson D2.94425592


The last portion of the output listing, shown in Output 47.2.3, gives some additional information about the residuals. The Press statistic gives the sum of squares of predicted residual errors, as described in Chapter 4: Introduction to Regression Procedures. The First Order Autocorrelation and the Durbin-Watson D statistic, which measures first-order autocorrelation, are also given.

Output 47.2.4: Plot of Mileage Data

Plot of Mileage Data


Finally, the ODS GRAPHICS ON command in the previous statements enables ODS Graphics, which in this case produces the plot shown in Output 47.2.4 of the actual and predicted values for the data, as well as a band representing the confidence limits for individual predictions. The quadratic relationship between mpg and mph is evident.