2
$\begingroup$

I recently using the day.csv file which is downloaded from http://archive.ics.uci.edu/ml/machine-learning-databases/00275/ to build a regression model for the last column “cnt” in R. This is the number of bikes rented a day. I first drop the variable "dteday" since it is not useful in building the model, and fit the model predicting cnt with the other 14 variables. Seeing that from the summary of fit1, we notice that there are only 4 significant variables with very small p-value < 0.05, which are season, atemp, casual, and registered.

    #model1
    fit1=lm(cnt~instant+season+yr+mnth+holiday+weekday+workingday+weathersit+temp+atemp+hum+windspeed+casual+registered)
    summary(fit1)
    Call:
    lm(formula = cnt ~ instant + season + yr + mnth + holiday + weekday + 
workingday + weathersit + temp + atemp + hum + windspeed + 
casual + registered)

    Residuals:
           Min         1Q     Median         3Q        Max 
    -2.541e-11 -2.540e-13 -3.000e-15  2.151e-13  2.653e-11 

    Coefficients:
                  Estimate Std. Error    t value Pr(>|t|)    
    (Intercept) -6.216e-13  4.601e-13 -1.351e+00  0.17710    
    instant      1.442e-15  6.651e-15  2.170e-01  0.82848    
    season      -9.284e-13  1.060e-13 -8.761e+00  < 2e-16 ***
    yr          -6.468e-13  2.455e-12 -2.630e-01  0.79229    
    mnth         2.040e-13  2.051e-13  9.940e-01  0.32043    
    holiday     -1.644e-13  3.642e-13 -4.510e-01  0.65190    
    weekday      3.328e-14  2.971e-14  1.120e+00  0.26307    
    workingday  -3.965e-13  2.203e-13 -1.799e+00  0.07238 .  
    weathersit   5.849e-14  1.482e-13  3.950e-01  0.69324    
    temp        -2.146e-12  2.535e-12 -8.460e-01  0.39766    
    atemp        8.693e-12  2.873e-12  3.026e+00  0.00256 ** 
    hum          7.270e-13  5.709e-13  1.273e+00  0.20333    
    windspeed    7.140e-13  8.390e-13  8.510e-01  0.39505    
    casual       1.000e+00  1.590e-16  6.288e+15  < 2e-16 ***
    registered   1.000e+00  9.141e-17  1.094e+16  < 2e-16 ***
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

    Residual standard error: 1.569e-12 on 716 degrees of freedom
    Multiple R-squared:      1, Adjusted R-squared:      1 
    F-statistic: 7.944e+31 on 14 and 716 DF,  p-value: < 2.2e-16

    Warning message:
    In summary.lm(fit1) : essentially perfect fit: summary may be unreliable    

Then I fit my second model with:

    fit2=lm(cnt~season+atemp+casual+registered)
    summary(fit2)
    par(mfrow=c(2,2))
    plot(fit2)
    Call:
    lm(formula = cnt ~ season + atemp + casual + registered)

    Residuals:
           Min         1Q     Median         3Q        Max 
    -2.923e-12 -2.195e-13 -8.280e-14  5.450e-14  2.630e-11 

    Coefficients:
                  Estimate Std. Error    t value Pr(>|t|)    
    (Intercept)  4.593e-12  1.732e-13  2.652e+01  < 2e-16 ***
    season       3.785e-13  5.035e-14  7.518e+00 1.65e-13 ***
    atemp       -5.717e-12  4.115e-13 -1.389e+01  < 2e-16 ***
    casual       1.000e+00  8.827e-17  1.133e+16  < 2e-16 ***
    registered   1.000e+00  4.052e-17  2.468e+16  < 2e-16 ***
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

    Residual standard error: 1.36e-12 on 726 degrees of freedom
    Multiple R-squared:      1, Adjusted R-squared:      1 
    F-statistic: 3.701e+32 on 4 and 726 DF,  p-value: < 2.2e-16

    Warning message:
    In summary.lm(fit2) : essentially perfect fit: summary may be unreliable    

enter image description here

Right now I am little confused on my regression diagnostic plots, the QQ plot seems not normal but I do not know how to interpret it. Do I need a log transformation in order to fix the plot? Also, I noticed that both my models have a very small residual standard error, and both R^2 and Adjusted R^2 are 1. Does it mean that my models are overfitted? How can I possibly fix it in this case?

Thank you so much for your help!

$\endgroup$
  • 1
    $\begingroup$ R has given you a warning that you essentially have a perfect fit and that the summary is unreliable. Try examining the three points which stand out in your plots. $\endgroup$ – mdewey May 29 '16 at 11:47
0
$\begingroup$

No, transformations, log or any other, will not help here. R is warning you that you have an essentially perfect fit. Look at the residual standard error, about $10^{-12}$, that is, essentially zero. The few points standing out in the plots are irrelevant here, it might be just numerics. This residuals (unstandardized!) are also essentially zero, just a bit larger than the others. The number of residual degrees of freedom is large, so it is not clear why you have a perfect fit. You should investigate that.

Then, maybe, fit with cross-validation? But first tell us when you have an explication of the essentially perfect fit.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.