Polynomial regression example

The data gives the weight, in kilograms, of an obese patient at 52 time points over an 8 month period of a weight rehabilitation programme.

Linear model

## 
## Call:
## lm(formula = Weight ~ Days, model = T)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -4.522 -2.891 -1.331  3.096  7.460 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 176.890244   0.987644   179.1   <2e-16 ***
## Days         -0.290735   0.007125   -40.8   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.639 on 50 degrees of freedom
## Multiple R-squared:  0.9708, Adjusted R-squared:  0.9703 
## F-statistic:  1665 on 1 and 50 DF,  p-value: < 2.2e-16

Forward selection w.r.t. \(F\)-test (\(t\)-test)

## Analysis of Variance Table
## 
## Model 1: Weight ~ Days
## Model 2: Weight ~ Days + I(Days^2)
## Model 3: Weight ~ Days + I(Days^2) + I(Days^3)
## Model 4: Weight ~ Days + I(Days^2) + I(Days^3) + I(Days^4)
##   Res.Df    RSS Df Sum of Sq        F  Pr(>F)    
## 1     50 662.14                                  
## 2     49  43.17  1    618.98 759.3607 < 2e-16 ***
## 3     48  39.23  1      3.93   4.8223 0.03306 *  
## 4     47  38.31  1      0.92   1.1328 0.29261    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Forward selection w.r.t. AIC

##          Step Df   Deviance Resid. Df Resid. Dev        AIC
## 1             NA         NA        50  662.14039 136.300162
## 2 + I(Days^2) -1 618.975207        49   43.16518  -3.682898
## 3 + I(Days^3) -1   3.930809        48   39.23437  -6.647909

Cubic model

## 
## Call:
## lm(formula = Weight ~ Days + I(Days^2) + I(Days^3), model = T)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.18223 -0.60311  0.00146  0.49090  2.33690 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.839e+02  4.219e-01 435.809  < 2e-16 ***
## Days        -4.881e-01  1.570e-02 -31.094  < 2e-16 ***
## I(Days^2)    1.022e-03  1.520e-04   6.721 1.97e-08 ***
## I(Days^3)   -8.909e-07  4.062e-07  -2.193   0.0332 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.9041 on 48 degrees of freedom
## Multiple R-squared:  0.9983, Adjusted R-squared:  0.9982 
## F-statistic:  9246 on 3 and 48 DF,  p-value: < 2.2e-16
## 
## Correlation of Coefficients:
##           (Intercept) Days  I(Days^2)
## Days      -0.81                      
## I(Days^2)  0.68       -0.97          
## I(Days^3) -0.59        0.92 -0.99