I am doing multiple linear regression analysis in R and I got the following summary:

lm(formula = Y ~ X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8 + X9 + 
    X10 + X11 + X12 + X13)

ALL 20 residuals are 0: no residual degrees of freedom!

Coefficients: (151 not defined because of singularities)
                   Estimate Std. Error t value Pr(>|t|)
(Intercept)       -15462.94         NA      NA       NA
X1                    63.31         NA      NA       NA
X2                  1363.12         NA      NA       NA
X31,266,019,376     5518.54         NA      NA       NA
X31,483,786,035    29894.78         NA      NA       NA
X31,619,000,000    39338.01         NA      NA       NA
X31,687,000,000    65308.07         NA      NA       NA
X31,720,264,324    35548.79         NA      NA       NA
X31,749,000,000    31693.75         NA      NA       NA


X13692,062,808           NA         NA      NA       NA
X13693,179,733           NA         NA      NA       NA
X13724,817,439           NA         NA      NA       NA

Residual standard error: NaN on 0 degrees of freedom
Multiple R-squared:      1, Adjusted R-squared:    NaN 
F-statistic:   NaN on 19 and 0 DF,  p-value: NA

Could anybody explain what does that result mean? And what should I do?

Thank you!

Another question. What should I do if the following error appears:

Error in step(model) : 
number of rows in use has changed: remove missing values?

Variable X3 appears to be a factor.

It looks like this is because you tried to read in a column of numbers with commas in it, (which was the one you have called X3). Having commas in it meant it was treated as character rather than numeric, and then (automatically) converted to a factor.

Try this: is.factor(X3). If that's TRUE, that's what your problem is.

Check whether any of your other variables got turned into factors when they should be numeric.

You need to make sure these read in properly. If the numbers are in a spreadsheet, change the format to avoid commas or set up your reading of the data to deal with numbers formatted with commas.

  • $\begingroup$ I checked all the variables and found they are all factors and have commas (the data set was created during some operations but not from reading it from spreadsheet). How can I handle with that in R? Thank you! $\endgroup$ – user45145 Nov 11 '14 at 3:18
  • $\begingroup$ The easiest way would probably be to recreate it as numbers from the start, without the commas. An alternative would be to convert to character, remove the commas and then read from the character variable. There are other possibilities. $\endgroup$ – Glen_b Nov 11 '14 at 6:03
  • $\begingroup$ Thank you! I edited my question, please take a look at it. $\endgroup$ – user45145 Nov 11 '14 at 14:25
  • $\begingroup$ It's not possible to tell what you did. You need to ask a new question with a minimal reproducible example (i.e. very short code & data that still has your problem, which will run & give the same error) so people can see what's going on - it doesn't look like it's related to the original problem (though you should link to this one just in case). Depending on whether there's any statistical component to the question or not (I can't tell for sure from what you have there), the new question may be more on topic at stackoverflow (as long as there's a reproducible example) rather than here. $\endgroup$ – Glen_b Nov 11 '14 at 22:00

The result means that you do not have enough observations to fit a model with 13 variables and an intercept. If you have 14 or less observations, you fit the model perfectly. In 2D, imagine that you have just 2 observations - then you can easily fit a line through them just by calculating a slope and an intercept. You do not know any other observation to fully determine the line to fit these observations.

In case of 13 variables and an intercept, the interpretation is similar - you can calculate the coefficients instead of estimating them.

  • 2
    $\begingroup$ As Glen_b notes, at least one variable is a factor, not numeric, so the OP does not have 13 variables + intercept, but much more. If all variables were numeric, there would at least be more observations than parameters. (Not that it makes much sense to fit 20 observations with 13 regressors.) Nevertheless, your point is valid, +1. $\endgroup$ – Stephan Kolassa Nov 6 '14 at 8:21
  • $\begingroup$ @StephanKolassa Thank you! I also received the error, could you help me to fix it: Error in step(model) : number of rows in use has changed: remove missing values? $\endgroup$ – user45145 Nov 11 '14 at 17:47

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.